From c1df6f26639c740baaaecb289a3a60d956bdee7d Mon Sep 17 00:00:00 2001 From: Xiaoli Zhou Date: Wed, 19 Jul 2023 19:34:20 +0800 Subject: [PATCH] [GIE Compiler] Introduce LDBC CI Tests for Cypher Query (#2984) ## What do these changes do? as titled. ## Related issue number #2914 --------- Co-authored-by: Longbin Lai --- .github/workflows/gaia.yml | 2 +- interactive_engine/compiler/Makefile | 8 +- ...rn_ci.sh => ir_exprimental_advanced_ci.sh} | 6 +- interactive_engine/compiler/pom.xml | 4 + .../common/ir/tools/GraphPlanner.java | 4 + .../integration/suite/ldbc/LdbcQueries.java | 244 ++++++++++++++++++ .../integration/suite/ldbc/QueryContext.java | 38 +++ .../processor/IrTestOpProcessor.java | 3 +- .../suite/pattern/PatternQueryTest.java | 176 ++----------- .../processor/IrStandardOpProcessor.java | 4 +- .../cypher/integration/ldbc/IrLdbcTest.java | 81 ++++++ .../integration/ldbc/IrLdbcTest.java | 2 +- .../integration/pattern/IrPatternTest.java | 2 +- .../integration/standard/IrGremlinTest.java | 2 +- .../ir/core/resource/ldbc_schema.json | 16 ++ interactive_engine/pom.xml | 6 + 16 files changed, 424 insertions(+), 174 deletions(-) rename interactive_engine/compiler/{ir_exprimental_pattern_ci.sh => ir_exprimental_advanced_ci.sh} (88%) create mode 100644 interactive_engine/compiler/src/main/java/com/alibaba/graphscope/cypher/integration/suite/ldbc/LdbcQueries.java create mode 100644 interactive_engine/compiler/src/main/java/com/alibaba/graphscope/cypher/integration/suite/ldbc/QueryContext.java create mode 100644 interactive_engine/compiler/src/test/java/com/alibaba/graphscope/cypher/integration/ldbc/IrLdbcTest.java rename interactive_engine/compiler/src/test/java/com/alibaba/graphscope/{ => gremlin}/integration/ldbc/IrLdbcTest.java (95%) rename interactive_engine/compiler/src/test/java/com/alibaba/graphscope/{ => gremlin}/integration/pattern/IrPatternTest.java (94%) rename interactive_engine/compiler/src/test/java/com/alibaba/graphscope/{ => gremlin}/integration/standard/IrGremlinTest.java (94%) diff --git a/.github/workflows/gaia.yml b/.github/workflows/gaia.yml index 9e0a6b6a9a88..16d1478aeb9f 100644 --- a/.github/workflows/gaia.yml +++ b/.github/workflows/gaia.yml @@ -94,7 +94,7 @@ jobs: run: | cd ${GITHUB_WORKSPACE} git clone -b master --single-branch --depth=1 https://github.com/7br/gstest.git /tmp/gstest - cd ${GITHUB_WORKSPACE}/interactive_engine/compiler && ./ir_exprimental_pattern_ci.sh + cd ${GITHUB_WORKSPACE}/interactive_engine/compiler && ./ir_exprimental_advanced_ci.sh - name: Ir Integration Test on Csr Store run: | diff --git a/interactive_engine/compiler/Makefile b/interactive_engine/compiler/Makefile index 38086e7f3a0b..4f12cfba1142 100644 --- a/interactive_engine/compiler/Makefile +++ b/interactive_engine/compiler/Makefile @@ -43,7 +43,7 @@ test: # start rpc server # make run gremlin_test: - mvn test -Dtest=com.alibaba.graphscope.integration.standard.IrGremlinTest + mvn test -Dtest=com.alibaba.graphscope.gremlin.integration.standard.IrGremlinTest run: cd $(CUR_DIR) && $(java) \ @@ -65,11 +65,13 @@ physical_plan: # start rpc server # make run graph.schema:=../executor/ir/core/resource/ldbc_schema.json ldbc_test: - mvn test -Dtest=com.alibaba.graphscope.integration.ldbc.IrLdbcTest + # todo: need to rewrite gremlin ldbc queries + # mvn test -Dtest=com.alibaba.graphscope.gremlin.integration.ldbc.IrLdbcTest + mvn test -Dtest=com.alibaba.graphscope.cypher.integration.ldbc.IrLdbcTest # start rpc server # make run graph.schema:=../executor/ir/core/resource/ldbc_schema.json pattern_test: - mvn test -Dtest=com.alibaba.graphscope.integration.pattern.IrPatternTest + mvn test -Dtest=com.alibaba.graphscope.gremlin.integration.pattern.IrPatternTest .PHONY: build run diff --git a/interactive_engine/compiler/ir_exprimental_pattern_ci.sh b/interactive_engine/compiler/ir_exprimental_advanced_ci.sh similarity index 88% rename from interactive_engine/compiler/ir_exprimental_pattern_ci.sh rename to interactive_engine/compiler/ir_exprimental_advanced_ci.sh index 88caf5006702..0cfbb89cf663 100755 --- a/interactive_engine/compiler/ir_exprimental_pattern_ci.sh +++ b/interactive_engine/compiler/ir_exprimental_advanced_ci.sh @@ -4,7 +4,7 @@ base_dir=$(cd $(dirname $0); pwd) ps -ef | grep "com.alibaba.graphscope.GraphServer" | awk '{print $2}' | xargs kill -9 || true ps -ef | grep "start_rpc_server" | awk '{print $2}' | xargs kill -9 sleep 3 -# start engine service and load ldbc graph +# start engine service and load ldbc graph with sf=0.1 cd ${base_dir}/../executor/ir/target/release && RUST_LOG=info DATA_PATH=/tmp/gstest/ldbc_graph_exp_bin PARTITION_ID=0 ./start_rpc_server --config ${base_dir}/../executor/ir/integrated/config/distributed/server_0 & cd ${base_dir}/../executor/ir/target/release && @@ -13,8 +13,8 @@ sleep 10 # start compiler service cd ${base_dir} && make run graph.schema:=../executor/ir/core/resource/ldbc_schema.json pegasus.hosts:=127.0.0.1:1234,127.0.0.1:1235 & sleep 5 -# run gremlin standard tests -cd ${base_dir} && make pattern_test +# run pattern tests and ldbc tests +cd ${base_dir} && make pattern_test && make ldbc_test exit_code=$? # clean service ps -ef | grep "com.alibaba.graphscope.GraphServer" | awk '{print $2}' | xargs kill -9 || true diff --git a/interactive_engine/compiler/pom.xml b/interactive_engine/compiler/pom.xml index 8c4f6df1ed27..1a2c503ec937 100644 --- a/interactive_engine/compiler/pom.xml +++ b/interactive_engine/compiler/pom.xml @@ -128,6 +128,10 @@ org.neo4j neo4j + + org.neo4j.driver + neo4j-java-driver + org.immutables value diff --git a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/tools/GraphPlanner.java b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/tools/GraphPlanner.java index aac93f4938b1..120d3d04dea5 100644 --- a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/tools/GraphPlanner.java +++ b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/common/ir/tools/GraphPlanner.java @@ -183,6 +183,10 @@ private RelOptPlanner createRelOptPlanner(PlannerConfig plannerConfig) { } } + public AtomicLong getIdGenerator() { + return idGenerator; + } + public static void main(String[] args) throws Exception { if (args.length < 3 || args[0].isEmpty() || args[1].isEmpty() || args[2].isEmpty()) { throw new IllegalArgumentException( diff --git a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/cypher/integration/suite/ldbc/LdbcQueries.java b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/cypher/integration/suite/ldbc/LdbcQueries.java new file mode 100644 index 000000000000..2833ddbf68df --- /dev/null +++ b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/cypher/integration/suite/ldbc/LdbcQueries.java @@ -0,0 +1,244 @@ +/* + * Copyright 2020 Alibaba Group Holding Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.alibaba.graphscope.cypher.integration.suite.ldbc; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +public class LdbcQueries { + public static QueryContext get_ldbc_2_test() { + String query = + "MATCH (p:PERSON{id:" + + " 19791209300143})-[:KNOWS]-(friend:PERSON)<-[:HASCREATOR]-(message : POST |" + + " COMMENT) \n" + + "WHERE message.creationDate < 20121128080000000 \n" + + "WITH \n" + + "\tfriend.id AS personId, \n" + + "\tfriend.firstName AS personFirstName, \n" + + " friend.lastName AS personLastName, \n" + + " message.id AS postOrCommentId, \n" + + " message.creationDate AS postOrCommentCreationDate \n" + + "ORDER BY \n" + + " postOrCommentCreationDate DESC, \n" + + " postOrCommentId ASC \n" + + "LIMIT 20\n" + + "RETURN personId, personFirstName, personLastName, postOrCommentId"; + List expected = + Arrays.asList( + "Record<{personId: 24189255811566, personFirstName: \"The\"," + + " personLastName: \"Kunda\", postOrCommentId: 1099511875186}>", + "Record<{personId: 30786325578747, personFirstName: \"Zhang\"," + + " personLastName: \"Huang\", postOrCommentId: 1099511787223}>", + "Record<{personId: 8796093023000, personFirstName: \"Peng\"," + + " personLastName: \"Zhang\", postOrCommentId: 1099511959866}>", + "Record<{personId: 13194139533535, personFirstName: \"Shweta\"," + + " personLastName: \"Singh\", postOrCommentId: 1099511997952}>", + "Record<{personId: 13194139533535, personFirstName: \"Shweta\"," + + " personLastName: \"Singh\", postOrCommentId: 1099511997953}>", + "Record<{personId: 13194139533535, personFirstName: \"Shweta\"," + + " personLastName: \"Singh\", postOrCommentId: 1099511722622}>", + "Record<{personId: 13194139533535, personFirstName: \"Shweta\"," + + " personLastName: \"Singh\", postOrCommentId: 1099511997861}>", + "Record<{personId: 4398046511596, personFirstName: \"Ge\", personLastName:" + + " \"Wei\", postOrCommentId: 1099511949726}>", + "Record<{personId: 13194139533535, personFirstName: \"Shweta\"," + + " personLastName: \"Singh\", postOrCommentId: 1099511722621}>", + "Record<{personId: 8796093023000, personFirstName: \"Peng\"," + + " personLastName: \"Zhang\", postOrCommentId: 1099511959863}>", + "Record<{personId: 4398046511596, personFirstName: \"Ge\", personLastName:" + + " \"Wei\", postOrCommentId: 1099511681330}>", + "Record<{personId: 4398046511596, personFirstName: \"Ge\", personLastName:" + + " \"Wei\", postOrCommentId: 1099511949721}>", + "Record<{personId: 8796093023000, personFirstName: \"Peng\"," + + " personLastName: \"Zhang\", postOrCommentId: 1099511993242}>", + "Record<{personId: 8796093023000, personFirstName: \"Peng\"," + + " personLastName: \"Zhang\", postOrCommentId: 1099511980256}>", + "Record<{personId: 13194139533535, personFirstName: \"Shweta\"," + + " personLastName: \"Singh\", postOrCommentId: 1099511997871}>", + "Record<{personId: 13194139533535, personFirstName: \"Shweta\"," + + " personLastName: \"Singh\", postOrCommentId: 1099511645534}>", + "Record<{personId: 13194139533535, personFirstName: \"Shweta\"," + + " personLastName: \"Singh\", postOrCommentId: 1099511722160}>", + "Record<{personId: 30786325578747, personFirstName: \"Zhang\"," + + " personLastName: \"Huang\", postOrCommentId: 1099511977072}>", + "Record<{personId: 24189255811566, personFirstName: \"The\"," + + " personLastName: \"Kunda\", postOrCommentId: 1099511738988}>", + "Record<{personId: 13194139533535, personFirstName: \"Shweta\"," + + " personLastName: \"Singh\", postOrCommentId: 1099511860894}>"); + return new QueryContext(query, expected); + } + + public static QueryContext get_ldbc_3_test() { + String query = + "MATCH (countryX:COUNTRY {name:" + + " 'Puerto_Rico'})<-[:ISLOCATEDIN]-(messageX)-[:HASCREATOR]->(otherP:PERSON),\n" + + " \t(countryY:COUNTRY {name:" + + " 'Republic_of_Macedonia'})<-[:ISLOCATEDIN]-(messageY)-[:HASCREATOR]->(otherP:PERSON),\n" + + " \t(otherP)-[:ISLOCATEDIN]->(city)-[:ISPARTOF]->(countryCity),\n" + + " \t(person:PERSON {id:15393162790207})-[:KNOWS*1..2]-(otherP)\n" + + "WHERE messageX.creationDate >= 20101201080000000 and messageX.creationDate <" + + " 20101231080000000\n" + + " AND messageY.creationDate >= 20101201080000000 and messageY.creationDate <" + + " 20101231080000000\n" + + "\tAND countryCity.name <> 'Puerto_Rico' AND countryCity.name <>" + + " 'Republic_of_Macedonia'\n" + + "WITH otherP, count(messageX) as xCount, count(messageY) as yCount\n" + + "RETURN otherP.id as id,\n" + + "\t\t\t otherP.firstName as firstName,\n" + + "\t\t\t otherP.lastName as lastName,\n" + + "\t\t\t xCount,\n" + + "\t\t\t yCount,\n" + + "\t\t\t xCount + yCount as total\n" + + "ORDER BY total DESC, id ASC\n" + + "Limit 20"; + return new QueryContext(query, Collections.emptyList()); + } + + public static QueryContext get_ldbc_6_test() { + String query = + "MATCH (person:PERSON" + + " {id:30786325579101})-[:KNOWS*1..3]-(other:PERSON)<-[:HASCREATOR]-(post:POST)-[:HASTAG]->(tag:TAG" + + " {name:'Shakira'}),\n" + + " (post)-[:HASTAG]->(otherTag:TAG)\n" + + "WHERE otherTag <> tag\n" + + "RETURN otherTag.name as name, count(distinct post) as postCnt\n" + + "ORDER BY postCnt desc, name asc\n" + + "LIMIT 10"; + List expected = + Arrays.asList( + "Record<{name: \"David_Foster\", postCnt: 4}>", + "Record<{name: \"Muammar_Gaddafi\", postCnt: 2}>", + "Record<{name: \"Robert_John_Mutt_Lange\", postCnt: 2}>", + "Record<{name: \"Alfred_the_Great\", postCnt: 1}>", + "Record<{name: \"Andre_Agassi\", postCnt: 1}>", + "Record<{name: \"Andy_Roddick\", postCnt: 1}>", + "Record<{name: \"Bangladesh\", postCnt: 1}>", + "Record<{name: \"Benito_Mussolini\", postCnt: 1}>", + "Record<{name: \"Clark_Gable\", postCnt: 1}>", + "Record<{name: \"Condoleezza_Rice\", postCnt: 1}>"); + return new QueryContext(query, expected); + } + + public static QueryContext get_ldbc_8_test() { + String query = + "MATCH (person:PERSON {id:" + + " 2199023256816})<-[:HASCREATOR]-(message)<-[:REPLYOF]-(comment:COMMENT)-[:HASCREATOR]->(author:PERSON)\n" + + "RETURN \n" + + "\tauthor.id,\n" + + "\tauthor.firstName,\n" + + "\tauthor.lastName,\n" + + "\tcomment.creationDate as commentDate,\n" + + "\tcomment.id as commentId,\n" + + "\tcomment.content\n" + + "ORDER BY\n" + + "\tcommentDate desc,\n" + + "\tcommentId asc\n" + + "LIMIT 20"; + List expected = + Arrays.asList( + "Record<{id: 13194139533482, firstName: \"Ana Paula\", lastName: \"Silva\"," + + " commentDate: 20120913024615078, commentId: 1099511667820, content:" + + " \"About Heinz Guderian, aised and organized under his direction" + + " About Malacca Sul\"}>", + "Record<{id: 8796093022928, firstName: \"Hao\", lastName: \"Zhu\"," + + " commentDate: 20120909134103021, commentId: 1099511964827, content:" + + " \"About Nothing but the Beat, icki Minaj, Usher, Jennifer Hudson," + + " Jessie J and Sia Furler\"}>", + "Record<{id: 10995116278796, firstName: \"Kenji\", lastName: \"Sakai\"," + + " commentDate: 20120909115826789, commentId: 1099511964825, content:" + + " \"About Humayun, to expand the Empire further, leaving a suAbout" + + " Philip K. Dick, r o\"}>", + "Record<{id: 30786325577752, firstName: \"Jie\", lastName: \"Yang\"," + + " commentDate: 20120909065507083, commentId: 1099511964826, content:" + + " \"no\"}>", + "Record<{id: 24189255812755, firstName: \"Paulo\", lastName: \"Santos\"," + + " commentDate: 20120909051506094, commentId: 1099511964828, content:" + + " \"good\"}>", + "Record<{id: 687, firstName: \"Deepak\", lastName: \"Singh\", commentDate:" + + " 20120908105918087, commentId: 1030792351589, content: \"no" + + " way!\"}>", + "Record<{id: 2199023256586, firstName: \"Alfonso\", lastName: \"Elizalde\"," + + " commentDate: 20120907145833508, commentId: 1030792488768, content:" + + " \"About Humayun, ial legacy for his son, Akbar. His peaceful About" + + " Busta Rhymes, sta Rhy\"}>", + "Record<{id: 30786325578896, firstName: \"Yang\", lastName: \"Li\"," + + " commentDate: 20120907141705148, commentId: 1030792488774, content:" + + " \"roflol\"}>", + "Record<{id: 21990232555834, firstName: \"John\", lastName: \"Garcia\"," + + " commentDate: 20120907134041067, commentId: 1030792488763, content:" + + " \"no way!\"}>", + "Record<{id: 13194139534578, firstName: \"Kunal\", lastName: \"Sharma\"," + + " commentDate: 20120907122417245, commentId: 1030792488765, content:" + + " \"maybe\"}>", + "Record<{id: 15393162789932, firstName: \"Fali Sam\", lastName: \"Price\"," + + " commentDate: 20120907101759051, commentId: 1030792488767, content:" + + " \"roflol\"}>", + "Record<{id: 30786325579189, firstName: \"Cheh\", lastName: \"Yang\"," + + " commentDate: 20120907052608122, commentId: 1030792488759, content:" + + " \"yes\"}>", + "Record<{id: 555, firstName: \"Chen\", lastName: \"Yang\", commentDate:" + + " 20120907024704535, commentId: 1030792488769, content: \"About Skin" + + " and Bones, Another Round, reprising the contribution he made to the" + + " original a\"}>", + "Record<{id: 13194139534382, firstName: \"A.\", lastName: \"Budjana\"," + + " commentDate: 20120907024514312, commentId: 1030792488758, content:" + + " \"duh\"}>", + "Record<{id: 8796093022290, firstName: \"Alexei\", lastName: \"Codreanu\"," + + " commentDate: 20120906212321712, commentId: 1030792488760, content:" + + " \"ok\"}>", + "Record<{id: 21990232555958, firstName: \"Ernest B\", lastName:" + + " \"Law-Yone\", commentDate: 20120906201808132, commentId:" + + " 1030792488766, content: \"great\"}>", + "Record<{id: 26388279067760, firstName: \"Max\", lastName: \"Bauer\"," + + " commentDate: 20120906175431955, commentId: 1030792488761, content:" + + " \"thx\"}>", + "Record<{id: 10995116278300, firstName: \"Jie\", lastName: \"Li\"," + + " commentDate: 20120906174021751, commentId: 1030792488762, content:" + + " \"maybe\"}>", + "Record<{id: 10995116279093, firstName: \"Diem\", lastName: \"Nguyen\"," + + " commentDate: 20120906173946333, commentId: 1030792488764, content:" + + " \"thanks\"}>", + "Record<{id: 26388279066662, firstName: \"Alfonso\", lastName:" + + " \"Rodriguez\", commentDate: 20120906124058972, commentId:" + + " 1030792487632, content: \"good\"}>"); + return new QueryContext(query, expected); + } + + public static QueryContext get_ldbc_12() { + String query = + "MATCH (person:PERSON {id:" + + " 19791209300143})-[:KNOWS]-(friend:PERSON)<-[:HASCREATOR]-(comment:COMMENT)-[:REPLYOF]->(:POST)-[:HASTAG]->(tag:TAG)-[:HASTYPE]->(:TAGCLASS)-[:ISSUBCLASSOF*0..5]->(baseTagClass:TAGCLASS" + + " {name: 'BasketballPlayer'})\n" + + "RETURN\n" + + " friend.id AS personId,\n" + + " friend.firstName AS personFirstName,\n" + + " friend.lastName AS personLastName,\n" + + " collect(DISTINCT tag.name) AS tagNames,\n" + + " count(DISTINCT comment) AS replyCount\n" + + "ORDER BY\n" + + " replyCount DESC,\n" + + " personId ASC\n" + + "LIMIT 20"; + List expected = + Arrays.asList( + "Record<{personId: 8796093023000, personFirstName: \"Peng\"," + + " personLastName: \"Zhang\", tagNames: [\"Michael_Jordan\"]," + + " replyCount: 4}>"); + return new QueryContext(query, expected); + } +} diff --git a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/cypher/integration/suite/ldbc/QueryContext.java b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/cypher/integration/suite/ldbc/QueryContext.java new file mode 100644 index 000000000000..2af48d535e48 --- /dev/null +++ b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/cypher/integration/suite/ldbc/QueryContext.java @@ -0,0 +1,38 @@ +/* + * Copyright 2020 Alibaba Group Holding Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.alibaba.graphscope.cypher.integration.suite.ldbc; + +import java.util.Collections; +import java.util.List; + +public class QueryContext { + private final String query; + private final List expectedResult; + + public QueryContext(String query, List expectedResult) { + this.query = query; + this.expectedResult = expectedResult; + } + + public String getQuery() { + return query; + } + + public List getExpectedResult() { + return Collections.unmodifiableList(expectedResult); + } +} diff --git a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/integration/processor/IrTestOpProcessor.java b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/integration/processor/IrTestOpProcessor.java index d1eeec433dde..4311c6cca709 100644 --- a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/integration/processor/IrTestOpProcessor.java +++ b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/integration/processor/IrTestOpProcessor.java @@ -94,7 +94,8 @@ public ThrowingConsumer select(Context ctx) { Traversal traversal = (Traversal) scriptEngine.eval(script, this.context); applyStrategies(traversal); - long jobId = JOB_ID_COUNTER.incrementAndGet(); + + long jobId = graphPlanner.getIdGenerator().getAndIncrement(); IrMeta irMeta = metaQueryCallback.beforeExec(); QueryStatusCallback statusCallback = createQueryStatusCallback(script, jobId); diff --git a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/integration/suite/pattern/PatternQueryTest.java b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/integration/suite/pattern/PatternQueryTest.java index 8bfaccb33eea..26fd2857cbfd 100644 --- a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/integration/suite/pattern/PatternQueryTest.java +++ b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/integration/suite/pattern/PatternQueryTest.java @@ -63,256 +63,112 @@ public abstract class PatternQueryTest extends AbstractGremlinProcessTest { public void run_pattern_1_test() { Traversal traversal = this.get_pattern_1_test(); this.printTraversalForm(traversal); - int counter = 0; - - String expected = "343476"; - while (traversal.hasNext()) { - Long bindings = traversal.next(); - Assert.assertTrue(bindings.toString().equals(expected)); - ++counter; - } - - Assert.assertEquals(1, counter); + Assert.assertEquals(155633L, traversal.next().longValue()); } @Test public void run_pattern_2_test() { Traversal traversal = this.get_pattern_2_test(); this.printTraversalForm(traversal); - int counter = 0; - - String expected = "87328"; - while (traversal.hasNext()) { - Long bindings = traversal.next(); - Assert.assertTrue(bindings.toString().equals(expected)); - ++counter; - } - - Assert.assertEquals(1, counter); + Assert.assertEquals(55488L, traversal.next().longValue()); } @Test public void run_pattern_3_test() { Traversal traversal = this.get_pattern_3_test(); this.printTraversalForm(traversal); - int counter = 0; - - String expected = "1547850"; - while (traversal.hasNext()) { - Long bindings = traversal.next(); - Assert.assertTrue(bindings.toString().equals(expected)); - ++counter; - } - - Assert.assertEquals(1, counter); + Assert.assertEquals(568408L, traversal.next().longValue()); } @Test public void run_pattern_4_test() { Traversal traversal = this.get_pattern_4_test(); this.printTraversalForm(traversal); - int counter = 0; - - String expected = "33380"; - while (traversal.hasNext()) { - Long bindings = traversal.next(); - Assert.assertTrue(bindings.toString().equals(expected)); - ++counter; - } - - Assert.assertEquals(1, counter); + Assert.assertEquals(23286L, traversal.next().longValue()); } @Test public void run_pattern_5_test() { Traversal traversal = this.get_pattern_5_test(); this.printTraversalForm(traversal); - int counter = 0; - - String expected = "31580"; - while (traversal.hasNext()) { - Long bindings = traversal.next(); - Assert.assertTrue(bindings.toString().equals(expected)); - ++counter; - } - - Assert.assertEquals(1, counter); + Assert.assertEquals(16291L, traversal.next().longValue()); } @Test public void run_pattern_6_test() { Traversal traversal = this.get_pattern_6_test(); this.printTraversalForm(traversal); - int counter = 0; - - String expected = "71733"; - while (traversal.hasNext()) { - Long bindings = traversal.next(); - Assert.assertTrue(bindings.toString().equals(expected)); - ++counter; - } - - Assert.assertEquals(1, counter); + Assert.assertEquals(43169L, traversal.next().longValue()); } @Test public void run_pattern_7_test() { Traversal traversal = this.get_pattern_7_test(); this.printTraversalForm(traversal); - int counter = 0; - - String expected = "6568"; - while (traversal.hasNext()) { - Long bindings = traversal.next(); - Assert.assertTrue(bindings.toString().equals(expected)); - ++counter; - } - - Assert.assertEquals(1, counter); + Assert.assertEquals(2944L, traversal.next().longValue()); } @Test public void run_pattern_8_test() { Traversal traversal = this.get_pattern_8_test(); this.printTraversalForm(traversal); - int counter = 0; - - String expected = "1594426"; - while (traversal.hasNext()) { - Long bindings = traversal.next(); - Assert.assertTrue(bindings.toString().equals(expected)); - ++counter; - } - - Assert.assertEquals(1, counter); + Assert.assertEquals(782347L, traversal.next().longValue()); } @Test public void run_pattern_9_test() { Traversal traversal = this.get_pattern_9_test(); this.printTraversalForm(traversal); - int counter = 0; - - String expected = "33380"; - while (traversal.hasNext()) { - Long bindings = traversal.next(); - Assert.assertTrue(bindings.toString().equals(expected)); - ++counter; - } - - Assert.assertEquals(1, counter); + Assert.assertEquals(23286L, traversal.next().longValue()); } @Test public void run_pattern_10_test() { Traversal traversal = this.get_pattern_10_test(); this.printTraversalForm(traversal); - int counter = 0; - - String expected = "7327"; - while (traversal.hasNext()) { - Long bindings = traversal.next(); - Assert.assertTrue(bindings.toString().equals(expected)); - ++counter; - } - - Assert.assertEquals(1, counter); + Assert.assertEquals(3019L, traversal.next().longValue()); } @Test public void run_pattern_11_test() { Traversal traversal = this.get_pattern_11_test(); this.printTraversalForm(traversal); - int counter = 0; - - String expected = "908981"; - while (traversal.hasNext()) { - Long bindings = traversal.next(); - Assert.assertTrue(bindings.toString().equals(expected)); - ++counter; - } - - Assert.assertEquals(1, counter); + Assert.assertEquals(506513L, traversal.next().longValue()); } @Test public void run_pattern_12_test() { Traversal traversal = this.get_pattern_12_test(); this.printTraversalForm(traversal); - int counter = 0; - - String expected = "89621"; - while (traversal.hasNext()) { - Long bindings = traversal.next(); - Assert.assertTrue(bindings.toString().equals(expected)); - ++counter; - } - - Assert.assertEquals(1, counter); + Assert.assertEquals(232854L, traversal.next().longValue()); } @Test public void run_pattern_13_test() { Traversal traversal = this.get_pattern_13_test(); this.printTraversalForm(traversal); - int counter = 0; - - String expected = "2430116"; - while (traversal.hasNext()) { - Long bindings = traversal.next(); - Assert.assertTrue(bindings.toString().equals(expected)); - ++counter; - } - - Assert.assertEquals(1, counter); + Assert.assertEquals(1602774L, traversal.next().longValue()); } @Test public void run_pattern_14_test() { Traversal traversal = this.get_pattern_14_test(); this.printTraversalForm(traversal); - int counter = 0; - - String expected = "87328"; - while (traversal.hasNext()) { - Long bindings = traversal.next(); - Assert.assertTrue(bindings.toString().equals(expected)); - ++counter; - } - - Assert.assertEquals(1, counter); + Assert.assertEquals(55488L, traversal.next().longValue()); } @Test public void run_pattern_15_test() { Traversal traversal = this.get_pattern_15_test(); this.printTraversalForm(traversal); - int counter = 0; - - String expected = "33380"; - while (traversal.hasNext()) { - Long bindings = traversal.next(); - Assert.assertTrue(bindings.toString().equals(expected)); - ++counter; - } - - Assert.assertEquals(1, counter); + Assert.assertEquals(23286L, traversal.next().longValue()); } @Test public void run_pattern_16_test() { Traversal traversal = this.get_pattern_16_test(); this.printTraversalForm(traversal); - int counter = 0; - - String expected = "33380"; - while (traversal.hasNext()) { - Long bindings = traversal.next(); - Assert.assertTrue(bindings.toString().equals(expected)); - ++counter; - } - - Assert.assertEquals(1, counter); + Assert.assertEquals(23286L, traversal.next().longValue()); } public static class Traversals extends PatternQueryTest { diff --git a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/plugin/processor/IrStandardOpProcessor.java b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/plugin/processor/IrStandardOpProcessor.java index 8b7835df83f8..39c1ae9f2a2a 100644 --- a/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/plugin/processor/IrStandardOpProcessor.java +++ b/interactive_engine/compiler/src/main/java/com/alibaba/graphscope/gremlin/plugin/processor/IrStandardOpProcessor.java @@ -76,13 +76,11 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.TimeoutException; -import java.util.concurrent.atomic.AtomicLong; import java.util.function.Supplier; import javax.script.SimpleBindings; public class IrStandardOpProcessor extends StandardOpProcessor { - protected static final AtomicLong JOB_ID_COUNTER = new AtomicLong(0L); protected Graph graph; protected GraphTraversalSource g; protected Configs configs; @@ -121,7 +119,7 @@ protected void evalOpInternal( String language = AntlrGremlinScriptEngineFactory.LANGUAGE_NAME; - long jobId = JOB_ID_COUNTER.incrementAndGet(); + long jobId = graphPlanner.getIdGenerator().getAndIncrement(); IrMeta irMeta = metaQueryCallback.beforeExec(); QueryStatusCallback statusCallback = createQueryStatusCallback(script, jobId); GremlinExecutor.LifeCycle lifeCycle = diff --git a/interactive_engine/compiler/src/test/java/com/alibaba/graphscope/cypher/integration/ldbc/IrLdbcTest.java b/interactive_engine/compiler/src/test/java/com/alibaba/graphscope/cypher/integration/ldbc/IrLdbcTest.java new file mode 100644 index 000000000000..d5a627977899 --- /dev/null +++ b/interactive_engine/compiler/src/test/java/com/alibaba/graphscope/cypher/integration/ldbc/IrLdbcTest.java @@ -0,0 +1,81 @@ +/* + * Copyright 2020 Alibaba Group Holding Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.alibaba.graphscope.cypher.integration.ldbc; + +import com.alibaba.graphscope.cypher.integration.suite.ldbc.LdbcQueries; +import com.alibaba.graphscope.cypher.integration.suite.ldbc.QueryContext; + +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.neo4j.driver.GraphDatabase; +import org.neo4j.driver.Result; +import org.neo4j.driver.Session; + +public class IrLdbcTest { + private static Session session; + + @BeforeClass + public static void beforeClass() { + String neo4jServerUrl = + System.getProperty("neo4j.bolt.server.url", "neo4j://localhost:7687"); + session = GraphDatabase.driver(neo4jServerUrl).session(); + } + + @Test + public void run_ldbc_2_test() { + QueryContext testQuery = LdbcQueries.get_ldbc_2_test(); + Result result = session.run(testQuery.getQuery()); + Assert.assertEquals(testQuery.getExpectedResult().toString(), result.list().toString()); + } + + @Test + public void run_ldbc_3_test() { + QueryContext testQuery = LdbcQueries.get_ldbc_3_test(); + Result result = session.run(testQuery.getQuery()); + Assert.assertEquals(testQuery.getExpectedResult().toString(), result.list().toString()); + } + + @Test + public void run_ldbc_6_test() { + QueryContext testQuery = LdbcQueries.get_ldbc_6_test(); + Result result = session.run(testQuery.getQuery()); + Assert.assertEquals(testQuery.getExpectedResult().toString(), result.list().toString()); + } + + @Test + public void run_ldbc_8_test() { + QueryContext testQuery = LdbcQueries.get_ldbc_8_test(); + Result result = session.run(testQuery.getQuery()); + Assert.assertEquals(testQuery.getExpectedResult().toString(), result.list().toString()); + } + + @Test + public void run_ldbc_12_test() { + QueryContext testQuery = LdbcQueries.get_ldbc_12(); + Result result = session.run(testQuery.getQuery()); + Assert.assertEquals(testQuery.getExpectedResult().toString(), result.list().toString()); + } + + @AfterClass + public static void afterClass() { + if (session != null) { + session.close(); + } + } +} diff --git a/interactive_engine/compiler/src/test/java/com/alibaba/graphscope/integration/ldbc/IrLdbcTest.java b/interactive_engine/compiler/src/test/java/com/alibaba/graphscope/gremlin/integration/ldbc/IrLdbcTest.java similarity index 95% rename from interactive_engine/compiler/src/test/java/com/alibaba/graphscope/integration/ldbc/IrLdbcTest.java rename to interactive_engine/compiler/src/test/java/com/alibaba/graphscope/gremlin/integration/ldbc/IrLdbcTest.java index ed11a77a9687..a15dfb4c2d55 100644 --- a/interactive_engine/compiler/src/test/java/com/alibaba/graphscope/integration/ldbc/IrLdbcTest.java +++ b/interactive_engine/compiler/src/test/java/com/alibaba/graphscope/gremlin/integration/ldbc/IrLdbcTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.alibaba.graphscope.integration.ldbc; +package com.alibaba.graphscope.gremlin.integration.ldbc; import com.alibaba.graphscope.gremlin.integration.graph.RemoteTestGraph; import com.alibaba.graphscope.gremlin.integration.graph.RemoteTestGraphProvider; diff --git a/interactive_engine/compiler/src/test/java/com/alibaba/graphscope/integration/pattern/IrPatternTest.java b/interactive_engine/compiler/src/test/java/com/alibaba/graphscope/gremlin/integration/pattern/IrPatternTest.java similarity index 94% rename from interactive_engine/compiler/src/test/java/com/alibaba/graphscope/integration/pattern/IrPatternTest.java rename to interactive_engine/compiler/src/test/java/com/alibaba/graphscope/gremlin/integration/pattern/IrPatternTest.java index ef74e43b43a7..49d7d931efe4 100644 --- a/interactive_engine/compiler/src/test/java/com/alibaba/graphscope/integration/pattern/IrPatternTest.java +++ b/interactive_engine/compiler/src/test/java/com/alibaba/graphscope/gremlin/integration/pattern/IrPatternTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.alibaba.graphscope.integration.pattern; +package com.alibaba.graphscope.gremlin.integration.pattern; import com.alibaba.graphscope.gremlin.integration.graph.RemoteTestGraph; import com.alibaba.graphscope.gremlin.integration.graph.RemoteTestGraphProvider; diff --git a/interactive_engine/compiler/src/test/java/com/alibaba/graphscope/integration/standard/IrGremlinTest.java b/interactive_engine/compiler/src/test/java/com/alibaba/graphscope/gremlin/integration/standard/IrGremlinTest.java similarity index 94% rename from interactive_engine/compiler/src/test/java/com/alibaba/graphscope/integration/standard/IrGremlinTest.java rename to interactive_engine/compiler/src/test/java/com/alibaba/graphscope/gremlin/integration/standard/IrGremlinTest.java index 124422382d2c..3d0cdcdd9956 100644 --- a/interactive_engine/compiler/src/test/java/com/alibaba/graphscope/integration/standard/IrGremlinTest.java +++ b/interactive_engine/compiler/src/test/java/com/alibaba/graphscope/gremlin/integration/standard/IrGremlinTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.alibaba.graphscope.integration.standard; +package com.alibaba.graphscope.gremlin.integration.standard; import com.alibaba.graphscope.gremlin.integration.graph.RemoteTestGraph; import com.alibaba.graphscope.gremlin.integration.graph.RemoteTestGraphProvider; diff --git a/interactive_engine/executor/ir/core/resource/ldbc_schema.json b/interactive_engine/executor/ir/core/resource/ldbc_schema.json index 5aa97c437f35..ca7025621bb7 100644 --- a/interactive_engine/executor/ir/core/resource/ldbc_schema.json +++ b/interactive_engine/executor/ir/core/resource/ldbc_schema.json @@ -110,6 +110,22 @@ "name": "COMMENT" }, "columns": [ + { + "key": { + "id": 0, + "name": "id" + }, + "data_type": 2, + "is_primary_key": false + }, + { + "key": { + "id": 2, + "name": "creationDate" + }, + "data_type": 2, + "is_primary_key": false + }, { "key": { "id": 4, diff --git a/interactive_engine/pom.xml b/interactive_engine/pom.xml index 2996b08e20b7..c91ec81edc57 100644 --- a/interactive_engine/pom.xml +++ b/interactive_engine/pom.xml @@ -638,6 +638,12 @@ + + org.neo4j.driver + neo4j-java-driver + ${noe4j.version} + test + org.immutables value