Skip to content

Commit

Permalink
Issue vesoft-inc#1364 Fixed crash caused when not specifying edge typ…
Browse files Browse the repository at this point in the history
…e (over *) and setting reversely.
  • Loading branch information
monadbobo committed Dec 9, 2019
1 parent fa0cdf1 commit 1ddebce
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/graph/GoExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ Status GoExecutor::prepareOverAll() {
}

auto v = edgeStatus.value();
if (isReversely()) {
v = -v;
}

edgeTypes_.push_back(v);

if (!expCtx_->addEdge(e, v)) {
Expand Down
50 changes: 50 additions & 0 deletions src/graph/test/GoTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,25 @@ TEST_F(GoTest, ReverselyOneStep) {
};
ASSERT_TRUE(verifyResult(resp, expected));
}
{
cpp2::ExecutionResponse resp;
auto query = "GO FROM hash('Tim Duncan') OVER * REVERSELY "
"YIELD like._src";
client_->execute(query, resp);
std::vector<std::tuple<int64_t>> expected = {
{ players_["Tony Parker"].vid() },
{ players_["Manu Ginobili"].vid() },
{ players_["LaMarcus Aldridge"].vid() },
{ players_["Marco Belinelli"].vid() },
{ players_["Danny Green"].vid() },
{ players_["Aron Baynes"].vid() },
{ players_["Boris Diaw"].vid() },
{ players_["Tiago Splitter"].vid() },
{ players_["Dejounte Murray"].vid() },
{ players_["Shaquile O'Neal"].vid() },
};
ASSERT_TRUE(verifyResult(resp, expected));
}
{
cpp2::ExecutionResponse resp;
auto query = "GO FROM hash('Tim Duncan') OVER like REVERSELY "
Expand Down Expand Up @@ -969,6 +988,19 @@ TEST_F(GoTest, ReverselyTwoStep) {
};
ASSERT_TRUE(verifyResult(resp, expected));
}
{
cpp2::ExecutionResponse resp;
auto query = "GO 2 STEPS FROM hash('Kobe Bryant') OVER * REVERSELY "
"YIELD $$.player.name";
client_->execute(query, resp);
std::vector<std::tuple<std::string>> expected = {
{ "Marc Gasol" },
{ "Vince Carter" },
{ "Yao Ming" },
{ "Grant Hill" },
};
ASSERT_TRUE(verifyResult(resp, expected));
}
}


Expand Down Expand Up @@ -1047,6 +1079,24 @@ TEST_F(GoTest, ReverselyWithPipe) {

ASSERT_TRUE(verifyResult(resp, expected));
}
{
cpp2::ExecutionResponse resp;
auto query = "GO FROM hash('Manu Ginobili') OVER * REVERSELY "
"YIELD like._src AS id |"
"GO FROM $-.id OVER serve";
client_->execute(query, resp);
std::vector<std::tuple<int64_t>> expected = {
{ teams_["Spurs"].vid() },
{ teams_["Spurs"].vid() },
{ teams_["Hornets"].vid() },
{ teams_["Spurs"].vid() },
{ teams_["Hawks"].vid() },
{ teams_["76ers"].vid() },
{ teams_["Spurs"].vid() },
};

ASSERT_TRUE(verifyResult(resp, expected));
}
/**
* TODO(dutor)
* For the time being, reference to the pipe inputs is faulty.
Expand Down
2 changes: 1 addition & 1 deletion src/meta/processors/BaseProcessor.inl
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ bool BaseProcessor<RESP>::doSyncPut(std::vector<kvstore::KV> data) {
kvstore_->asyncMultiPut(kDefaultSpaceId,
kDefaultPartId,
std::move(data),
[this, &ret, &baton] (kvstore::ResultCode code) {
[&ret, &baton] (kvstore::ResultCode code) {
if (kvstore::ResultCode::SUCCEEDED == code) {
ret = true;
} else {
Expand Down

0 comments on commit 1ddebce

Please sign in to comment.