Skip to content

Commit

Permalink
add more test case
Browse files Browse the repository at this point in the history
  • Loading branch information
nevermore3 committed Jan 16, 2023
1 parent ff61d29 commit fac07c2
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 27 deletions.
48 changes: 33 additions & 15 deletions src/graph/executor/Executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,9 @@ std::size_t hash<nebula::graph::ListWrapper>::operator()(
if (pair.second) {
seed ^= std::hash<nebula::Value>()(pair.first);
} else {
if (!pair.first.isList()) {
return std::hash<nebula::Value>()(pair.first);
}
const auto &values = pair.first.getList().values;
for (const auto &v : values) {
seed ^= std::hash<nebula::Value>()(v);
Expand Down Expand Up @@ -804,26 +807,41 @@ bool equal_to<nebula::graph::ListWrapper>::operator()(
continue;
}
}
const auto &values = pairs[i].first.getList().values;
const auto &otherValues = otherPairs[i].first.getList().values;
size_t listSize = values.size();
if (listSize != otherValues.size()) {
return false;
}
if (values.front() == otherValues.front()) {
for (size_t j = 1; j < listSize; ++j) {
if (values[j] != otherValues[j]) {
if (!pairs[i].first.isList()) {
if (!otherPairs[i].first.isList()) {
if (pairs[i].first != otherPairs[i].first) {
return false;
} else {
continue;
}
} else {
return false;
}
} else if (values.front() == otherValues.back()) {
for (size_t j = 1; j < listSize; ++j) {
if (values[j] != otherValues[listSize - 1 - j]) {
return false;
} else {
if (!otherPairs[i].first.isList()) {
return false;
}
const auto &values = pairs[i].first.getList().values;
const auto &otherValues = otherPairs[i].first.getList().values;
size_t listSize = values.size();
if (listSize != otherValues.size()) {
return false;
}
if (values.front() == otherValues.front()) {
for (size_t j = 1; j < listSize; ++j) {
if (values[j] != otherValues[j]) {
return false;
}
}
} else if (values.front() == otherValues.back()) {
for (size_t j = 1; j < listSize; ++j) {
if (values[j] != otherValues[listSize - 1 - j]) {
return false;
}
}
} else {
return false;
}
} else {
return false;
}
}
return true;
Expand Down
58 changes: 46 additions & 12 deletions tests/tck/features/match/PathExpr.feature
Original file line number Diff line number Diff line change
Expand Up @@ -421,12 +421,12 @@ Feature: Basic match
RETURN p
"""
Then the result should be, in any order:
| p |
| [] |
| [] |
| [] |
| [] |
| [] |
| p |
| [<("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"})-[:like@0 {likeness: 95}]->("Tony Parker" :player{age: 36, name: "Tony Parker"})-[:like@0 {likeness: 90}]->("LaMarcus Aldridge" :player{age: 33, name: "LaMarcus Aldridge"})-[:like@0 {likeness: 75}]->("Tony Parker" :player{age: 36, name: "Tony Parker"})>] |
| [] |
| [] |
| [] |
| [] |
When executing query:
"""
MATCH (v:player)-[e:like*3]->(n)
Expand All @@ -448,14 +448,14 @@ Feature: Basic match
Then the result should be, in any order:
| v |

Scenario: different edge type in two pattern when apply join
Scenario: different edge direction in two pattern when apply join
When executing query:
"""
MATCH (v:player{name: 'Tim Duncan'})-[e:like*2]->(n)
RETURN ()-[e:like*2]->(n)
"""
Then the result should be, in any order:
| ()-[e:like*2]->(n) = ()-[e:like*2]->(n) |
| ()-[e:like*2]->(n) |
| [<("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"})<-[:like@0 {likeness: 90}]-("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"})<-[:like@0 {likeness: 95}]-("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"})>] |
| [<("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"})-[:like@0 {likeness: 95}]->("Tony Parker" :player{age: 36, name: "Tony Parker"})-[:like@0 {likeness: 90}]->("LaMarcus Aldridge" :player{age: 33, name: "LaMarcus Aldridge"})>] |
| [<("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"})-[:like@0 {likeness: 95}]->("Tony Parker" :player{age: 36, name: "Tony Parker"})-[:like@0 {likeness: 95}]->("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"})>] |
Expand All @@ -466,7 +466,7 @@ Feature: Basic match
RETURN ()-[e:like]->(n)
"""
Then the result should be, in any order:
| ()-[e:like]->(n) = ()-[e:like]->(n) |
| ()-[e:like]->(n) |
| [<("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"})-[:like@0 {likeness: 95}]->("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"})>] |
| [<("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"})-[:like@0 {likeness: 95}]->("Tony Parker" :player{age: 36, name: "Tony Parker"})>] |
When executing query:
Expand All @@ -475,6 +475,40 @@ Feature: Basic match
RETURN ()-[e:like*1..2]->(n)
"""
Then the result should be, in any order:
| ()-[e:like*1..2]->(n) = ()-[e:like*1..2]->(n) |
| [<("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"})-[:like@0 {likeness: 95}]->("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"})>] |
| [<("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"})-[:like@0 {likeness: 95}]->("Tony Parker" :player{age: 36, name: "Tony Parker"})>] |
| ()-[e:like*1..2]->(n) |
| [<("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"})-[:like@0 {likeness: 95}]->("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"})>] |
| [<("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"})-[:like@0 {likeness: 95}]->("Tony Parker" :player{age: 36, name: "Tony Parker"})>] |
| [<("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"})<-[:like@0 {likeness: 90}]-("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"})<-[:like@0 {likeness: 95}]-("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"})>] |
| [<("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"})-[:like@0 {likeness: 95}]->("Tony Parker" :player{age: 36, name: "Tony Parker"})-[:like@0 {likeness: 90}]->("LaMarcus Aldridge" :player{age: 33, name: "LaMarcus Aldridge"})>] |
| [<("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"})-[:like@0 {likeness: 95}]->("Tony Parker" :player{age: 36, name: "Tony Parker"})-[:like@0 {likeness: 95}]->("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"})>] |
| [<("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"})<-[:like@0 {likeness: 95}]-("Tony Parker" :player{age: 36, name: "Tony Parker"})<-[:like@0 {likeness: 95}]-("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"})>] |
When executing query:
"""
MATCH (v:player{name: 'Tim Duncan'})-[e:like]-(n)
RETURN ()-[e:like]-(n)
"""
Then the result should be, in any order:
| ()-[e:like]-(n) |
| [<("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"})<-[:like@0 {likeness: 80}]-("Aron Baynes" :player{age: 32, name: "Aron Baynes"})>] |
| [<("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"})<-[:like@0 {likeness: 80}]-("Boris Diaw" :player{age: 36, name: "Boris Diaw"})>] |
| [<("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"})<-[:like@0 {likeness: 70}]-("Danny Green" :player{age: 31, name: "Danny Green"})>] |
| [<("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"})<-[:like@0 {likeness: 99}]-("Dejounte Murray" :player{age: 29, name: "Dejounte Murray"})>] |
| [<("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"})<-[:like@0 {likeness: 75}]-("LaMarcus Aldridge" :player{age: 33, name: "LaMarcus Aldridge"})>] |
| [<("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"})<-[:like@0 {likeness: 90}]-("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"})>] |
| [<("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"})<-[:like@0 {likeness: 55}]-("Marco Belinelli" :player{age: 32, name: "Marco Belinelli"})>] |
| [<("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"})<-[:like@0 {likeness: 80}]-("Shaquille O'Neal" :player{age: 47, name: "Shaquille O'Neal"})>] |
| [<("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"})<-[:like@0 {likeness: 80}]-("Tiago Splitter" :player{age: 34, name: "Tiago Splitter"})>] |
| [<("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"})<-[:like@0 {likeness: 95}]-("Tony Parker" :player{age: 36, name: "Tony Parker"})>] |
| [<("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"})-[:like@0 {likeness: 95}]->("Manu Ginobili" :player{age: 41, name: "Manu Ginobili"})>] |
| [<("Tim Duncan" :player{age: 42, name: "Tim Duncan"} :bachelor{name: "Tim Duncan", speciality: "psychology"})-[:like@0 {likeness: 95}]->("Tony Parker" :player{age: 36, name: "Tony Parker"})>] |
When executing query:
"""
MATCH (v:player{name: 'Tim Duncan'})-[e:like*2]->(n)
RETURN ()-[e:like*3]->(n)
"""
Then the result should be, in any order:
| ()-[e:like]-(n) |
| [] |
| [] |
| [] |
| [] |

0 comments on commit fac07c2

Please sign in to comment.