From 7418cec6a8e6f8b80b91b895137be11775142a73 Mon Sep 17 00:00:00 2001 From: Gabor Szarnyas Date: Fri, 1 Mar 2019 19:49:45 +0100 Subject: [PATCH] Rewrote interactive update queries to omit UNWIND operations --- .../interactive-update-1.cypher | 21 +++++++++++-------- .../interactive-update-4.cypher | 6 +++--- .../interactive-update-6.cypher | 6 +++--- .../interactive-update-7.cypher | 8 +++---- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/queries/ldbc-snb-interactive/interactive-update-1.cypher b/queries/ldbc-snb-interactive/interactive-update-1.cypher index 8d2afaa77..97c385fd5 100644 --- a/queries/ldbc-snb-interactive/interactive-update-1.cypher +++ b/queries/ldbc-snb-interactive/interactive-update-1.cypher @@ -2,14 +2,17 @@ MATCH (c:City {id:$cityId}) CREATE (p:Person {id: $personId, firstName: $personFirstName, lastName: $personLastName, gender: $gender, birthday: $birthday, creationDate: $creationDate, locationIP: $locationIP, browserUsed: $browserUsed, speaks: $languages, emails: $emails})-[:IS_LOCATED_IN]->(c) WITH p, count(*) AS dummy1 -UNWIND $tagIds AS tagId - MATCH (t:Tag {id: tagId}) - CREATE (p)-[:HAS_INTEREST]->(t) + +MATCH (t:Tag) +WHERE t.id IN $tagIds +CREATE (p)-[:HAS_INTEREST]->(t) WITH p, count(*) AS dummy2 -UNWIND $studyAt AS s - MATCH (u:Organisation {id: s[0]}) - CREATE (p)-[:STUDY_AT {classYear: s[1]}]->(u) + +MATCH (u:Organisation) +WHERE u.id IN [ s IN $studyAt | s[0] ] +CREATE (p)-[:STUDY_AT {classYear: [ s IN $studyAt WHERE s[0] = u.id | s[1] ][0] }]->(u) WITH p, count(*) AS dummy3 -UNWIND $workAt AS w - MATCH (comp:Organisation {id: w[0]}) - CREATE (p)-[:WORKS_AT {workFrom: w[1]}]->(comp) + +MATCH (comp:Organisation) +WHERE comp.id IN [ w IN $workAt | w[0] ] +CREATE (p)-[:WORKS_AT {workFrom: [ w IN $workAt WHERE w[0] = comp.id | w[1] ][0] }]->(comp) diff --git a/queries/ldbc-snb-interactive/interactive-update-4.cypher b/queries/ldbc-snb-interactive/interactive-update-4.cypher index d7d1dd035..bb2940d9b 100644 --- a/queries/ldbc-snb-interactive/interactive-update-4.cypher +++ b/queries/ldbc-snb-interactive/interactive-update-4.cypher @@ -2,6 +2,6 @@ MATCH (p:Person {id: $moderatorPersonId}) CREATE (f:Forum {id: $forumId, title: $forumTitle, creationDate: $creationDate})-[:HAS_MODERATOR]->(p) WITH f -UNWIND $tagIds AS tagId - MATCH (t:Tag {id: tagId}) - CREATE (f)-[:HAS_TAG]->(t) +MATCH (t:Tag) +WHERE t.id IN $tagIds +CREATE (f)-[:HAS_TAG]->(t) diff --git a/queries/ldbc-snb-interactive/interactive-update-6.cypher b/queries/ldbc-snb-interactive/interactive-update-6.cypher index bbb088b10..558c6bdf7 100644 --- a/queries/ldbc-snb-interactive/interactive-update-6.cypher +++ b/queries/ldbc-snb-interactive/interactive-update-6.cypher @@ -2,6 +2,6 @@ MATCH (author:Person {id: $authorPersonId}), (country:Country {id: $countryId}), (forum:Forum {id: $forumId}) CREATE (author)<-[:HAS_CREATOR]-(p:Post:Message {id: $postId, creationDate: $creationDate, locationIP: $locationIP, browserUsed: $browserUsed, content: CASE $content WHEN '' THEN null ELSE $content END, imageFile: CASE $imageFile WHEN '' THEN null ELSE $imageFile END, length: $length})<-[:CONTAINER_OF]-(forum), (p)-[:IS_LOCATED_IN]->(country) WITH p -UNWIND $tagIds AS tagId - MATCH (t:Tag {id: tagId}) - CREATE (p)-[:HAS_TAG]->(t) +MATCH (t:Tag) +WHERE t.id IN $tagIds +CREATE (p)-[:HAS_TAG]->(t) diff --git a/queries/ldbc-snb-interactive/interactive-update-7.cypher b/queries/ldbc-snb-interactive/interactive-update-7.cypher index 3d03a782f..391a171cd 100644 --- a/queries/ldbc-snb-interactive/interactive-update-7.cypher +++ b/queries/ldbc-snb-interactive/interactive-update-7.cypher @@ -2,9 +2,9 @@ MATCH (author:Person {id: $authorPersonId}), (country:Country {id: $countryId}), - (message:Message {id: CASE $replyToPostId WHEN -1 THEN $replyToCommentId ELSE $replyToPostId END}) + (message:Message {id: $replyToPostId + $replyToCommentId + 1}) // $replyToCommentId is -1 if the message is a reply to a post and vica versa (see spec) CREATE (author)<-[:HAS_CREATOR]-(c:Comment:Message {id: $commentId, creationDate: $creationDate, locationIP: $locationIP, browserUsed: $browserUsed, content: $content, length: $length})-[:REPLY_OF]->(message), (c)-[:IS_LOCATED_IN]->(country) WITH c -UNWIND $tagIds AS tagId - MATCH (t:Tag {id: tagId}) - CREATE (c)-[:HAS_TAG]->(t) +MATCH (t:Tag) +WHERE t.id IN $tagIds +CREATE (c)-[:HAS_TAG]->(t)