Skip to content

Commit

Permalink
Workaround for vesoft-inc#2087, which lose the data when join with du…
Browse files Browse the repository at this point in the history
…plicate in… (vesoft-inc#2089)

* Workaround for vesoft-inc#2087, which lose the data when join with duplicate input(VID)

* Remove the useless comment.

* Add some cases.

* For variable input also.

Co-authored-by: dutor <440396+dutor@users.noreply.github.com>
  • Loading branch information
Shylock-Hg and dutor authored May 20, 2020
1 parent 3bf69da commit 56a9c3c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/graph/GoExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,14 @@ Status GoExecutor::setupStarts() {
return std::move(result).status();
}
starts_ = std::move(result).value();
std::unordered_set<VertexID> uni;
uni.reserve(starts_.size());
uni.insert(starts_.begin(), starts_.end());
if (starts_.size() == uni.size()) {
uniqueStart_ = true;
} else {
uniqueStart_ = false;
}

auto indexResult = inputs->buildIndex(*colname_);
if (!indexResult.ok()) {
Expand Down Expand Up @@ -1142,11 +1150,18 @@ bool GoExecutor::processFinalResult(RpcResponse &rpcResp, Callback cb) const {
return ret.value();
};
getters.getVariableProp = [&srcId,
this] (const std::string &prop) {
this] (const std::string &prop) -> OptVariantType {
if (!uniqueStart_) {
return Status::NotSupported(
"Not supported duplicate start from variable");
}
return getPropFromInterim(srcId, prop);
};
getters.getInputProp = [&srcId,
this] (const std::string &prop) {
this] (const std::string &prop) -> OptVariantType {
if (!uniqueStart_) {
return Status::NotSupported("Not supported duplicate start from input");
}
return getPropFromInterim(srcId, prop);
};

Expand Down
2 changes: 2 additions & 0 deletions src/graph/GoExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ class GoExecutor final : public TraverseExecutor {
std::unique_ptr<VertexHolder> vertexHolder_;
std::unique_ptr<VertexBackTracker> backTracker_;
std::unique_ptr<cpp2::ExecutionResponse> resp_;
// TODO(shylock) Join lose the data with duplicate input(VID) map
bool uniqueStart_{false}; // #2087 Workaround
// The name of Tag or Edge, index of prop in data
using SchemaPropIndex = std::unordered_map<std::pair<std::string, std::string>, int64_t>;
};
Expand Down
21 changes: 21 additions & 0 deletions src/graph/test/GoTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2369,6 +2369,27 @@ TEST_P(GoTest, Contains) {
}
}

TEST_P(GoTest, issue2087) {
// from input
{
cpp2::ExecutionResponse resp;
auto *fmt = "GO FROM %ld OVER like YIELD like._src as src, like._dst as dst "
"| GO FROM $-.src OVER like YIELD $-.src as src, like._dst as dst";
auto query = folly::stringPrintf(fmt, players_["Tim Duncan"].vid());
auto code = client_->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::E_EXECUTION_ERROR, code);
}
// from variable
{
cpp2::ExecutionResponse resp;
auto *fmt = "$a = GO FROM %ld OVER like YIELD like._src as src, like._dst as dst; "
"GO FROM $a.src OVER like YIELD $-.src as src, like._dst as dst";
auto query = folly::stringPrintf(fmt, players_["Tim Duncan"].vid());
auto code = client_->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::E_EXECUTION_ERROR, code);
}
}

TEST_P(GoTest, ZeroStep) {
// Zero step
{
Expand Down

0 comments on commit 56a9c3c

Please sign in to comment.