Skip to content
This repository has been archived by the owner on Dec 1, 2022. It is now read-only.

Commit

Permalink
fix getNeighborIter (#859)
Browse files Browse the repository at this point in the history
* fix getNeighborIter

* add test case

* add noEdge_ indicate without Edge in getNeighborExecutor response

Co-authored-by: Yee <[email protected]>
  • Loading branch information
nevermore3 and yixinglu authored Mar 23, 2021
1 parent d96832d commit 3ebc305
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/context/Iterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ GetNeighborsIter::GetNeighborsIter(std::shared_ptr<Value> value)
void GetNeighborsIter::goToFirstEdge() {
// Go to first edge
for (currentDs_ = dsIndices_.begin(); currentDs_ < dsIndices_.end(); ++currentDs_) {
if (noEdge_) {
currentRow_ = currentDs_->ds->rows.begin();
valid_ = true;
break;
}
for (currentRow_ = currentDs_->ds->rows.begin();
currentRow_ < currentDs_->ds->rows.end(); ++currentRow_) {
colIdx_ = currentDs_->colLowerBound + 1;
Expand Down Expand Up @@ -126,7 +131,9 @@ StatusOr<int64_t> GetNeighborsIter::buildIndex(DataSetIndex* dsIndex) {
// It is "_vid", "_stats", "_expr" in this situation.
}
}

if (edgeStartIndex == -1) {
noEdge_ = true;
}
dsIndex->colLowerBound = edgeStartIndex - 1;
dsIndex->colUpperBound = colNames.size() - 1;
return edgeStartIndex;
Expand Down Expand Up @@ -181,6 +188,11 @@ void GetNeighborsIter::next() {
return;
}

if (noEdge_) {
currentRow_++;
return;
}

while (++edgeIdx_ > -1) {
if (edgeIdx_ < edgeIdxUpperBound_) {
const auto& currentEdge = currentCol_->operator[](edgeIdx_);
Expand Down
1 change: 1 addition & 0 deletions src/context/Iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ class GetNeighborsIter final : public Iterator {
int64_t colIdx_{-1};
const List* currentCol_{nullptr};

bool noEdge_{false};
int64_t edgeIdx_{-1};
int64_t edgeIdxUpperBound_{-1};
const List* currentEdge_{nullptr};
Expand Down
15 changes: 15 additions & 0 deletions tests/tck/features/go/GO.IntVid.feature
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ Feature: IntegerVid Go Sentence
Then the result should be, in any order, with relax comparison, and the columns 0 should be hashed:
| serve._dst |
| "Spurs" |
When executing query:
"""
GO FROM hash("Tim Duncan") OVER like YIELD $^.player.name as name, $^.player.age as age
"""
Then the result should be, in any order, with relax comparison:
| name | age |
| "Tim Duncan" | 42 |
When executing query:
"""
GO FROM hash("Tim Duncan"), hash("Tony Parker") OVER like YIELD $^.player.name as name, $^.player.age as age
"""
Then the result should be, in any order, with relax comparison:
| name | age |
| "Tim Duncan" | 42 |
| "Tony Parker" | 36 |
When executing query:
"""
GO FROM hash("Tim Duncan"), hash("Tim Duncan") OVER serve
Expand Down
15 changes: 15 additions & 0 deletions tests/tck/features/go/GO.feature
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ Feature: Go Sentence
Then the result should be, in any order, with relax comparison:
| serve._dst |
| "Spurs" |
When executing query:
"""
GO FROM "Tim Duncan" OVER like YIELD $^.player.name as name, $^.player.age as age
"""
Then the result should be, in any order, with relax comparison:
| name | age |
| "Tim Duncan" | 42 |
When executing query:
"""
GO FROM "Tim Duncan", "Tony Parker" OVER like YIELD $^.player.name as name, $^.player.age as age
"""
Then the result should be, in any order, with relax comparison:
| name | age |
| "Tim Duncan" | 42 |
| "Tony Parker" | 36 |
When executing query:
"""
GO FROM "Tim Duncan", "Tim Duncan" OVER serve
Expand Down

0 comments on commit 3ebc305

Please sign in to comment.