Skip to content

Commit

Permalink
fix match node label (#5165)
Browse files Browse the repository at this point in the history
* filter out initvid

* Update MatchNodeLabelFilter.feature

Co-authored-by: codesigner <[email protected]>
  • Loading branch information
nevermore3 and codesigner authored Dec 30, 2022
1 parent 51ff615 commit 9eca7a2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
36 changes: 13 additions & 23 deletions src/graph/executor/query/TraverseExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,30 +169,20 @@ folly::Future<Status> 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<Value, VertexHash, VertexEqual> 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<Value, VertexHash, VertexEqual> 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++;
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions tests/tck/features/bugfix/MatchNodeLabelFilter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

0 comments on commit 9eca7a2

Please sign in to comment.