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

Feature/view vertices edges #3320

Merged
merged 44 commits into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
c56d753
Scan multiple parts.
Shylock-Hg Nov 3, 2021
dd0790e
Add multiple parts test case.
Shylock-Hg Nov 3, 2021
f126d77
Add limit test.
Shylock-Hg Nov 3, 2021
1415928
Merge branch 'master' into feature/scan_multiple_parts
Shylock-Hg Nov 3, 2021
fa11ae5
Remove unused include.
Shylock-Hg Nov 3, 2021
0fe9754
Support multiple tags.
Shylock-Hg Nov 4, 2021
3266566
Merge branch 'master' into feature/scan_multiple_parts
Shylock-Hg Nov 4, 2021
f1cab23
Merge branch 'master' into feature/scan_multiple_parts
Shylock-Hg Nov 5, 2021
d8958de
Fix license header.
Shylock-Hg Nov 5, 2021
236e4f9
Optimize the extra read operations.
Shylock-Hg Nov 9, 2021
011813f
Merge branch 'master' into feature/scan_multiple_parts
Shylock-Hg Nov 9, 2021
57ba9c5
Fix compile error.
Shylock-Hg Nov 9, 2021
e502546
Skip invalid tag in one loop.
Shylock-Hg Nov 9, 2021
96b00e6
Avoid extra logical.
Shylock-Hg Nov 9, 2021
05e73aa
Merge branch 'master' into feature/scan_multiple_parts
Shylock-Hg Nov 9, 2021
9d08fe7
Merge branch 'master' of https://github.com/vesoft-inc/nebula into fe…
Shylock-Hg Nov 11, 2021
5b9bd4f
Add scan executors.
Shylock-Hg Nov 11, 2021
5f71938
Add scan entry of match.
Shylock-Hg Nov 16, 2021
9715a28
Merge branch 'master' into feature/view-vertices-edges
Shylock-Hg Nov 16, 2021
ed4af13
Format.
Shylock-Hg Nov 16, 2021
0a51b56
Merge branch 'feature/view-vertices-edges' of github.com:Shylock-Hg/n…
Shylock-Hg Nov 16, 2021
5596fb2
Merge branch 'master' of https://github.com/vesoft-inc/nebula into fe…
Shylock-Hg Nov 18, 2021
b097321
Push filter down to ScanVertices.
Shylock-Hg Nov 18, 2021
38d1dd7
Push filter over AppendVertices.
Shylock-Hg Nov 22, 2021
9d1872e
Merge branch 'master' of https://github.com/vesoft-inc/nebula into fe…
Shylock-Hg Nov 24, 2021
cf8f5ff
Remove unused code.
Shylock-Hg Nov 24, 2021
a990b86
Support push limit down to scan vertices.
Shylock-Hg Nov 25, 2021
ede4c10
Merge branch 'master' of https://github.com/vesoft-inc/nebula into fe…
Shylock-Hg Nov 25, 2021
95b1bba
Fix vfilter push down.
Shylock-Hg Nov 25, 2021
61cda54
Merge branch 'master' into feature/view-vertices-edges
Shylock-Hg Nov 26, 2021
845fb6b
Transforme traverse to get edges.
Shylock-Hg Nov 30, 2021
d6af76e
Merge branch 'feature/view-vertices-edges' of github.com:Shylock-Hg/n…
Shylock-Hg Nov 30, 2021
8953015
Push limit to scan edges.
Shylock-Hg Nov 30, 2021
88e81ed
Check limit for scan.
Shylock-Hg Nov 30, 2021
3bcd952
Revert test cases.
Shylock-Hg Nov 30, 2021
5da28e4
Merge branch 'master' of https://github.com/vesoft-inc/nebula into fe…
Shylock-Hg Nov 30, 2021
f4c5a59
Merge branch 'master' into feature/view-vertices-edges
Shylock-Hg Nov 30, 2021
f6ddcce
Merge branch 'master' into feature/view-vertices-edges
Shylock-Hg Dec 8, 2021
96c2099
Resolve conflict.
Shylock-Hg Dec 8, 2021
6d0296b
Merge branch 'master' into feature/view-vertices-edges
Shylock-Hg Dec 8, 2021
83b26cb
Remove redundant line.
Shylock-Hg Dec 8, 2021
e540715
Merge branch 'master' into feature/view-vertices-edges
CPWstatic Dec 9, 2021
eb6307b
Merge branch 'master' into feature/view-vertices-edges
Shylock-Hg Dec 9, 2021
3704609
Merge branch 'master' into feature/view-vertices-edges
Shylock-Hg Dec 9, 2021
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
10 changes: 5 additions & 5 deletions src/clients/storage/GraphStorageClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,15 +559,15 @@ StorageRpcRespFuture<cpp2::GetNeighborsResponse> GraphStorageClient::lookupAndTr
});
}

