From 1ddebce95bf1c56058c419c9b0e8a8a85c02f771 Mon Sep 17 00:00:00 2001 From: Simon Liu <331435+monadbobo@users.noreply.github.com> Date: Mon, 9 Dec 2019 15:10:39 +0800 Subject: [PATCH] Issue #1364 Fixed crash caused when not specifying edge type (over *) and setting reversely. --- src/graph/GoExecutor.cpp | 4 +++ src/graph/test/GoTest.cpp | 50 +++++++++++++++++++++++++++ src/meta/processors/BaseProcessor.inl | 2 +- 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/src/graph/GoExecutor.cpp b/src/graph/GoExecutor.cpp index 7442ec9edc3..fb1afed50ef 100644 --- a/src/graph/GoExecutor.cpp +++ b/src/graph/GoExecutor.cpp @@ -221,6 +221,10 @@ Status GoExecutor::prepareOverAll() { } auto v = edgeStatus.value(); + if (isReversely()) { + v = -v; + } + edgeTypes_.push_back(v); if (!expCtx_->addEdge(e, v)) { diff --git a/src/graph/test/GoTest.cpp b/src/graph/test/GoTest.cpp index 2dbee267e98..cc78a1babda 100644 --- a/src/graph/test/GoTest.cpp +++ b/src/graph/test/GoTest.cpp @@ -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> 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 " @@ -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> expected = { + { "Marc Gasol" }, + { "Vince Carter" }, + { "Yao Ming" }, + { "Grant Hill" }, + }; + ASSERT_TRUE(verifyResult(resp, expected)); + } } @@ -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> 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. diff --git a/src/meta/processors/BaseProcessor.inl b/src/meta/processors/BaseProcessor.inl index ba708cc5e27..dace4fb5825 100644 --- a/src/meta/processors/BaseProcessor.inl +++ b/src/meta/processors/BaseProcessor.inl @@ -289,7 +289,7 @@ bool BaseProcessor::doSyncPut(std::vector 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 {