Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the promise/future in traverse executor. #3814

Merged
merged 3 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions src/graph/executor/query/TraverseExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,10 @@ folly::Future<Status> TraverseExecutor::traverse() {
DataSet emptyResult;
return finish(ResultBuilder().value(Value(std::move(emptyResult))).build());
}
getNeighbors();
return promise_.getFuture();
return getNeighbors();
}

void TraverseExecutor::getNeighbors() {
folly::Future<Status> TraverseExecutor::getNeighbors() {
currentStep_++;
time::Duration getNbrTime;
StorageClient* storageClient = qctx_->getStorageClient();
Expand All @@ -93,7 +92,7 @@ void TraverseExecutor::getNeighbors() {
qctx()->rctx()->session()->id(),
qctx()->plan()->id(),
qctx()->plan()->isProfileEnabled());
storageClient
return storageClient
->getNeighbors(param,
reqDs_.colNames,
std::move(reqDs_.rows),
Expand All @@ -112,7 +111,7 @@ void TraverseExecutor::getNeighbors() {
.thenValue([this, getNbrTime](StorageRpcResponse<GetNeighborsResponse>&& resp) mutable {
SCOPED_TIMER(&execTime_);
addStats(resp, getNbrTime.elapsedInUSec());
handleResponse(resp);
return handleResponse(std::move(resp));
});
}

Expand Down Expand Up @@ -140,11 +139,11 @@ void TraverseExecutor::addStats(RpcResponse& resp, int64_t getNbrTimeInUSec) {
otherStats_.emplace(folly::sformat("step {}", currentStep_), ss.str());
}

void TraverseExecutor::handleResponse(RpcResponse& resps) {
folly::Future<Status> TraverseExecutor::handleResponse(RpcResponse&& resps) {
SCOPED_TIMER(&execTime_);
auto result = handleCompleteness(resps, FLAGS_accept_partial_success);
if (!result.ok()) {
promise_.setValue(std::move(result).status());
return folly::makeFuture<Status>(std::move(result).status());
}

auto& responses = resps.responses();
Expand All @@ -162,21 +161,20 @@ void TraverseExecutor::handleResponse(RpcResponse& resps) {

auto status = buildInterimPath(iter.get());
if (!status.ok()) {
promise_.setValue(status);
return;
return folly::makeFuture<Status>(std::move(status));
}
if (!isFinalStep()) {
if (reqDs_.rows.empty()) {
if (range_ != nullptr) {
promise_.setValue(buildResult());
return folly::makeFuture<Status>(buildResult());
} else {
promise_.setValue(Status::OK());
return folly::makeFuture<Status>(Status::OK());
}
} else {
getNeighbors();
return getNeighbors();
}
} else {
promise_.setValue(buildResult());
return folly::makeFuture<Status>(buildResult());
}
}

Expand Down
5 changes: 2 additions & 3 deletions src/graph/executor/query/TraverseExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ class TraverseExecutor final : public StorageAccessExecutor {

void addStats(RpcResponse& resps, int64_t getNbrTimeInUSec);

void getNeighbors();
folly::Future<Status> getNeighbors();

void handleResponse(RpcResponse& resps);
folly::Future<Status> handleResponse(RpcResponse&& resps);

Status buildInterimPath(GetNeighborsIter* iter);

Expand Down Expand Up @@ -74,7 +74,6 @@ class TraverseExecutor final : public StorageAccessExecutor {
private:
DataSet reqDs_;
const Traverse* traverse_{nullptr};
folly::Promise<Status> promise_;
MatchStepRange* range_{nullptr};
size_t currentStep_{0};
std::list<std::unordered_map<Value, Paths>> paths_;
Expand Down