From 9eca7a2da582865c691d655cc883cc7bd830df88 Mon Sep 17 00:00:00 2001 From: jimingquan Date: Fri, 30 Dec 2022 16:32:19 +0800 Subject: [PATCH] fix match node label (#5165) * filter out initvid * Update MatchNodeLabelFilter.feature Co-authored-by: codesigner --- src/graph/executor/query/TraverseExecutor.cpp | 36 +++++++------------ .../bugfix/MatchNodeLabelFilter.feature | 9 +++++ 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/graph/executor/query/TraverseExecutor.cpp b/src/graph/executor/query/TraverseExecutor.cpp index d0753b348de..a92312761f2 100644 --- a/src/graph/executor/query/TraverseExecutor.cpp +++ b/src/graph/executor/query/TraverseExecutor.cpp @@ -169,30 +169,20 @@ folly::Future TraverseExecutor::handleResponse(RpcResponse&& resps) { // match (v)-[e:Rel]-(v1:Label1)-[e1*2]->() where id(v0) in [6, 23] return v1 // the attributes of v1 will be obtained in the second traverse operator // If the conditions are not met, the path in the previous step needs to be filtered out - if (!dst2PathsMap_.empty()) { - std::unordered_set existVids; - existVids.reserve(iter->numRows()); - auto vertices = iter->getVertices(); - for (auto& vertex : vertices.values) { - if (vertex.isVertex()) { - existVids.emplace(vertex); - } - } - auto dst2PathIter = dst2PathsMap_.begin(); - while (dst2PathIter != dst2PathsMap_.end()) { - if (existVids.find(dst2PathIter->first) == existVids.end()) { - dst2PathIter = dst2PathsMap_.erase(dst2PathIter); - } else { - dst2PathIter++; - } + std::unordered_set existVids; + existVids.reserve(iter->numRows()); + auto vertices = iter->getVertices(); + for (auto& vertex : vertices.values) { + if (vertex.isVertex()) { + existVids.emplace(vertex); } - auto initVidIter = initVids_.begin(); - while (initVidIter != initVids_.end()) { - if (existVids.find(*initVidIter) == existVids.end()) { - initVidIter = initVids_.erase(initVidIter); - } else { - initVidIter++; - } + } + auto initVidIter = initVids_.begin(); + while (initVidIter != initVids_.end()) { + if (existVids.find(*initVidIter) == existVids.end()) { + initVidIter = initVids_.erase(initVidIter); + } else { + initVidIter++; } } } diff --git a/tests/tck/features/bugfix/MatchNodeLabelFilter.feature b/tests/tck/features/bugfix/MatchNodeLabelFilter.feature index 96b8925c4f5..2071a20df75 100644 --- a/tests/tck/features/bugfix/MatchNodeLabelFilter.feature +++ b/tests/tck/features/bugfix/MatchNodeLabelFilter.feature @@ -51,3 +51,12 @@ Feature: match node label filter Then the result should be, in any order: | labels(v1) | count(*) | | ["bachelor", "player"] | 34 | + When executing query: + """ + MATCH (v:bachelor)<-[e*2..2]-()<-[e1]-() + WHERE id(v) in ['Tony Parker', 'Spurs', 'Tim Duncan'] + return labels(v), count(*) + """ + Then the result should be, in any order: + | labels(v) | count(*) | + | ["bachelor", "player"] | 184 |