Skip to content
This repository has been archived by the owner on Apr 4, 2021. It is now read-only.

Rewrote interactive update queries to omit UNWIND operations #387

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions queries/ldbc-snb-interactive/interactive-update-1.cypher
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 3 additions & 3 deletions queries/ldbc-snb-interactive/interactive-update-4.cypher
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 3 additions & 3 deletions queries/ldbc-snb-interactive/interactive-update-6.cypher
Original file line number Diff line number Diff line change
Expand Up @@ -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)
8 changes: 4 additions & 4 deletions queries/ldbc-snb-interactive/interactive-update-7.cypher
Original file line number Diff line number Diff line change
Expand Up @@ -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)