From 26297ca641296b890ccdb707fb25265b6712ac32 Mon Sep 17 00:00:00 2001 From: Teon Banek Date: Thu, 31 Aug 2017 16:38:52 +0200 Subject: [PATCH] ldbc: Extract update queries Summary: Convert update queries to oC supported by MG Ignore ve2 in ldbc Reviewers: buda, mislav.bradac, florijan Reviewed By: buda Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D733 --- tests/public_benchmark/ldbc/.gitignore | 1 + .../ldbc/test_cases/queries/update_1.cyp | 19 ++++++++++++++++++ .../ldbc/test_cases/queries/update_1.oc | 20 +++++++++++++++++++ .../ldbc/test_cases/queries/update_2.cyp | 12 +++++++++++ .../ldbc/test_cases/queries/update_2.oc | 12 +++++++++++ .../ldbc/test_cases/queries/update_3.cyp | 4 ++++ .../ldbc/test_cases/queries/update_3.oc | 4 ++++ .../ldbc/test_cases/queries/update_4.cyp | 11 ++++++++++ .../ldbc/test_cases/queries/update_4.oc | 12 +++++++++++ .../ldbc/test_cases/queries/update_5.cyp | 5 +++++ .../ldbc/test_cases/queries/update_5.oc | 5 +++++ .../ldbc/test_cases/queries/update_6.cyp | 17 ++++++++++++++++ .../ldbc/test_cases/queries/update_6.oc | 18 +++++++++++++++++ .../ldbc/test_cases/queries/update_7.cyp | 17 ++++++++++++++++ .../ldbc/test_cases/queries/update_7.oc | 18 +++++++++++++++++ .../ldbc/test_cases/queries/update_8.cyp | 4 ++++ .../ldbc/test_cases/queries/update_8.oc | 4 ++++ 17 files changed, 183 insertions(+) create mode 100644 tests/public_benchmark/ldbc/test_cases/queries/update_1.cyp create mode 100644 tests/public_benchmark/ldbc/test_cases/queries/update_1.oc create mode 100644 tests/public_benchmark/ldbc/test_cases/queries/update_2.cyp create mode 100644 tests/public_benchmark/ldbc/test_cases/queries/update_2.oc create mode 100644 tests/public_benchmark/ldbc/test_cases/queries/update_3.cyp create mode 100644 tests/public_benchmark/ldbc/test_cases/queries/update_3.oc create mode 100644 tests/public_benchmark/ldbc/test_cases/queries/update_4.cyp create mode 100644 tests/public_benchmark/ldbc/test_cases/queries/update_4.oc create mode 100644 tests/public_benchmark/ldbc/test_cases/queries/update_5.cyp create mode 100644 tests/public_benchmark/ldbc/test_cases/queries/update_5.oc create mode 100644 tests/public_benchmark/ldbc/test_cases/queries/update_6.cyp create mode 100644 tests/public_benchmark/ldbc/test_cases/queries/update_6.oc create mode 100644 tests/public_benchmark/ldbc/test_cases/queries/update_7.cyp create mode 100644 tests/public_benchmark/ldbc/test_cases/queries/update_7.oc create mode 100644 tests/public_benchmark/ldbc/test_cases/queries/update_8.cyp create mode 100644 tests/public_benchmark/ldbc/test_cases/queries/update_8.oc diff --git a/tests/public_benchmark/ldbc/.gitignore b/tests/public_benchmark/ldbc/.gitignore index c222b1083..db485e350 100644 --- a/tests/public_benchmark/ldbc/.gitignore +++ b/tests/public_benchmark/ldbc/.gitignore @@ -4,4 +4,5 @@ ldbc-snb-impls/ neo4j_csv_dataset_scale_*/ tmp/ ve3/ +ve2/ *.out diff --git a/tests/public_benchmark/ldbc/test_cases/queries/update_1.cyp b/tests/public_benchmark/ldbc/test_cases/queries/update_1.cyp new file mode 100644 index 000000000..401835489 --- /dev/null +++ b/tests/public_benchmark/ldbc/test_cases/queries/update_1.cyp @@ -0,0 +1,19 @@ +// LdbcUpdate1AddPerson{personId=35184372093118, personFirstName='Sanjay', personLastName='Anand', gender='male', birthday=Sat Jun 11 02:00:00 CEST 1988, creationDate=Thu Sep 13 12:52:35 CEST 2012, locationIp='103.1.131.183', browserUsed='Firefox', cityId=117, languages=[te, bn, en], emails=[Sanjay35184372093118@gmail.com, Sanjay35184372093118@gmx.com, Sanjay35184372093118@yahoo.com], tagIds=[4, 571, 1187, 2931, 8163, 10222, 12296], studyAt=[Organization{organizationId=3650, year=2007}], workAt=[Organization{organizationId=554, year=2008}]} + +// Create the person node. +CREATE (p:Person {id: "35184372093118", firstName: 'Sanjay', lastName: 'Anand', gender: 'male', birthday: 581990400000, creationDate: 1347533555467, locationIP: '103.1.131.183', browserUsed: 'Firefox', speaks: ["te", "bn", "en"], emails: ["Sanjay35184372093118@gmail.com", "Sanjay35184372093118@gmx.com", "Sanjay35184372093118@yahoo.com"]}); + +// Add isLocatedIn and hasInterest relationships. +MATCH (p:Person {id: "35184372093118"}), + (c:Place {id: "117"}) +OPTIONAL MATCH (t:Tag) +WHERE t.id IN ["4", "571", "1187", "2931", "8163", "10222", "12296"] +WITH p, c, collect(t) AS tagSet +CREATE (p)-[:IS_LOCATED_IN]->(c) +FOREACH(t IN tagSet| CREATE (p)-[:HAS_INTEREST]->(t)); + +// Add for each studyAt +MATCH (p:Person {id: "35184372093118"}), (u0:Organisation {id: 3650}) CREATE (p)-[:STUDY_AT {classYear: 2007}]->(u0); + +// Add for each workAt +MATCH (p:Person {id: "35184372093118"}), (c0:Organisation {id: 554}) CREATE (p)-[:WORK_AT {workFrom: 2008}]->(c0); diff --git a/tests/public_benchmark/ldbc/test_cases/queries/update_1.oc b/tests/public_benchmark/ldbc/test_cases/queries/update_1.oc new file mode 100644 index 000000000..11d6cf0c7 --- /dev/null +++ b/tests/public_benchmark/ldbc/test_cases/queries/update_1.oc @@ -0,0 +1,20 @@ +// LdbcUpdate1AddPerson{personId=35184372093118, personFirstName='Sanjay', personLastName='Anand', gender='male', birthday=Sat Jun 11 02:00:00 CEST 1988, creationDate=Thu Sep 13 12:52:35 CEST 2012, locationIp='103.1.131.183', browserUsed='Firefox', cityId=117, languages=[te, bn, en], emails=[Sanjay35184372093118@gmail.com, Sanjay35184372093118@gmx.com, Sanjay35184372093118@yahoo.com], tagIds=[4, 571, 1187, 2931, 8163, 10222, 12296], studyAt=[Organization{organizationId=3650, year=2007}], workAt=[Organization{organizationId=554, year=2008}]} + +// Create the person node. +CREATE (p:Person {id: "35184372093118", firstName: 'Sanjay', lastName: 'Anand', gender: 'male', birthday: 581990400000, creationDate: 1347533555467, locationIP: '103.1.131.183', browserUsed: 'Firefox', speaks: ["te", "bn", "en"], emails: ["Sanjay35184372093118@gmail.com", "Sanjay35184372093118@gmx.com", "Sanjay35184372093118@yahoo.com"]}); + +// Add isLocatedIn and hasInterest relationships. +MATCH (p:Person {id: "35184372093118"}), + (c:Place {id: "117"}) +OPTIONAL MATCH (t:Tag) +WHERE t.id IN ["4", "571", "1187", "2931", "8163", "10222", "12296"] +WITH p, c, collect(t) AS tagSet +CREATE (p)-[:IS_LOCATED_IN]->(c) +// FOREACH(t IN tagSet| CREATE (p)-[:HAS_INTEREST]->(t)); +WITH p, tagSet UNWIND list AS t CREATE (p)-[:HAS_INTEREST]->(t); + +// Add for each studyAt +MATCH (p:Person {id: "35184372093118"}), (u0:Organisation {id: 3650}) CREATE (p)-[:STUDY_AT {classYear: 2007}]->(u0); + +// Add for each workAt +MATCH (p:Person {id: "35184372093118"}), (c0:Organisation {id: 554}) CREATE (p)-[:WORK_AT {workFrom: 2008}]->(c0); diff --git a/tests/public_benchmark/ldbc/test_cases/queries/update_2.cyp b/tests/public_benchmark/ldbc/test_cases/queries/update_2.cyp new file mode 100644 index 000000000..9217d81e5 --- /dev/null +++ b/tests/public_benchmark/ldbc/test_cases/queries/update_2.cyp @@ -0,0 +1,12 @@ +// Parameters are read from an arbitrary line in ldbc_snb_datagen/social_network/updateStream_0_0_forum.csv +// First 3 columns are skipped, then read in order and passed as arguments. +// Missing columns are filled with "" +// The easiest way is to run QueryTester and see the parameters. + +// LdbcUpdate2AddPostLike{personId=26388279073665, postId=1236953235741, creationDate=Thu Sep 13 11:36:22 CEST 2012} +// Date is converted to the number of milliseconds since January 1, 1970, 00:00:00 GMT + +// Add a Like to a Post of the social network. +MATCH (p:Person {id:"26388279073665"}), + (m:Post {id:"1236953235741"}) +CREATE (p)-[:LIKES {creationDate:1347528982194}]->(m); diff --git a/tests/public_benchmark/ldbc/test_cases/queries/update_2.oc b/tests/public_benchmark/ldbc/test_cases/queries/update_2.oc new file mode 100644 index 000000000..9217d81e5 --- /dev/null +++ b/tests/public_benchmark/ldbc/test_cases/queries/update_2.oc @@ -0,0 +1,12 @@ +// Parameters are read from an arbitrary line in ldbc_snb_datagen/social_network/updateStream_0_0_forum.csv +// First 3 columns are skipped, then read in order and passed as arguments. +// Missing columns are filled with "" +// The easiest way is to run QueryTester and see the parameters. + +// LdbcUpdate2AddPostLike{personId=26388279073665, postId=1236953235741, creationDate=Thu Sep 13 11:36:22 CEST 2012} +// Date is converted to the number of milliseconds since January 1, 1970, 00:00:00 GMT + +// Add a Like to a Post of the social network. +MATCH (p:Person {id:"26388279073665"}), + (m:Post {id:"1236953235741"}) +CREATE (p)-[:LIKES {creationDate:1347528982194}]->(m); diff --git a/tests/public_benchmark/ldbc/test_cases/queries/update_3.cyp b/tests/public_benchmark/ldbc/test_cases/queries/update_3.cyp new file mode 100644 index 000000000..5901f300f --- /dev/null +++ b/tests/public_benchmark/ldbc/test_cases/queries/update_3.cyp @@ -0,0 +1,4 @@ +// LdbcUpdate3AddCommentLike{personId=102, commentId=2199029728710, creationDate=Thu Sep 13 11:38:06 CEST 2012} +MATCH (p:Person {id:"102"}), + (m:Comment {id:"2199029728710"}) +CREATE (p)-[:LIKES {creationDate:1347529086733}]->(m); diff --git a/tests/public_benchmark/ldbc/test_cases/queries/update_3.oc b/tests/public_benchmark/ldbc/test_cases/queries/update_3.oc new file mode 100644 index 000000000..5901f300f --- /dev/null +++ b/tests/public_benchmark/ldbc/test_cases/queries/update_3.oc @@ -0,0 +1,4 @@ +// LdbcUpdate3AddCommentLike{personId=102, commentId=2199029728710, creationDate=Thu Sep 13 11:38:06 CEST 2012} +MATCH (p:Person {id:"102"}), + (m:Comment {id:"2199029728710"}) +CREATE (p)-[:LIKES {creationDate:1347529086733}]->(m); diff --git a/tests/public_benchmark/ldbc/test_cases/queries/update_4.cyp b/tests/public_benchmark/ldbc/test_cases/queries/update_4.cyp new file mode 100644 index 000000000..39d05004a --- /dev/null +++ b/tests/public_benchmark/ldbc/test_cases/queries/update_4.cyp @@ -0,0 +1,11 @@ +// LdbcUpdate4AddForum{forumId=2199023287110, forumTitle='Album 14 of Brian Kelly', creationDate=Thu Sep 13 11:41:44 CEST 2012, moderatorPersonId=6597069776618, tagIds=[12273]} + +CREATE (f:Forum {id: "2199023287110", title: 'Album 14 of Brian Kelly', creationDate: 1347529304194}); + +MATCH (f:Forum {id: "2199023287110"}), + (p:Person {id:"6597069776618"}) +OPTIONAL MATCH (t:Tag) +WHERE t.id IN ["12273"] +WITH f, p, collect(t) as tagSet +CREATE (f)-[:HAS_MODERATOR]->(p) +FOREACH (t IN tagSet| CREATE (f)-[:HAS_TAG]->(t)); diff --git a/tests/public_benchmark/ldbc/test_cases/queries/update_4.oc b/tests/public_benchmark/ldbc/test_cases/queries/update_4.oc new file mode 100644 index 000000000..531b2defa --- /dev/null +++ b/tests/public_benchmark/ldbc/test_cases/queries/update_4.oc @@ -0,0 +1,12 @@ +// LdbcUpdate4AddForum{forumId=2199023287110, forumTitle='Album 14 of Brian Kelly', creationDate=Thu Sep 13 11:41:44 CEST 2012, moderatorPersonId=6597069776618, tagIds=[12273]} + +CREATE (f:Forum {id: "2199023287110", title: 'Album 14 of Brian Kelly', creationDate: 1347529304194}); + +MATCH (f:Forum {id: "2199023287110"}), + (p:Person {id:"6597069776618"}) +OPTIONAL MATCH (t:Tag) +WHERE t.id IN ["12273"] +WITH f, p, collect(t) as tagSet +CREATE (f)-[:HAS_MODERATOR]->(p) +// FOREACH (t IN tagSet| CREATE (f)-[:HAS_TAG]->(t)); +WITH f, tagSet UNWIND tagSet AS t CREATE (f)-[:HAS_TAG]->(t); diff --git a/tests/public_benchmark/ldbc/test_cases/queries/update_5.cyp b/tests/public_benchmark/ldbc/test_cases/queries/update_5.cyp new file mode 100644 index 000000000..3085aed82 --- /dev/null +++ b/tests/public_benchmark/ldbc/test_cases/queries/update_5.cyp @@ -0,0 +1,5 @@ +// LdbcUpdate5AddForumMembership{forumId=1786706433093, personId=32985348839299, joinDate=Thu Sep 13 11:36:02 CEST 2012} + +MATCH (f:Forum {id:"1786706433093"}), + (p:Person {id:"32985348839299"}) +CREATE (f)-[:HAS_MEMBER {joinDate:1347528962967}]->(p); diff --git a/tests/public_benchmark/ldbc/test_cases/queries/update_5.oc b/tests/public_benchmark/ldbc/test_cases/queries/update_5.oc new file mode 100644 index 000000000..3085aed82 --- /dev/null +++ b/tests/public_benchmark/ldbc/test_cases/queries/update_5.oc @@ -0,0 +1,5 @@ +// LdbcUpdate5AddForumMembership{forumId=1786706433093, personId=32985348839299, joinDate=Thu Sep 13 11:36:02 CEST 2012} + +MATCH (f:Forum {id:"1786706433093"}), + (p:Person {id:"32985348839299"}) +CREATE (f)-[:HAS_MEMBER {joinDate:1347528962967}]->(p); diff --git a/tests/public_benchmark/ldbc/test_cases/queries/update_6.cyp b/tests/public_benchmark/ldbc/test_cases/queries/update_6.cyp new file mode 100644 index 000000000..8bdbaf929 --- /dev/null +++ b/tests/public_benchmark/ldbc/test_cases/queries/update_6.cyp @@ -0,0 +1,17 @@ +// LdbcUpdate6AddPost{postId=2199025986581, imageFile='', creationDate=Thu Sep 13 11:41:43 CEST 2012, locationIp='61.16.220.210', browserUsed='Chrome', language='tk', content='About Abbas I of Persia, w Shah Mohammed in a coup and placed the 16-year-old Abbas on the th', length=93, authorPersonId=8796093029267, forumId=549755863266, countryId=0, tagIds=[3]} + +// If the imageFile parameter is not empty, then we need to add it to the created node properties. + +CREATE (m:Post:Message {id: "2199025986581", creationDate: 1347529303996, locationIP: '61.16.220.210', browserUsed: 'Chrome', language: 'tk', content: 'About Abbas I of Persia, w Shah Mohammed in a coup and placed the 16-year-old Abbas on the th', length: 93}); + +MATCH (m:Post {id: "2199025986581"}), + (p:Person {id: "8796093029267"}), + (f:Forum {id: "549755863266"}), + (c:Place {id: "0"}) +OPTIONAL MATCH (t:Tag) +WHERE t.id IN ["3"] +WITH m, p, f, c, collect(t) as tagSet +CREATE (m)-[:HAS_CREATOR]->(p), + (m)<-[:CONTAINER_OF]-(f), + (m)-[:IS_LOCATED_IN]->(c) +FOREACH (t IN tagSet| CREATE (m)-[:HAS_TAG]->(t)); diff --git a/tests/public_benchmark/ldbc/test_cases/queries/update_6.oc b/tests/public_benchmark/ldbc/test_cases/queries/update_6.oc new file mode 100644 index 000000000..252df3032 --- /dev/null +++ b/tests/public_benchmark/ldbc/test_cases/queries/update_6.oc @@ -0,0 +1,18 @@ +// LdbcUpdate6AddPost{postId=2199025986581, imageFile='', creationDate=Thu Sep 13 11:41:43 CEST 2012, locationIp='61.16.220.210', browserUsed='Chrome', language='tk', content='About Abbas I of Persia, w Shah Mohammed in a coup and placed the 16-year-old Abbas on the th', length=93, authorPersonId=8796093029267, forumId=549755863266, countryId=0, tagIds=[3]} + +// If the imageFile parameter is not empty, then we need to add it to the created node properties. + +CREATE (m:Post:Message {id: "2199025986581", creationDate: 1347529303996, locationIP: '61.16.220.210', browserUsed: 'Chrome', language: 'tk', content: 'About Abbas I of Persia, w Shah Mohammed in a coup and placed the 16-year-old Abbas on the th', length: 93}); + +MATCH (m:Post {id: "2199025986581"}), + (p:Person {id: "8796093029267"}), + (f:Forum {id: "549755863266"}), + (c:Place {id: "0"}) +OPTIONAL MATCH (t:Tag) +WHERE t.id IN ["3"] +WITH m, p, f, c, collect(t) as tagSet +CREATE (m)-[:HAS_CREATOR]->(p), + (m)<-[:CONTAINER_OF]-(f), + (m)-[:IS_LOCATED_IN]->(c) +// FOREACH (t IN tagSet| CREATE (m)-[:HAS_TAG]->(t)); +WITH m, tagSet UNWIND tagSet AS t CREATE (m)-[:HAS_TAG]->(t); diff --git a/tests/public_benchmark/ldbc/test_cases/queries/update_7.cyp b/tests/public_benchmark/ldbc/test_cases/queries/update_7.cyp new file mode 100644 index 000000000..c3af7b283 --- /dev/null +++ b/tests/public_benchmark/ldbc/test_cases/queries/update_7.cyp @@ -0,0 +1,17 @@ +// LdbcUpdate7AddComment{commentId=2199024038763, creationDate=Thu Sep 13 11:36:09 CEST 2012, locationIp='213.55.65.79', browserUsed='Firefox', content='About Arnold Schoenberg, ist movement in German poetry and art, andAbout Ecce Cor M', length=83, authorPersonId=8796093030860, countryId=76, replyToPostId=2199024038761, replyToCommentId=-1, tagIds=[146, 11287]} + +CREATE (c:Comment:Message {id: "2199024038763", creationDate: 1347528969834, locationIP: '213.55.65.79', browserUsed: 'Firefox', content: 'About Arnold Schoenberg, ist movement in German poetry and art, andAbout Ecce Cor M', length: 83}); + +// For replyOfId: if replyToCommentId is -1, then use replyToPostId + +MATCH (m:Comment {id: "2199024038763"}), + (p:Person {id: "8796093030860"}), + (r:Message {id: "2199024038761"}), + (c:Place {id: "76"}) +OPTIONAL MATCH (t:Tag) +WHERE t.id IN ["146", "11287"] +WITH m, p, r, c, collect(t) as tagSet +CREATE (m)-[:HAS_CREATOR]->(p), + (m)-[:REPLY_OF]->(r), + (m)-[:IS_LOCATED_IN]->(c) +FOREACH (t IN tagSet| CREATE (m)-[:HAS_TAG]->(t)); diff --git a/tests/public_benchmark/ldbc/test_cases/queries/update_7.oc b/tests/public_benchmark/ldbc/test_cases/queries/update_7.oc new file mode 100644 index 000000000..eba9fb433 --- /dev/null +++ b/tests/public_benchmark/ldbc/test_cases/queries/update_7.oc @@ -0,0 +1,18 @@ +// LdbcUpdate7AddComment{commentId=2199024038763, creationDate=Thu Sep 13 11:36:09 CEST 2012, locationIp='213.55.65.79', browserUsed='Firefox', content='About Arnold Schoenberg, ist movement in German poetry and art, andAbout Ecce Cor M', length=83, authorPersonId=8796093030860, countryId=76, replyToPostId=2199024038761, replyToCommentId=-1, tagIds=[146, 11287]} + +CREATE (c:Comment:Message {id: "2199024038763", creationDate: 1347528969834, locationIP: '213.55.65.79', browserUsed: 'Firefox', content: 'About Arnold Schoenberg, ist movement in German poetry and art, andAbout Ecce Cor M', length: 83}); + +// For replyOfId: if replyToCommentId is -1, then use replyToPostId + +MATCH (m:Comment {id: "2199024038763"}), + (p:Person {id: "8796093030860"}), + (r:Message {id: "2199024038761"}), + (c:Place {id: "76"}) +OPTIONAL MATCH (t:Tag) +WHERE t.id IN ["146", "11287"] +WITH m, p, r, c, collect(t) as tagSet +CREATE (m)-[:HAS_CREATOR]->(p), + (m)-[:REPLY_OF]->(r), + (m)-[:IS_LOCATED_IN]->(c) +// FOREACH (t IN tagSet| CREATE (m)-[:HAS_TAG]->(t)); +WITH m, tagSet UNWIND tagSet AS t CREATE (m)-[:HAS_TAG]->(t); diff --git a/tests/public_benchmark/ldbc/test_cases/queries/update_8.cyp b/tests/public_benchmark/ldbc/test_cases/queries/update_8.cyp new file mode 100644 index 000000000..929b749af --- /dev/null +++ b/tests/public_benchmark/ldbc/test_cases/queries/update_8.cyp @@ -0,0 +1,4 @@ +// LdbcUpdate8AddFriendship{person1Id=21990232558208, person2Id=32985348841200, creationDate=Thu Sep 13 11:43:09 CEST 2012} +MATCH (p1:Person {id:"21990232558208"}), + (p2:Person {id:"32985348841200"}) +CREATE (p1)-[:KNOWS {creationDate:1347529389109}]->(p2); diff --git a/tests/public_benchmark/ldbc/test_cases/queries/update_8.oc b/tests/public_benchmark/ldbc/test_cases/queries/update_8.oc new file mode 100644 index 000000000..929b749af --- /dev/null +++ b/tests/public_benchmark/ldbc/test_cases/queries/update_8.oc @@ -0,0 +1,4 @@ +// LdbcUpdate8AddFriendship{person1Id=21990232558208, person2Id=32985348841200, creationDate=Thu Sep 13 11:43:09 CEST 2012} +MATCH (p1:Person {id:"21990232558208"}), + (p2:Person {id:"32985348841200"}) +CREATE (p1)-[:KNOWS {creationDate:1347529389109}]->(p2);