Skip to content
This repository has been archived by the owner on Dec 1, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into featureX
Browse files Browse the repository at this point in the history
  • Loading branch information
yixinglu authored Jun 18, 2021
2 parents 7a86e0b + 9032b50 commit 932030b
Show file tree
Hide file tree
Showing 40 changed files with 451 additions and 555 deletions.
2 changes: 1 addition & 1 deletion src/executor/StorageAccessExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class StorageAccessExecutor : public Executor {
return Status::Error(std::move(error));
}
case nebula::cpp2::ErrorCode::E_INVALID_VID: {
std::string error = "Storage Error: The VID must be a 64-bit interger"
std::string error = "Storage Error: The VID must be a 64-bit integer"
" or a string fitting space vertex id length limit.";
return Status::Error(std::move(error));
}
Expand Down
3 changes: 2 additions & 1 deletion src/executor/admin/SpaceExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ folly::Future<Status> DropSpaceExecutor::execute() {
auto ftIndexesRet = qctx()->getMetaClient()->getFTIndexBySpaceFromCache(spaceIdRet.value());
NG_RETURN_IF_ERROR(ftIndexesRet);
auto map = std::move(ftIndexesRet).value();
transform(map.begin(), map.end(), ftIndexes.begin(), [](auto pair) { return pair.first; });
auto get = [] (const auto &ptr) { return ptr.first; };
std::transform(map.begin(), map.end(), std::back_inserter(ftIndexes), get);
} else {
LOG(WARNING) << "Get space ID failed when prepare text index: " << dsNode->getSpaceName();
}
Expand Down
4 changes: 2 additions & 2 deletions src/executor/query/GetEdgesExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ folly::Future<Status> GetEdgesExecutor::getEdges() {
->getProps(ge->space(),
std::move(edges),
nullptr,
&ge->props(),
ge->exprs().empty() ? nullptr : &ge->exprs(),
ge->props(),
ge->exprs(),
ge->dedup(),
ge->orderBy(),
ge->limit(),
Expand Down
4 changes: 2 additions & 2 deletions src/executor/query/GetVerticesExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ folly::Future<Status> GetVerticesExecutor::getVertices() {
return DCHECK_NOTNULL(storageClient)
->getProps(gv->space(),
std::move(vertices),
&gv->props(),
gv->props(),
nullptr,
gv->exprs().empty() ? nullptr : &gv->exprs(),
gv->exprs(),
gv->dedup(),
gv->orderBy(),
gv->limit(),
Expand Down
9 changes: 9 additions & 0 deletions src/parser/Clauses.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,15 @@ class YieldColumns final {
return result;
}

std::vector<std::string> names() const {
std::vector<std::string> names;
names.reserve(columns_.size());
for (auto &col : columns_) {
names.emplace_back(col->name());
}
return names;
}

size_t size() const {
return columns_.size();
}
Expand Down
2 changes: 1 addition & 1 deletion src/planner/match/MatchSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ Status MatchSolver::appendFetchVertexPlan(const Expression* nodeFilter,
extractAndDedupVidColumn(qctx, initialExpr, plan.root, inputVar, plan);
auto srcExpr = ExpressionUtils::inputPropExpr(kVid);
// [Get vertices]
auto props = SchemaUtil::getAllVertexProp(qctx, space);
auto props = SchemaUtil::getAllVertexProp(qctx, space, true);
NG_RETURN_IF_ERROR(props);
auto gv = GetVertices::make(qctx,
plan.root,
Expand Down
6 changes: 1 addition & 5 deletions src/planner/match/YieldClausePlanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,7 @@ Status YieldClausePlanner::buildYield(YieldClauseContext* yctx, SubPlan& subplan
}

if (yctx->distinct) {
auto root = subplan.root;
auto* dedup = Dedup::make(yctx->qctx, root);
dedup->setInputVar(root->outputVar());
dedup->setColNames(root->colNames());
subplan.root = dedup;
subplan.root = Dedup::make(yctx->qctx, subplan.root);
}

return Status::OK();
Expand Down
12 changes: 6 additions & 6 deletions src/planner/ngql/PathPlanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

namespace nebula {
namespace graph {
GetNeighbors::EdgeProps PathPlanner::buildEdgeProps(bool reverse) {
auto edgeProps = std::make_unique<std::vector<storage::cpp2::EdgeProp>>();
std::unique_ptr<std::vector<EdgeProp>> PathPlanner::buildEdgeProps(bool reverse) {
auto edgeProps = std::make_unique<std::vector<EdgeProp>>();
switch (pathCtx_->over.direction) {
case storage::cpp2::EdgeDirection::IN_EDGE: {
doBuildEdgeProps(edgeProps, reverse, true);
Expand All @@ -33,7 +33,7 @@ GetNeighbors::EdgeProps PathPlanner::buildEdgeProps(bool reverse) {
return edgeProps;
}

void PathPlanner::doBuildEdgeProps(GetNeighbors::EdgeProps& edgeProps,
void PathPlanner::doBuildEdgeProps(std::unique_ptr<std::vector<EdgeProp>>& edgeProps,
bool reverse,
bool isInEdge) {
const auto& exprProps = pathCtx_->exprProps;
Expand Down Expand Up @@ -148,9 +148,9 @@ PlanNode* PathPlanner::allPairStartVidDataSet(PlanNode* dep, const std::string&
columns->addColumn(path);

auto* project = Project::make(pathCtx_->qctx, dep, columns);
project->setColNames({kVid, kPathStr});
project->setInputVar(inputVar);
project->setOutputVar(inputVar);
project->setColNames({kVid, kPathStr});

return project;
}
Expand Down Expand Up @@ -401,7 +401,7 @@ PlanNode* PathPlanner::buildVertexPlan(PlanNode* dep, const std::string& input)
idArgs->addArgument(std::make_unique<ColumnExpression>(1));
auto* src = qctx->objPool()->add(new FunctionCallExpression("id", idArgs));
// get all vertexprop
auto vertexProp = SchemaUtil::getAllVertexProp(qctx, pathCtx_->space);
auto vertexProp = SchemaUtil::getAllVertexProp(qctx, pathCtx_->space, true);
auto* getVertices = GetVertices::make(
qctx, unwind, pathCtx_->space.id, src, std::move(vertexProp).value(), {}, true);

Expand Down Expand Up @@ -448,7 +448,7 @@ PlanNode* PathPlanner::buildEdgePlan(PlanNode* dep, const std::string& input) {
auto* type =
qctx->objPool()->add(new FunctionCallExpression("typeid", typeArgs));
// prepare edgetype
auto edgeProp = SchemaUtil::getEdgeProp(qctx, pathCtx_->space, pathCtx_->over.edgeTypes);
auto edgeProp = SchemaUtil::getEdgeProps(qctx, pathCtx_->space, pathCtx_->over.edgeTypes, true);
auto* getEdge = GetEdges::make(qctx,
unwind,
pathCtx_->space.id,
Expand Down
7 changes: 5 additions & 2 deletions src/planner/ngql/PathPlanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace graph {

class PathPlanner final : public Planner {
public:
using EdgeProp = nebula::storage::cpp2::EdgeProp;
static std::unique_ptr<PathPlanner> make() {
return std::unique_ptr<PathPlanner>(new PathPlanner());
}
Expand Down Expand Up @@ -49,9 +50,11 @@ class PathPlanner final : public Planner {
PlanNode* buildEdgePlan(PlanNode* dep, const std::string& input);

private:
GetNeighbors::EdgeProps buildEdgeProps(bool reverse);
std::unique_ptr<std::vector<EdgeProp>> buildEdgeProps(bool reverse);

void doBuildEdgeProps(GetNeighbors::EdgeProps& edgeProps, bool reverse, bool isInEdge);
void doBuildEdgeProps(std::unique_ptr<std::vector<EdgeProp>>& edgeProps,
bool reverse,
bool isInEdge);

void buildStart(Starts& starts, std::string& startVidsVar, bool reverse);

Expand Down
9 changes: 9 additions & 0 deletions src/planner/plan/PlanNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,15 @@ std::ostream& operator<<(std::ostream& os, PlanNode::Kind kind) {
return os;
}

SingleInputNode::SingleInputNode(QueryContext* qctx, Kind kind, const PlanNode* dep)
: SingleDependencyNode(qctx, kind, dep) {
if (dep != nullptr) {
readVariable(dep->outputVarPtr());
} else {
inputVars_.emplace_back(nullptr);
}
}

std::unique_ptr<PlanNodeDescription> SingleDependencyNode::explain() const {
auto desc = PlanNode::explain();
DCHECK(desc->dependencies == nullptr);
Expand Down
15 changes: 9 additions & 6 deletions src/planner/plan/PlanNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ class SingleDependencyNode : public PlanNode {

PlanNode* clone() const override {
LOG(FATAL) << "Shouldn't call the unimplemented method";
return nullptr;
}

protected:
Expand All @@ -315,21 +316,21 @@ class SingleInputNode : public SingleDependencyNode {

PlanNode* clone() const override {
LOG(FATAL) << "Shouldn't call the unimplemented method";
return nullptr;
}

protected:
void cloneMembers(const SingleInputNode &node) {
SingleDependencyNode::cloneMembers(node);
}

SingleInputNode(QueryContext* qctx, Kind kind, const PlanNode* dep)
: SingleDependencyNode(qctx, kind, dep) {
if (dep != nullptr) {
readVariable(dep->outputVarPtr());
} else {
inputVars_.emplace_back(nullptr);
void copyInputColNames(const PlanNode* input) {
if (input != nullptr) {
setColNames(input->colNames());
}
}

SingleInputNode(QueryContext* qctx, Kind kind, const PlanNode* dep);
};

class BinaryInputNode : public PlanNode {
Expand Down Expand Up @@ -368,6 +369,7 @@ class BinaryInputNode : public PlanNode {

PlanNode* clone() const override {
LOG(FATAL) << "Shouldn't call the unimplemented method";
return nullptr;
}

std::unique_ptr<PlanNodeDescription> explain() const override;
Expand All @@ -388,6 +390,7 @@ class VariableDependencyNode : public PlanNode {

PlanNode* clone() const override {
LOG(FATAL) << "Shouldn't call the unimplemented method";
return nullptr;
}

protected:
Expand Down
64 changes: 35 additions & 29 deletions src/planner/plan/Query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,11 @@ void GetNeighbors::cloneMembers(const GetNeighbors& g) {
}
}


std::unique_ptr<PlanNodeDescription> GetVertices::explain() const {
auto desc = Explore::explain();
addDescription("src", src_ ? src_->toString() : "", desc.get());
addDescription("props", folly::toJson(util::toJson(props_)), desc.get());
addDescription("exprs", folly::toJson(util::toJson(exprs_)), desc.get());
addDescription("props", props_ ? folly::toJson(util::toJson(*props_)) : "", desc.get());
addDescription("exprs", exprs_ ? folly::toJson(util::toJson(*exprs_)) : "", desc.get());
return desc;
}

Expand All @@ -115,21 +114,17 @@ void GetVertices::cloneMembers(const GetVertices& gv) {

src_ = qctx_->objPool()->add(gv.src()->clone().release());

std::vector<storage::cpp2::VertexProp> props;
const auto& gvProps = gv.props();
props.reserve(gvProps.size());
for (const auto& prop : gvProps) {
props.emplace_back(prop);
if (gv.props_) {
auto vertexProps = *gv.props_;
auto vertexPropsPtr = std::make_unique<decltype(vertexProps)>(std::move(vertexProps));
setVertexProps(std::move(vertexPropsPtr));
}
props_ = std::move(props);

std::vector<storage::cpp2::Expr> exprs;
const auto& gvExprs = gv.exprs();
exprs.reserve(gvExprs.size());
for (const auto& expr : gvExprs) {
exprs.emplace_back(expr);
if (gv.exprs_) {
auto exprs = *gv.exprs_;
auto exprsPtr = std::make_unique<decltype(exprs)>(std::move(exprs));
setExprs(std::move(exprsPtr));
}
exprs_ = std::move(exprs);
}


Expand All @@ -139,8 +134,8 @@ std::unique_ptr<PlanNodeDescription> GetEdges::explain() const {
addDescription("type", util::toJson(type_), desc.get());
addDescription("ranking", ranking_ ? ranking_->toString() : "", desc.get());
addDescription("dst", dst_ ? dst_->toString() : "", desc.get());
addDescription("props", folly::toJson(util::toJson(props_)), desc.get());
addDescription("exprs", folly::toJson(util::toJson(exprs_)), desc.get());
addDescription("props", props_ ? folly::toJson(util::toJson(*props_)) : "", desc.get());
addDescription("exprs", exprs_ ? folly::toJson(util::toJson(*exprs_)) : "", desc.get());
return desc;
}

Expand All @@ -158,21 +153,17 @@ void GetEdges::cloneMembers(const GetEdges& ge) {
ranking_ = qctx_->objPool()->add(ge.ranking()->clone().release());
dst_ = qctx_->objPool()->add(ge.dst()->clone().release());

std::vector<storage::cpp2::EdgeProp> props;
const auto& geProps = ge.props();
props.reserve(geProps.size());
for (const auto& prop : geProps) {
props.emplace_back(prop);
if (ge.props_) {
auto edgeProps = *ge.props_;
auto edgePropsPtr = std::make_unique<decltype(edgeProps)>(std::move(edgeProps));
setEdgeProps(std::move(edgePropsPtr));
}
props_ = std::move(props);

std::vector<storage::cpp2::Expr> exprs;
const auto& geExprs = ge.exprs();
exprs.reserve(geExprs.size());
for (const auto& expr : geExprs) {
exprs.emplace_back(expr);
if (ge.exprs_) {
auto exprs = *ge.exprs_;
auto exprsPtr = std::make_unique<decltype(exprs)>(std::move(exprs));
setExprs(std::move(exprsPtr));
}
exprs_ = std::move(exprs);
}


Expand Down Expand Up @@ -205,6 +196,12 @@ void IndexScan::cloneMembers(const IndexScan &g) {
isEmptyResultSet_ = g.isEmptyResultSet();
}

Filter::Filter(QueryContext* qctx, PlanNode* input, Expression* condition, bool needStableFilter)
: SingleInputNode(qctx, Kind::kFilter, input) {
condition_ = condition;
needStableFilter_ = needStableFilter;
copyInputColNames(input);
}

std::unique_ptr<PlanNodeDescription> Filter::explain() const {
auto desc = SingleInputNode::explain();
Expand Down Expand Up @@ -263,6 +260,12 @@ void Minus::cloneMembers(const Minus& f) {
SetOp::cloneMembers(f);
}

Project::Project(QueryContext* qctx, PlanNode* input, YieldColumns* cols)
: SingleInputNode(qctx, Kind::kProject, input), cols_(cols) {
if (cols_ != nullptr) {
setColNames(cols_->names());
}
}

std::unique_ptr<PlanNodeDescription> Project::explain() const {
auto desc = SingleInputNode::explain();
Expand Down Expand Up @@ -436,6 +439,9 @@ void SwitchSpace::cloneMembers(const SwitchSpace &l) {
SingleInputNode::cloneMembers(l);
}

Dedup::Dedup(QueryContext* qctx, PlanNode* input) : SingleInputNode(qctx, Kind::kDedup, input) {
copyInputColNames(input);
}

PlanNode* Dedup::clone() const {
auto* newDedup = Dedup::make(qctx_, nullptr);
Expand Down
Loading

0 comments on commit 932030b

Please sign in to comment.