Skip to content

Commit

Permalink
Let the m to n steps return the data even if can't reach n steps. (ve…
Browse files Browse the repository at this point in the history
…soft-inc#2148)

* Let the m to n steps return the data even if can't reach n steps.

* Unify the go exit entry.

* Revert "Unify the go exit entry."

This reverts commit fbe28b7.

* Unify the go exit entry.

* Fix the edges reserve count.

* Add a cases for record a part data in go.

* Fix DAIL-91
  • Loading branch information
Shylock-Hg authored May 28, 2020
1 parent 6cba753 commit 2ba45b5
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 7 deletions.
20 changes: 14 additions & 6 deletions src/graph/GoExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -576,25 +576,33 @@ void GoExecutor::stepOut() {
std::move(future).via(runner).thenValue(cb).thenError(error);
}

#define GO_EXIT() do { \
if (!isRecord()) { \
onEmptyInputs(); \
return; \
} else { \
maybeFinishExecution(); \
return; \
} \
} while (0);

void GoExecutor::onStepOutResponse(RpcResponse &&rpcResp) {
joinResp(std::move(rpcResp));

if (isFinalStep()) {
maybeFinishExecution();
return;
GO_EXIT();
} else {
auto dsts = getDstIdsFromResps(records_.end() - 1, records_.end());
starts_ = std::move(dsts);
if (starts_.empty()) {
onEmptyInputs();
return;
GO_EXIT();
}
curStep_++;
stepOut();
}
}

#undef GO_EXIT

void GoExecutor::maybeFinishExecution() {
auto requireDstProps = expCtx_->hasDstTagProp();
Expand Down Expand Up @@ -695,8 +703,8 @@ void GoExecutor::finishExecution() {
StatusOr<std::vector<cpp2::RowValue>> GoExecutor::toThriftResponse() const {
std::vector<cpp2::RowValue> rows;
int64_t totalRows = 0;
for (const auto &rpcResp : records_) {
for (const auto& resp : rpcResp.responses()) {
for (auto rpcResp = records_.begin() + recordFrom_ - 1; rpcResp != records_.end(); ++rpcResp) {
for (const auto& resp : rpcResp->responses()) {
if (resp.get_total_edges() != nullptr) {
totalRows += *resp.get_total_edges();
}
Expand Down
53 changes: 52 additions & 1 deletion src/graph/test/GoTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2416,6 +2416,18 @@ TEST_P(GoTest, WithIntermediateData) {
auto code = client_->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);

std::vector<std::tuple<int64_t>> expected = {
teams_["Spurs"].vid()
};
ASSERT_TRUE(verifyResult(resp, expected));
}
{
cpp2::ExecutionResponse resp;
auto *fmt = "GO 2 TO 3 STEPS FROM %ld OVER serve";
auto query = folly::stringPrintf(fmt, players_["Tim Duncan"].vid());
auto code = client_->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);

std::vector<std::tuple<int64_t>> expected = {
};
ASSERT_TRUE(verifyResult(resp, expected));
Expand Down Expand Up @@ -2446,6 +2458,29 @@ TEST_P(GoTest, WithIntermediateData) {
};
ASSERT_TRUE(verifyResult(resp, expected));
}
{
cpp2::ExecutionResponse resp;
auto &player = players_["Tony Parker"];
auto *fmt = "GO 2 TO 2 STEPS FROM %ld OVER like REVERSELY YIELD DISTINCT like._dst";
auto query = folly::stringPrintf(fmt, player.vid());
auto code = client_->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);
std::vector<std::tuple<VertexID>> expected = {
{players_["LaMarcus Aldridge"].vid()},
{players_["Marco Belinelli"].vid()},
{players_["Boris Diaw"].vid()},
{players_["Dejounte Murray"].vid()},
{players_["Tony Parker"].vid()},
{players_["Manu Ginobili"].vid()},
{players_["Danny Green"].vid()},
{players_["Aron Baynes"].vid()},
{players_["Tiago Splitter"].vid()},
{players_["Shaquile O'Neal"].vid()},
{players_["Rudy Gay"].vid()},
{players_["Damian Lillard"].vid()},
};
ASSERT_TRUE(verifyResult(resp, expected));
}
// empty starts before last step
{
cpp2::ExecutionResponse resp;
Expand All @@ -2454,8 +2489,24 @@ TEST_P(GoTest, WithIntermediateData) {
auto code = client_->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);

// Empty response
std::vector<std::tuple<int64_t>> expected = {
players_["Tim Duncan"].vid(),
players_["Tony Parker"].vid(),
players_["Manu Ginobili"].vid(),
players_["LaMarcus Aldridge"].vid(),
players_["Rudy Gay"].vid(),
players_["Marco Belinelli"].vid(),
players_["Danny Green"].vid(),
players_["Kyle Anderson"].vid(),
players_["Aron Baynes"].vid(),
players_["Boris Diaw"].vid(),
players_["Tiago Splitter"].vid(),
players_["Cory Joseph"].vid(),
players_["David West"].vid(),
players_["Jonathon Simmons"].vid(),
players_["Dejounte Murray"].vid(),
players_["Tracy McGrady"].vid(),
players_["Paul Gasol"].vid(),
};
ASSERT_TRUE(verifyResult(resp, expected));
}
Expand Down

0 comments on commit 2ba45b5

Please sign in to comment.