StorageRpcRespFuture<cpp2::ScanEdgeResponse> GraphStorageClient::scanEdge(
StorageRpcRespFuture<cpp2::ScanResponse> GraphStorageClient::scanEdge(
const CommonRequestParam& param,
const cpp2::EdgeProp& edgeProp,
const std::vector<cpp2::EdgeProp>& edgeProp,
int64_t limit,
const Expression* filter) {
std::unordered_map<HostAddr, cpp2::ScanEdgeRequest> requests;
auto status = getHostPartsWithCursor(param.space);
if (!status.ok()) {
return folly::makeFuture<StorageRpcResponse<cpp2::ScanEdgeResponse>>(
return folly::makeFuture<StorageRpcResponse<cpp2::ScanResponse>>(
std::runtime_error(status.status().toString()));
}
auto& clusters = status.value();
Expand All @@ -590,15 +590,15 @@ StorageRpcRespFuture<cpp2::ScanEdgeResponse> GraphStorageClient::scanEdge(
const cpp2::ScanEdgeRequest& r) { return client->future_scanEdge(r); });
}

StorageRpcRespFuture<cpp2::ScanVertexResponse> GraphStorageClient::scanVertex(
StorageRpcRespFuture<cpp2::ScanResponse> GraphStorageClient::scanVertex(
const CommonRequestParam& param,
const std::vector<cpp2::VertexProp>& vertexProp,
int64_t limit,
const Expression* filter) {
std::unordered_map<HostAddr, cpp2::ScanVertexRequest> requests;
auto status = getHostPartsWithCursor(param.space);
if (!status.ok()) {
return folly::makeFuture<StorageRpcResponse<cpp2::ScanVertexResponse>>(
return folly::makeFuture<StorageRpcResponse<cpp2::ScanResponse>>(
std::runtime_error(status.status().toString()));
}
auto& clusters = status.value();
Expand Down
10 changes: 5 additions & 5 deletions src/clients/storage/GraphStorageClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ class GraphStorageClient : public StorageClientBase<cpp2::GraphStorageServiceAsy
StorageRpcRespFuture<cpp2::GetNeighborsResponse> lookupAndTraverse(
const CommonRequestParam& param, cpp2::IndexSpec indexSpec, cpp2::TraverseSpec traverseSpec);

StorageRpcRespFuture<cpp2::ScanEdgeResponse> scanEdge(const CommonRequestParam& param,
const cpp2::EdgeProp& vertexProp,
int64_t limit,
const Expression* filter);
StorageRpcRespFuture<cpp2::ScanResponse> scanEdge(const CommonRequestParam& param,
const std::vector<cpp2::EdgeProp>& vertexProp,
int64_t limit,
const Expression* filter);

StorageRpcRespFuture<cpp2::ScanVertexResponse> scanVertex(
StorageRpcRespFuture<cpp2::ScanResponse> scanVertex(
const CommonRequestParam& param,
const std::vector<cpp2::VertexProp>& vertexProp,
int64_t limit,
Expand Down
12 changes: 12 additions & 0 deletions src/common/meta/SchemaManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,17 @@ StatusOr<std::pair<bool, int32_t>> SchemaManager::getSchemaIDByName(GraphSpaceID
return Status::Error("Schema not exist: %s", schemaName.str().c_str());
}

StatusOr<std::unordered_map<TagID, std::string>> SchemaManager::getAllTags(GraphSpaceID space) {
std::unordered_map<TagID, std::string> tags;
auto tagSchemas = getAllLatestVerTagSchema(space);
NG_RETURN_IF_ERROR(tagSchemas);
for (auto& tagSchema : tagSchemas.value()) {
auto tagName = toTagName(space, tagSchema.first);
NG_RETURN_IF_ERROR(tagName);
tags.emplace(tagSchema.first, tagName.value());
}
return tags;
}

} // namespace meta
} // namespace nebula
2 changes: 2 additions & 0 deletions src/common/meta/SchemaManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class SchemaManager {

virtual StatusOr<std::vector<std::string>> getAllEdge(GraphSpaceID space) = 0;

StatusOr<std::unordered_map<TagID, std::string>> getAllTags(GraphSpaceID space);

// get all version of all tag schema
virtual StatusOr<TagSchemas> getAllVerTagSchema(GraphSpaceID space) = 0;

Expand Down
2 changes: 2 additions & 0 deletions src/graph/context/ast/CypherAstContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ struct ScanInfo {
std::vector<IndexID> indexIds;
// use for seek by edge only
MatchEdge::Direction direction{MatchEdge::Direction::OUT_EDGE};
// use for scan seek
bool anyLabel{false};
};

struct CypherClauseContextBase : AstContext {
Expand Down
2 changes: 2 additions & 0 deletions src/graph/executor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ nebula_add_library(
query/InnerJoinExecutor.cpp
query/IndexScanExecutor.cpp
query/AssignExecutor.cpp
query/ScanVerticesExecutor.cpp
query/ScanEdgesExecutor.cpp
query/TraverseExecutor.cpp
query/AppendVerticesExecutor.cpp
algo/ConjunctPathExecutor.cpp
Expand Down
8 changes: 8 additions & 0 deletions src/graph/executor/Executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@
#include "graph/executor/query/MinusExecutor.h"
#include "graph/executor/query/ProjectExecutor.h"
#include "graph/executor/query/SampleExecutor.h"
#include "graph/executor/query/ScanEdgesExecutor.h"
#include "graph/executor/query/ScanVerticesExecutor.h"
#include "graph/executor/query/SortExecutor.h"
#include "graph/executor/query/TopNExecutor.h"
#include "graph/executor/query/TraverseExecutor.h"
Expand Down Expand Up @@ -170,6 +172,12 @@ Executor *Executor::makeExecutor(QueryContext *qctx, const PlanNode *node) {
case PlanNode::Kind::kGetVertices: {
return pool->add(new GetVerticesExecutor(node, qctx));
}
case PlanNode::Kind::kScanEdges: {
return pool->add(new ScanEdgesExecutor(node, qctx));
}
case PlanNode::Kind::kScanVertices: {
return pool->add(new ScanVerticesExecutor(node, qctx));
}
case PlanNode::Kind::kGetNeighbors: {
return pool->add(new GetNeighborsExecutor(node, qctx));
}
Expand Down
3 changes: 2 additions & 1 deletion src/graph/executor/query/GetPropExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class GetPropExecutor : public StorageAccessExecutor {
GetPropExecutor(const std::string &name, const PlanNode *node, QueryContext *qctx)
: StorageAccessExecutor(name, node, qctx) {}

Status handleResp(storage::StorageRpcResponse<storage::cpp2::GetPropResponse> &&rpcResp,
template <typename Response>
Status handleResp(storage::StorageRpcResponse<Response> &&rpcResp,
const std::vector<std::string> &colNames) {
auto result = handleCompleteness(rpcResp, FLAGS_accept_partial_success);
NG_RETURN_IF_ERROR(result);
Expand Down
47 changes: 47 additions & 0 deletions src/graph/executor/query/ScanEdgesExecutor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* Copyright (c) 2021 vesoft inc. All rights reserved.
*
* This source code is licensed under Apache 2.0 License.
*/

#include "graph/executor/query/ScanEdgesExecutor.h"

#include "common/time/ScopedTimer.h"
#include "graph/context/QueryContext.h"
#include "graph/planner/plan/Query.h"
#include "graph/util/SchemaUtil.h"

using nebula::storage::GraphStorageClient;
using nebula::storage::StorageRpcResponse;
using nebula::storage::cpp2::ScanResponse;

namespace nebula {
namespace graph {

folly::Future<Status> ScanEdgesExecutor::execute() { return scanEdges(); }

folly::Future<Status> ScanEdgesExecutor::scanEdges() {
SCOPED_TIMER(&execTime_);
GraphStorageClient *client = qctx()->getStorageClient();
auto *se = asNode<ScanEdges>(node());

time::Duration scanEdgesTime;
GraphStorageClient::CommonRequestParam param(se->space(),
qctx()->rctx()->session()->id(),
qctx()->plan()->id(),
qctx()->plan()->isProfileEnabled());
return DCHECK_NOTNULL(client)
->scanEdge(param, *DCHECK_NOTNULL(se->props()), se->limit(), se->filter())
.via(runner())
.ensure([this, scanEdgesTime]() {
SCOPED_TIMER(&execTime_);
otherStats_.emplace("total_rpc", folly::sformat("{}(us)", scanEdgesTime.elapsedInUSec()));
})
.thenValue([this, se](StorageRpcResponse<ScanResponse> &&rpcResp) {
SCOPED_TIMER(&execTime_);
addStats(rpcResp, otherStats_);
return handleResp(std::move(rpcResp), se->colNames());
});
}

} // namespace graph
} // namespace nebula
22 changes: 22 additions & 0 deletions src/graph/executor/query/ScanEdgesExecutor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* Copyright (c) 2021 vesoft inc. All rights reserved.
*
* This source code is licensed under Apache 2.0 License.
*/

#include "graph/executor/query/GetPropExecutor.h"

namespace nebula {
namespace graph {
class ScanEdgesExecutor final : public GetPropExecutor {
public:
ScanEdgesExecutor(const PlanNode *node, QueryContext *qctx)
: GetPropExecutor("ScanEdgesExecutor", node, qctx) {}

folly::Future<Status> execute() override;

private:
folly::Future<Status> scanEdges();
};

} // namespace graph
} // namespace nebula
47 changes: 47 additions & 0 deletions src/graph/executor/query/ScanVerticesExecutor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* Copyright (c) 2021 vesoft inc. All rights reserved.
*
* This source code is licensed under Apache 2.0 License.
*/

#include "graph/executor/query/ScanVerticesExecutor.h"

#include "common/time/ScopedTimer.h"
#include "graph/context/QueryContext.h"
#include "graph/util/SchemaUtil.h"

using nebula::storage::GraphStorageClient;
using nebula::storage::StorageRpcResponse;
using nebula::storage::cpp2::ScanResponse;

namespace nebula {
namespace graph {

folly::Future<Status> ScanVerticesExecutor::execute() { return scanVertices(); }

folly::Future<Status> ScanVerticesExecutor::scanVertices() {
SCOPED_TIMER(&execTime_);

auto *sv = asNode<ScanVertices>(node());
GraphStorageClient *storageClient = qctx()->getStorageClient();

time::Duration scanVertexTime;
GraphStorageClient::CommonRequestParam param(sv->space(),
qctx()->rctx()->session()->id(),
qctx()->plan()->id(),
qctx()->plan()->isProfileEnabled());
return DCHECK_NOTNULL(storageClient)
->scanVertex(param, *DCHECK_NOTNULL(sv->props()), sv->limit(), sv->filter())
.via(runner())
.ensure([this, scanVertexTime]() {
SCOPED_TIMER(&execTime_);
otherStats_.emplace("total_rpc", folly::sformat("{}(us)", scanVertexTime.elapsedInUSec()));
})
.thenValue([this, sv](StorageRpcResponse<ScanResponse> &&rpcResp) {
SCOPED_TIMER(&execTime_);
addStats(rpcResp, otherStats_);
return handleResp(std::move(rpcResp), sv->colNames());
});
}

} // namespace graph
} // namespace nebula
26 changes: 26 additions & 0 deletions src/graph/executor/query/ScanVerticesExecutor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* Copyright (c) 2021 vesoft inc. All rights reserved.
*
* This source code is licensed under Apache 2.0 License.
*/

#pragma once

#include "graph/executor/query/GetPropExecutor.h"
#include "graph/planner/plan/Query.h"

namespace nebula {
namespace graph {

class ScanVerticesExecutor final : public GetPropExecutor {
public:
ScanVerticesExecutor(const PlanNode *node, QueryContext *qctx)
: GetPropExecutor("ScanVerticesExecutor", node, qctx) {}

folly::Future<Status> execute() override;

private:
folly::Future<Status> scanVertices();
};

} // namespace graph
} // namespace nebula
2 changes: 2 additions & 0 deletions src/graph/optimizer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ nebula_add_library(
rule/PushFilterDownAggregateRule.cpp
rule/PushFilterDownProjectRule.cpp
rule/PushFilterDownLeftJoinRule.cpp
rule/PushFilterDownScanVerticesRule.cpp
rule/PushVFilterDownScanVerticesRule.cpp
rule/OptimizeEdgeIndexScanByFilterRule.cpp
rule/OptimizeTagIndexScanByFilterRule.cpp
rule/UnionAllIndexScanBaseRule.cpp
Expand Down
Loading