From f491b434593d82be19679013c456b5435dfa02ae Mon Sep 17 00:00:00 2001 From: jimingquan <6930445+nevermore3@users.noreply.github.com> Date: Thu, 10 Nov 2022 15:42:37 +0800 Subject: [PATCH] fix error --- nebula/queries/interactive-complex-1.ngql | 4 ++-- nebula/queries/interactive-complex-10.ngql | 2 +- nebula/queries/interactive-complex-12.ngql | 19 ++++++++++++------- nebula/queries/interactive-complex-5.ngql | 12 +++++++++++- nebula/queries/interactive-complex-7.ngql | 8 ++++++-- .../snb/impls/workloads/nebula/NebulaDb.java | 10 +++------- 6 files changed, 35 insertions(+), 20 deletions(-) diff --git a/nebula/queries/interactive-complex-1.ngql b/nebula/queries/interactive-complex-1.ngql index 203de6965..b61731e52 100644 --- a/nebula/queries/interactive-complex-1.ngql +++ b/nebula/queries/interactive-complex-1.ngql @@ -1,7 +1,7 @@ MATCH p=(person:Person)-[:KNOWS*1..3]-(friend:Person {firstName: $firstName}) WHERE id(person) == $personId AND id(friend) != $personId -WITH friend,toInteger(substr(id(friend), 2)) as friendId, min(length(p)) AS distance -ORDER BY distance ASC, friend.Person.lastName ASC, friendId ASC +WITH friend,toInteger(substr(id(friend), 2)) as friendId, min(length(p)) AS distance, friend.Person.lastName AS lastName +ORDER BY distance ASC, lastName ASC, friendId ASC LIMIT 20 MATCH (friend)-[:IS_LOCATED_IN]->(friendCity:Place) OPTIONAL MATCH (friend)-[studyAt:STUDY_AT]->(uni:Organisation)-[:IS_LOCATED_IN]->(uniCity:Place) diff --git a/nebula/queries/interactive-complex-10.ngql b/nebula/queries/interactive-complex-10.ngql index e0605b674..215f9c6e5 100644 --- a/nebula/queries/interactive-complex-10.ngql +++ b/nebula/queries/interactive-complex-10.ngql @@ -4,7 +4,7 @@ WITH person, city, friend, datetime({epochMillis: friend.Person.birthday}) as bi WHERE (birthday.month==$month AND birthday.day>=21) OR (birthday.month==($month%12)+1 AND birthday.day<22) WITH DISTINCT friend, city, person -OPTIONAL MATCH (friend)<-[:HAS_CREATOR]-(post:Post) +OPTIONAL MATCH (friend)<-[:POST_HAS_CREATOR]-(post:Post) WITH friend, city, collect(post) AS posts, person WITH friend, city, diff --git a/nebula/queries/interactive-complex-12.ngql b/nebula/queries/interactive-complex-12.ngql index 7b8e271b5..9f59e7fbf 100644 --- a/nebula/queries/interactive-complex-12.ngql +++ b/nebula/queries/interactive-complex-12.ngql @@ -1,10 +1,15 @@ -MATCH (n:Person)-[:KNOWS]-(friend:Person)<-[:COMMENT_HAS_CREATOR]-(`comment`:`Comment`)-[:REPLY_OF_POST]->(:Post)-[:HAS_TAG]->(`tag`:`Tag`)-[:HAS_TYPE]->(tagClass:Tagclass)-[:IS_SUBCLASS_OF*0..100]->(baseTagClass:Tagclass) - WHERE id(n) == $personId AND (tagClass.Tagclass.name == $tagClassName OR baseTagClass.Tagclass.name == $tagClassName) - RETURN +MATCH (tag1:`Tag`)-[:HAS_TYPE|IS_SUBCLASS_OF*0..6]->(baseTagClass:Tagclass) +WHERE tag1.`Tag`.name == $tagClassName OR baseTagClass.Tagclass.name == $tagClassName +WITH collect(id(tag1)) as T +MATCH (p:Person)-[:KNOWS]-(friend:Person)<-[:COMMENT_HAS_CREATOR]-(comment1:`Comment`)-[:REPLY_OF_POST]->(:Post)-[:HAS_TAG]->(tag2:`Tag`) +WHERE id(p) == $personId AND id(tag2) in T +RETURN toInteger(substr(id(friend),2)) AS personId, friend.Person.firstName AS personFirstName, friend.Person.lastName AS personLastName, - collect(DISTINCT `tag`.`Tag`.name) AS tagNames, - count(DISTINCT id(`comment`)) AS replyCount - ORDER BY replyCount DESC, personId ASC - LIMIT 20 \ No newline at end of file + collect(DISTINCT tag2.`Tag`.name) AS tagNames, + count(DISTINCT id(comment1)) AS replyCount +ORDER BY + replyCount DESC, + personId ASC +LIMIT 20 \ No newline at end of file diff --git a/nebula/queries/interactive-complex-5.ngql b/nebula/queries/interactive-complex-5.ngql index b16ad863f..8d4d70aba 100644 --- a/nebula/queries/interactive-complex-5.ngql +++ b/nebula/queries/interactive-complex-5.ngql @@ -1 +1,11 @@ -GO 1 TO 2 STEPS FROM $personId OVER KNOWS WHERE KNOWS._dst != $personId YIELD distinct KNOWS._dst AS friendId | GO FROM $-.friendId OVER HAS_MEMBER REVERSELY WHERE HAS_MEMBER.joinDate > $minDate YIELD distinct HAS_MEMBER._dst AS forumId, $-.friendId as friendId| GO FROM $-.forumId OVER CONTAINER_OF YIELD $-.friendId AS friendId, $^.Forum.title AS title, $-.forumId AS forumId, CONTAINER_OF._dst AS postId | GO FROM $-.postId OVER POST_HAS_CREATOR WHERE POST_HAS_CREATOR._dst == $-.friendId YIELD $-.forumId AS forumId, $-.title AS forumTitle, $-.postId AS postId | group by $-.forumId, $-.forumTitle YIELD toInteger(substr($-.forumId, 2)) AS forumId, $-.forumTitle AS forumTitle, count($-.postId) AS postCount | ORDER BY $-.postCount DESC, $-.forumId ASC | LIMIT 20 \ No newline at end of file +MATCH (person:Person)-[:KNOWS*1..2]-(friend:Person)<-[membership:HAS_MEMBER]-(forum:Forum) + WHERE id(person) == $personId AND id(friend) != $personId AND membership.joinDate > $minDate + WITH DISTINCT friend, forum + OPTIONAL MATCH (friend)<-[:POST_HAS_CREATOR]-(post:Post)<-[:CONTAINER_OF]-(forum) + WITH forum, count(post) AS postCount + RETURN + toInteger(substr(id(forum),2)) AS forumId, + forum.Forum.title AS forumTitle, + postCount + ORDER BY postCount DESC, forumId ASC + LIMIT 20 \ No newline at end of file diff --git a/nebula/queries/interactive-complex-7.ngql b/nebula/queries/interactive-complex-7.ngql index 1ce49467b..84dca5618 100644 --- a/nebula/queries/interactive-complex-7.ngql +++ b/nebula/queries/interactive-complex-7.ngql @@ -20,8 +20,12 @@ RETURN liker.Person.lastName AS personLastName, latestLike.likeTime AS likeCreationDate, id(latestLike.msg) AS messageId, - CASE WHEN tags(latestLike.msg) == ["Post"] THEN latestLike.msg.imageFile - ELSE latestLike.msg.content END AS messageContent, + CASE WHEN tags(latestLike.msg) == ["Post"] THEN + CASE WHEN size(latestLike.msg.imageFile) == 0 THEN latestLike.msg.content + ELSE latestLike.msg.imageFile + END + ELSE latestLike.msg.content + END AS messageContent, latestLike.msg.creationDate AS messageCreationDate, p IS NULL AS isNew ORDER BY diff --git a/nebula/src/main/java/org/ldbcouncil/snb/impls/workloads/nebula/NebulaDb.java b/nebula/src/main/java/org/ldbcouncil/snb/impls/workloads/nebula/NebulaDb.java index aacce4919..10b0b5a31 100644 --- a/nebula/src/main/java/org/ldbcouncil/snb/impls/workloads/nebula/NebulaDb.java +++ b/nebula/src/main/java/org/ldbcouncil/snb/impls/workloads/nebula/NebulaDb.java @@ -18,6 +18,7 @@ import java.net.UnknownHostException; import java.text.ParseException; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -89,16 +90,11 @@ public LdbcQuery1Result convertSingleResult(ResultSet.Record record) throws Unsu List emails = new ArrayList<>(); if (!record.get(8).isNull()) { - for (ValueWrapper email : record.get(8).asList()) { - emails.add(email.asString()); - } + Collections.addAll(emails, record.get(8).asString().split(",")); } - List languages = new ArrayList<>(); if (!record.get(9).isNull()) { - for (ValueWrapper lang : record.get(9).asList()) { - languages.add(lang.asString()); - } + Collections.addAll(languages, record.get(9).asString().split(",")); } List universities = new ArrayList<>();