-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
546 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// Copyright (c) 2020 vesoft inc. All rights reserved. | ||
// | ||
// This source code is licensed under Apache 2.0 License. | ||
|
||
#include "graph/executor/query/GetDstBySrcExecutor.h" | ||
|
||
#include "graph/service/GraphFlags.h" | ||
|
||
using nebula::storage::StorageClient; | ||
using nebula::storage::StorageRpcResponse; | ||
using nebula::storage::cpp2::GetDstBySrcResponse; | ||
|
||
namespace nebula { | ||
namespace graph { | ||
|
||
StatusOr<List> GetDstBySrcExecutor::buildRequestList() { | ||
SCOPED_TIMER(&execTime_); | ||
auto inputVar = gd_->inputVar(); | ||
auto iter = ectx_->getResult(inputVar).iter(); | ||
return buildRequestListByVidType(iter.get(), gd_->src(), gd_->dedup()); | ||
} | ||
|
||
folly::Future<Status> GetDstBySrcExecutor::execute() { | ||
auto res = buildRequestList(); | ||
NG_RETURN_IF_ERROR(res); | ||
auto reqList = std::move(res).value(); | ||
if (reqList.empty()) { | ||
DataSet emptyResult; | ||
return finish(ResultBuilder() | ||
.value(Value(std::move(emptyResult))) | ||
.iter(Iterator::Kind::kSequential) | ||
.build()); | ||
} | ||
|
||
time::Duration getDstTime; | ||
StorageClient* storageClient = qctx_->getStorageClient(); | ||
QueryExpressionContext qec(qctx()->ectx()); | ||
StorageClient::CommonRequestParam param(gd_->space(), | ||
qctx()->rctx()->session()->id(), | ||
qctx()->plan()->id(), | ||
qctx()->plan()->isProfileEnabled()); | ||
return storageClient->getDstBySrc(param, std::move(reqList), gd_->edgeTypes()) | ||
.via(runner()) | ||
.ensure([this, getDstTime]() { | ||
SCOPED_TIMER(&execTime_); | ||
otherStats_.emplace("total_rpc_time", folly::sformat("{}(us)", getDstTime.elapsedInUSec())); | ||
}) | ||
.thenValue([this](StorageRpcResponse<GetDstBySrcResponse>&& resp) { | ||
SCOPED_TIMER(&execTime_); | ||
auto& hostLatency = resp.hostLatency(); | ||
for (size_t i = 0; i < hostLatency.size(); ++i) { | ||
size_t size = 0u; | ||
auto& result = resp.responses()[i]; | ||
if (result.dsts_ref().has_value()) { | ||
size = (*result.dsts_ref()).size(); | ||
} | ||
auto& info = hostLatency[i]; | ||
otherStats_.emplace( | ||
folly::sformat("{} exec/total/vertices", std::get<0>(info).toString()), | ||
folly::sformat("{}(us)/{}(us)/{},", std::get<1>(info), std::get<2>(info), size)); | ||
auto detail = getStorageDetail(result.result.latency_detail_us_ref()); | ||
if (!detail.empty()) { | ||
otherStats_.emplace("storage_detail", detail); | ||
} | ||
} | ||
return handleResponse(resp, this->gd_->colNames()); | ||
}); | ||
} | ||
|
||
Status GetDstBySrcExecutor::handleResponse(RpcResponse& resps, | ||
const std::vector<std::string>& colNames) { | ||
auto result = handleCompleteness(resps, FLAGS_accept_partial_success); | ||
NG_RETURN_IF_ERROR(result); | ||
ResultBuilder builder; | ||
builder.state(result.value()); | ||
|
||
auto& responses = resps.responses(); | ||
DataSet ds; | ||
for (auto& resp : responses) { | ||
auto* dataset = resp.get_dsts(); | ||
if (dataset == nullptr) { | ||
continue; | ||
} | ||
dataset->colNames = colNames; | ||
ds.append(std::move(*dataset)); | ||
} | ||
builder.value(Value(std::move(ds))).iter(Iterator::Kind::kSequential); | ||
return finish(builder.build()); | ||
} | ||
|
||
} // namespace graph | ||
} // namespace nebula |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (c) 2020 vesoft inc. All rights reserved. | ||
// | ||
// This source code is licensed under Apache 2.0 License. | ||
|
||
#ifndef GRAPH_EXECUTOR_QUERY_GETDSTBYSRCEXECUTOR_H_ | ||
#define GRAPH_EXECUTOR_QUERY_GETDSTBYSRCEXECUTOR_H_ | ||
|
||
#include "graph/executor/StorageAccessExecutor.h" | ||
#include "graph/planner/plan/Query.h" | ||
|
||
// get the dst id of the src id | ||
namespace nebula { | ||
namespace graph { | ||
class GetDstBySrcExecutor final : public StorageAccessExecutor { | ||
public: | ||
GetDstBySrcExecutor(const PlanNode* node, QueryContext* qctx) | ||
: StorageAccessExecutor("GetDstBySrcExecutor", node, qctx) { | ||
gd_ = asNode<GetDstBySrc>(node); | ||
} | ||
|
||
folly::Future<Status> execute() override; | ||
|
||
StatusOr<List> buildRequestList(); | ||
|
||
private: | ||
using RpcResponse = storage::StorageRpcResponse<storage::cpp2::GetDstBySrcResponse>; | ||
Status handleResponse(RpcResponse& resps, const std::vector<std::string>& colNames); | ||
|
||
private: | ||
const GetDstBySrc* gd_; | ||
}; | ||
|
||
} // namespace graph | ||
} // namespace nebula | ||
|
||
#endif // GRAPH_EXECUTOR_QUERY_GETDSTBYSRCEXECUTOR_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.