Skip to content

Commit

Permalink
check if vertex valid by tag prefix scan
Browse files Browse the repository at this point in the history
  • Loading branch information
critical27 committed Sep 20, 2022
1 parent 8d2b013 commit 60bed04
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 43 deletions.
13 changes: 11 additions & 2 deletions src/storage/exec/GetPropNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class GetTagPropNode : public QueryNode<VertexID> {
if (!std::any_of(tagNodes_.begin(), tagNodes_.end(), [](const auto& tagNode) {
return tagNode->valid();
})) {
auto kvstore = context_->env()->kvstore_;
if (FLAGS_use_vertex_key) {
auto kvstore = context_->env()->kvstore_;
auto vertexKey = NebulaKeyUtils::vertexKey(context_->vIdLen(), partId, vId);
std::string value;
ret = kvstore->get(context_->spaceId(), partId, vertexKey, &value);
Expand All @@ -58,7 +58,16 @@ class GetTagPropNode : public QueryNode<VertexID> {
return ret;
}
} else {
return nebula::cpp2::ErrorCode::SUCCEEDED;
// check if vId has any valid tag by prefix scan
std::unique_ptr<kvstore::KVIterator> iter;
auto tagPrefix = NebulaKeyUtils::tagPrefix(context_->vIdLen(), partId, vId);
ret = context_->env()->kvstore_->prefix(context_->spaceId(), partId, tagPrefix, &iter);
if (ret != nebula::cpp2::ErrorCode::SUCCEEDED) {
return ret;
} else if (!iter->valid()) {
return nebula::cpp2::ErrorCode::SUCCEEDED;
}
// if has any tag, will emplace a row with vId
}
}

Expand Down
2 changes: 2 additions & 0 deletions tests/tck/features/delete/DeleteTag.IntVid.feature
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Feature: Delete int vid of tag
"""
Then the result should be, in any order:
| player.name | player.age |
| EMPTY | EMPTY |
When executing query:
"""
FETCH PROP ON bachelor hash("Tim Duncan") YIELD bachelor.name, bachelor.speciality
Expand Down Expand Up @@ -205,6 +206,7 @@ Feature: Delete int vid of tag
"""
Then the result should be, in any order:
| player.name | player.age |
| EMPTY | EMPTY |
When executing query:
"""
FETCH PROP ON player hash("Tony Parker") YIELD player.name, player.age
Expand Down
2 changes: 2 additions & 0 deletions tests/tck/features/delete/DeleteTag.feature
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Feature: Delete string vid of tag
"""
Then the result should be, in any order:
| player.name | player.age |
| EMPTY | EMPTY |
When executing query:
"""
FETCH PROP ON bachelor "Tim Duncan" YIELD bachelor.name, bachelor.speciality
Expand Down Expand Up @@ -205,6 +206,7 @@ Feature: Delete string vid of tag
"""
Then the result should be, in any order:
| player.name | player.age |
| EMPTY | EMPTY |
When executing query:
"""
FETCH PROP ON player "Tony Parker" YIELD player.name, player.age
Expand Down
24 changes: 12 additions & 12 deletions tests/tck/features/go/GO.IntVid.feature
Original file line number Diff line number Diff line change
Expand Up @@ -1383,14 +1383,14 @@ Feature: IntegerVid Go Sentence
"""
Then the result should be, in any order, with relax comparison, and the columns 0,1 should be hashed:
| serve._dst | like._dst | serve.start_year | like.likeness | $$.player.name |
| "Thunders" | EMPTY | 2008 | EMPTY | NULL |
| "Thunders" | EMPTY | 2008 | EMPTY | EMPTY |
| EMPTY | "Paul George" | EMPTY | 90 | "Paul George" |
| EMPTY | "James Harden" | EMPTY | 90 | "James Harden" |
| "Pacers" | EMPTY | 2010 | EMPTY | NULL |
| "Thunders" | EMPTY | 2017 | EMPTY | NULL |
| "Pacers" | EMPTY | 2010 | EMPTY | EMPTY |
| "Thunders" | EMPTY | 2017 | EMPTY | EMPTY |
| EMPTY | "Russell Westbrook" | EMPTY | 95 | "Russell Westbrook" |
| "Thunders" | EMPTY | 2009 | EMPTY | NULL |
| "Rockets" | EMPTY | 2012 | EMPTY | NULL |
| "Thunders" | EMPTY | 2009 | EMPTY | EMPTY |
| "Rockets" | EMPTY | 2012 | EMPTY | EMPTY |
| EMPTY | "Russell Westbrook" | EMPTY | 80 | "Russell Westbrook" |
When executing query:
"""
Expand All @@ -1399,14 +1399,14 @@ Feature: IntegerVid Go Sentence
"""
Then the result should be, in any order, with relax comparison, and the columns 0,1 should be hashed:
| serve._dst | like._dst | serve.start_year | like.likeness | $$.player.name |
| "Thunders" | EMPTY | 2008 | EMPTY | NULL |
| "Thunders" | EMPTY | 2008 | EMPTY | EMPTY |
| EMPTY | "Paul George" | EMPTY | 90 | "Paul George" |
| EMPTY | "James Harden" | EMPTY | 90 | "James Harden" |
| "Pacers" | EMPTY | 2010 | EMPTY | NULL |
| "Thunders" | EMPTY | 2017 | EMPTY | NULL |
| "Pacers" | EMPTY | 2010 | EMPTY | EMPTY |
| "Thunders" | EMPTY | 2017 | EMPTY | EMPTY |
| EMPTY | "Russell Westbrook" | EMPTY | 95 | "Russell Westbrook" |
| "Thunders" | EMPTY | 2009 | EMPTY | NULL |
| "Rockets" | EMPTY | 2012 | EMPTY | NULL |
| "Thunders" | EMPTY | 2009 | EMPTY | EMPTY |
| "Rockets" | EMPTY | 2012 | EMPTY | EMPTY |
| EMPTY | "Russell Westbrook" | EMPTY | 80 | "Russell Westbrook" |
When executing query:
"""
Expand Down Expand Up @@ -1480,8 +1480,8 @@ Feature: IntegerVid Go Sentence
GO FROM hash('Tim Duncan') OVER serve YIELD $$.player.name as name
"""
Then the result should be, in any order, with relax comparison:
| name |
| NULL |
| name |
| EMPTY |

Scenario: Integer Vid zero step
When executing query:
Expand Down
34 changes: 17 additions & 17 deletions tests/tck/features/go/GO.feature
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,6 @@ Feature: Go Sentence
| like._dst |
| "Kobe Bryant" |
| "Marc Gasol" |
| EMPTY |
| EMPTY |
| EMPTY |
| EMPTY |
| EMPTY |
When executing query:
"""
GO FROM "Paul Gasol" OVER *
Expand All @@ -359,6 +354,11 @@ Feature: Go Sentence
"""
Then the result should be, in any order, with relax comparison:
| like._dst |
| EMPTY |
| EMPTY |
| EMPTY |
| EMPTY |
| EMPTY |
When executing query:
"""
GO FROM "Manu Ginobili" OVER * REVERSELY YIELD like.likeness, teammate.start_year, serve.start_year, $$.player.name
Expand Down Expand Up @@ -1467,14 +1467,14 @@ Feature: Go Sentence
"""
Then the result should be, in any order, with relax comparison:
| serve._dst | like._dst | serve.start_year | like.likeness | $$.player.name |
| "Thunders" | EMPTY | 2008 | EMPTY | NULL |
| "Thunders" | EMPTY | 2008 | EMPTY | EMPTY |
| EMPTY | "Paul George" | EMPTY | 90 | "Paul George" |
| EMPTY | "James Harden" | EMPTY | 90 | "James Harden" |
| "Pacers" | EMPTY | 2010 | EMPTY | NULL |
| "Thunders" | EMPTY | 2017 | EMPTY | NULL |
| "Pacers" | EMPTY | 2010 | EMPTY | EMPTY |
| "Thunders" | EMPTY | 2017 | EMPTY | EMPTY |
| EMPTY | "Russell Westbrook" | EMPTY | 95 | "Russell Westbrook" |
| "Thunders" | EMPTY | 2009 | EMPTY | NULL |
| "Rockets" | EMPTY | 2012 | EMPTY | NULL |
| "Thunders" | EMPTY | 2009 | EMPTY | EMPTY |
| "Rockets" | EMPTY | 2012 | EMPTY | EMPTY |
| EMPTY | "Russell Westbrook" | EMPTY | 80 | "Russell Westbrook" |
When executing query:
"""
Expand All @@ -1483,14 +1483,14 @@ Feature: Go Sentence
"""
Then the result should be, in any order, with relax comparison:
| serve._dst | like._dst | serve.start_year | like.likeness | $$.player.name |
| "Thunders" | EMPTY | 2008 | EMPTY | NULL |
| "Thunders" | EMPTY | 2008 | EMPTY | EMPTY |
| EMPTY | "Paul George" | EMPTY | 90 | "Paul George" |
| EMPTY | "James Harden" | EMPTY | 90 | "James Harden" |
| "Pacers" | EMPTY | 2010 | EMPTY | NULL |
| "Thunders" | EMPTY | 2017 | EMPTY | NULL |
| "Pacers" | EMPTY | 2010 | EMPTY | EMPTY |
| "Thunders" | EMPTY | 2017 | EMPTY | EMPTY |
| EMPTY | "Russell Westbrook" | EMPTY | 95 | "Russell Westbrook" |
| "Thunders" | EMPTY | 2009 | EMPTY | NULL |
| "Rockets" | EMPTY | 2012 | EMPTY | NULL |
| "Thunders" | EMPTY | 2009 | EMPTY | EMPTY |
| "Rockets" | EMPTY | 2012 | EMPTY | EMPTY |
| EMPTY | "Russell Westbrook" | EMPTY | 80 | "Russell Westbrook" |
When executing query:
"""
Expand Down Expand Up @@ -1564,8 +1564,8 @@ Feature: Go Sentence
GO FROM 'Tim Duncan' OVER serve YIELD $$.player.name as name
"""
Then the result should be, in any order, with relax comparison:
| name |
| NULL |
| name |
| EMPTY |

Scenario: zero step
When executing query:
Expand Down
20 changes: 10 additions & 10 deletions tests/tck/features/go/GoYieldVertexEdge.feature
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,6 @@ Feature: Go Yield Vertex And Edge Sentence
| e |
| [:like "Paul Gasol"->"Kobe Bryant" @0 {likeness: 90}] |
| [:like "Paul Gasol"->"Marc Gasol" @0 {likeness: 99}] |
| [:serve "Paul Gasol"->"Bucks"@0{end_year:2020,start_year:2019}]|
| [:serve "Paul Gasol"->"Bulls"@0{end_year:2016,start_year:2014}]|
| [:serve "Paul Gasol"->"Grizzlies"@0{end_year:2008,start_year:2001}]|
| [:serve "Paul Gasol"->"Lakers"@0{end_year:2014,start_year:2008}]|
| [:serve "Paul Gasol"->"Spurs"@0{end_year:2019,start_year:2016}]|
When executing query:
"""
GO FROM "Paul Gasol" OVER *
Expand All @@ -365,6 +360,11 @@ Feature: Go Yield Vertex And Edge Sentence
"""
Then the result should be, in any order, with relax comparison:
| type |
| "serve" |
| "serve" |
| "serve" |
| "serve" |
| "serve" |
When executing query:
"""
GO FROM "Manu Ginobili" OVER * REVERSELY YIELD like.likeness, teammate.start_year, serve.start_year, $$.player.name, type(edge) as type
Expand Down Expand Up @@ -1383,13 +1383,13 @@ Feature: Go Yield Vertex And Edge Sentence
| dst | serve.start_year | like.likeness | $$.player.name |
| "James Harden" | EMPTY | 90 | "James Harden" |
| "Paul George" | EMPTY | 90 | "Paul George" |
| "Thunders" | 2008 | EMPTY | NULL |
| "Thunders" | 2008 | EMPTY | EMPTY |
| "Russell Westbrook" | EMPTY | 80 | "Russell Westbrook" |
| "Rockets" | 2012 | EMPTY | NULL |
| "Thunders" | 2009 | EMPTY | NULL |
| "Rockets" | 2012 | EMPTY | EMPTY |
| "Thunders" | 2009 | EMPTY | EMPTY |
| "Russell Westbrook" | EMPTY | 95 | "Russell Westbrook" |
| "Pacers" | 2010 | EMPTY | NULL |
| "Thunders" | 2017 | EMPTY | NULL |
| "Pacers" | 2010 | EMPTY | EMPTY |
| "Thunders" | 2017 | EMPTY | EMPTY |
When executing query:
"""
GO 1 TO 2 STEPS FROM 'Russell Westbrook' OVER * REVERSELY YIELD edge as e
Expand Down
2 changes: 1 addition & 1 deletion tests/tck/features/insert/insertVertexOnly.feature
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ Feature: insert vertex without tag
FETCH PROP ON * 1,2 yield vertex AS v;
"""
Then the result should be, in any order, with relax comparison:
| v |
| v |
Then drop the used space
1 change: 0 additions & 1 deletion tests/tck/features/match/Base.feature
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,6 @@ Feature: Basic match
"""
Then a SemanticError should be raised at runtime: Match clause is not supported to be followed by other cypher clauses

@wtf
Scenario: exists
When executing query:
"""
Expand Down
6 changes: 6 additions & 0 deletions tests/tck/features/ttl/TTL.feature
Original file line number Diff line number Diff line change
Expand Up @@ -394,30 +394,35 @@ Feature: TTLTest
"""
Then the result should be, in any order, with relax comparison:
| node |
| ("1") |
When executing query:
"""
FETCH PROP ON person "1" YIELD person.id as id
"""
Then the result should be, in any order:
| id |
| EMPTY |
When executing query:
"""
FETCH PROP ON * "1" YIELD person.id, career.id
"""
Then the result should be, in any order:
| person.id | career.id |
| EMPTY | EMPTY |
When executing query:
"""
FETCH PROP ON person "2" YIELD person.id
"""
Then the result should be, in any order:
| person.id |
| EMPTY |
When executing query:
"""
FETCH PROP ON person "2" YIELD person.id as id
"""
Then the result should be, in any order:
| id |
| EMPTY |
When executing query:
"""
FETCH PROP ON career "2" YIELD career.id;
Expand Down Expand Up @@ -487,4 +492,5 @@ Feature: TTLTest
"""
Then the result should be, in any order:
| age |
| EMPTY |
And drop the used space

0 comments on commit 60bed04

Please sign in to comment.