Skip to content

Commit

Permalink
Add comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
CPWstatic committed Feb 15, 2022
1 parent 96ef20a commit f106472
Show file tree
Hide file tree
Showing 20 changed files with 93 additions and 112 deletions.
2 changes: 2 additions & 0 deletions src/graph/planner/match/ArgumentFinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

namespace nebula {
namespace graph {
// ArgumentFinder find if a pattern use a named alias that already declared
// in former patterns.
class ArgumentFinder final : public StartVidFinder {
public:
static std::unique_ptr<ArgumentFinder> make() {
Expand Down
6 changes: 2 additions & 4 deletions src/graph/planner/match/LabelIndexSeek.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
namespace nebula {
namespace graph {

/*
* The LabelIndexSeek was designed to find if could get the starting vids by tag
* index.
*/
// The LabelIndexSeek was designed to find if could get the starting vids by tag
// index.
class LabelIndexSeek final : public StartVidFinder {
public:
static std::unique_ptr<LabelIndexSeek> make() {
Expand Down
10 changes: 3 additions & 7 deletions src/graph/planner/match/MatchClausePlanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@

namespace nebula {
namespace graph {
/*
* The MatchClausePlanner was designed to generate plan for match clause;
*/
// The MatchClausePlanner generates plan for match clause;
class MatchClausePlanner final : public CypherClausePlanner {
public:
MatchClausePlanner() = default;
Expand Down Expand Up @@ -62,10 +60,8 @@ class MatchClausePlanner final : public CypherClausePlanner {
size_t startIndex,
SubPlan& subplan);

/*
* Project all named alias.
* TODO: Might not neccessary
*/
// Project all named alias.
// TODO: Might not neccessary
Status projectColumnsBySymbols(MatchClauseContext* matchClauseCtx, SubPlan& plan);

YieldColumn* buildVertexColumn(MatchClauseContext* matchClauseCtx,
Expand Down
1 change: 1 addition & 0 deletions src/graph/planner/match/MatchPlanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace nebula {
namespace graph {
// MatchPlanner generate plans for Match statement based on AstContext.
class MatchPlanner final : public Planner {
public:
static std::unique_ptr<MatchPlanner> make() {
Expand Down
4 changes: 1 addition & 3 deletions src/graph/planner/match/OrderByClausePlanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@

namespace nebula {
namespace graph {
/*
* The OrderByClausePlanner was designed to generate plan for order by clause;
*/
// The OrderByClausePlanner generate plan for order by clause;
class OrderByClausePlanner final : public CypherClausePlanner {
public:
OrderByClausePlanner() = default;
Expand Down
4 changes: 1 addition & 3 deletions src/graph/planner/match/PaginationPlanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@

namespace nebula {
namespace graph {
/*
* The PaginationPlanner was designed to generate subplan for skip/limit clause.
*/
// The PaginationPlanner generate subplan for skip/limit clause.
class PaginationPlanner final : public CypherClausePlanner {
public:
PaginationPlanner() = default;
Expand Down
6 changes: 2 additions & 4 deletions src/graph/planner/match/PropIndexSeek.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@

namespace nebula {
namespace graph {
/*
* The PropIndexSeek was designed to find if could get starting vids by tag
* props or edge props index.
*/
// The PropIndexSeek find if a plan could get starting vids by tag
// props or edge props index.
class PropIndexSeek final : public StartVidFinder {
public:
static std::unique_ptr<PropIndexSeek> make() {
Expand Down
4 changes: 1 addition & 3 deletions src/graph/planner/match/ReturnClausePlanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@

namespace nebula {
namespace graph {
/*
* The ReturnClausePlanner was designed to generated plan for return clause.
*/
// The ReturnClausePlanner generate plan for return clause.
class ReturnClausePlanner final : public CypherClausePlanner {
public:
ReturnClausePlanner() = default;
Expand Down
6 changes: 2 additions & 4 deletions src/graph/planner/match/ScanSeek.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@

namespace nebula {
namespace graph {
/*
* The ScanSeek was designed to find if could get the starting vids in
* filter.
*/
// The ScanSeek find if a plan could get the starting vids in
// filter.
class ScanSeek final : public StartVidFinder {
public:
static std::unique_ptr<ScanSeek> make() {
Expand Down
5 changes: 1 addition & 4 deletions src/graph/planner/match/SegmentsConnector.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@

namespace nebula {
namespace graph {
/**
* The SegmentsConnector was designed to be a util to help connecting the
* plan segment.
*/
// The SegmentsConnector is a util to help connecting the plan segment.
class SegmentsConnector final {
public:
SegmentsConnector() = delete;
Expand Down
25 changes: 25 additions & 0 deletions src/graph/planner/match/StartVidFinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,27 @@ class StartVidFinder;

using StartVidFinderInstantiateFunc = std::function<std::unique_ptr<StartVidFinder>()>;

// A StartVidFinder find a generally good solution for traversing from the vids.
// Currently we have five StartVidFinders:
// 1. VertexIdSeek find if a plan could traverse from a given vid.
// MATCH(n) WHERE id(n) = value RETURN n
//
// 2. ArgumentFinder find if a plan could traverse from some vids that already
// beed traversed.
// MATCH (n)-[]-(l), (l)-[]-(m) return n,l,m
// MATCH (n)-[]-(l) MATCH (l)-[]-(m) return n,l,m
//
// 3. PropIndexSeek find if a plan could traverse from some vids that could be
// read from the property indices.
// MATCH(n:Tag{prop:value}) RETURN n
// MATCH(n:Tag) WHERE n.prop = value RETURN n
//
// 4. LabelIndexSeek find if a plan could traverse from some vids that could be
// read from the label indices.
// MATCH(n: tag) RETURN n
// MATCH(s)-[:edge]->(e) RETURN e
//
// 5. ScanSeek find if a plan could traverse from some vids by scanning.
class StartVidFinder {
public:
virtual ~StartVidFinder() = default;
Expand All @@ -26,8 +47,12 @@ class StartVidFinder {

bool match(PatternContext* patternCtx);

// The derived class should implement matchNode if the finder has
// ability to find vids from node pattern.
virtual bool matchNode(NodeContext* nodeCtx) = 0;

// The derived class should implement matchEdge if the finder has
// ability to find vids from edge pattern.
virtual bool matchEdge(EdgeContext* nodeCtx) = 0;

StatusOr<SubPlan> transform(PatternContext* patternCtx);
Expand Down
4 changes: 1 addition & 3 deletions src/graph/planner/match/UnwindClausePlanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@

namespace nebula {
namespace graph {
/*
* The UnwindClausePlanner was designed to generate plan for unwind clause
*/
// The UnwindClausePlanner generates plan for unwind clause
class UnwindClausePlanner final : public CypherClausePlanner {
public:
UnwindClausePlanner() = default;
Expand Down
5 changes: 1 addition & 4 deletions src/graph/planner/match/VertexIdSeek.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@

namespace nebula {
namespace graph {
/*
* The VertexIdSeek was designed to find if could get the starting vids in
* filter.
*/
// The VertexIdSeek find if a plan could get the starting vids in filters.
class VertexIdSeek final : public StartVidFinder {
public:
static std::unique_ptr<VertexIdSeek> make() {
Expand Down
4 changes: 1 addition & 3 deletions src/graph/planner/match/WhereClausePlanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@

namespace nebula {
namespace graph {
/*
* The WhereClausePlanner was designed to generate plan for where clause.
*/
// The WhereClausePlanner generates plan for where clause.
class WhereClausePlanner final : public CypherClausePlanner {
public:
explicit WhereClausePlanner(bool needStableFilter = false)
Expand Down
4 changes: 1 addition & 3 deletions src/graph/planner/match/WithClausePlanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@

namespace nebula {
namespace graph {
/*
* The WithClausePlanner was designed to generate plan for with clause.
*/
// The WithClausePlanner generates plan for with clause.
class WithClausePlanner final : public CypherClausePlanner {
public:
WithClausePlanner() = default;
Expand Down
5 changes: 1 addition & 4 deletions src/graph/planner/match/YieldClausePlanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@

namespace nebula {
namespace graph {
/*
* The YieldClausePlanner was designed to generate plan for yield clause in
* cypher
*/
// The YieldClausePlanner generates plan for yield clause
class YieldClausePlanner final : public CypherClausePlanner {
public:
YieldClausePlanner() = default;
Expand Down
50 changes: 19 additions & 31 deletions src/graph/planner/ngql/GoPlanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,9 @@ Expression* GoPlanner::loopCondition(uint32_t steps, const std::string& var) {
return LogicalExpression::makeAnd(pool, step, earlyEnd);
}

/*
* extract vid and edge's prop from GN
* for joinDst & joinInput
* output colNames {srcProps, edgeProps, kVid, "JOIN_DST_VID"}
*/
// extract vid and edge's prop from GN
// for joinDst & joinInput
// output colNames {srcProps, edgeProps, kVid, "JOIN_DST_VID"}
PlanNode* GoPlanner::extractSrcEdgePropsFromGN(PlanNode* dep, const std::string& input) {
auto& srcEdgePropsExpr = goCtx_->srcEdgePropsExpr;
auto* pool = goCtx_->qctx->objPool();
Expand All @@ -116,11 +114,9 @@ PlanNode* GoPlanner::extractSrcEdgePropsFromGN(PlanNode* dep, const std::string&
return project;
}

/*
* extract vid and dst from GN
* for trackStartVid
* output ColNames {srcVidColName, "TRACK_DST_VID"}
*/
// extract vid and dst from GN
// for trackStartVid
// output ColNames {srcVidColName, "TRACK_DST_VID"}
PlanNode* GoPlanner::extractSrcDstFromGN(PlanNode* dep, const std::string& input) {
auto qctx = goCtx_->qctx;
auto* pool = qctx->objPool();
Expand All @@ -138,11 +134,9 @@ PlanNode* GoPlanner::extractSrcDstFromGN(PlanNode* dep, const std::string& input
return dedup;
}

/*
* extract vid from runTime input
* for joinInput
* output ColNames {runtimeVidName, dstVidColName}
*/
// extract vid from runTime input
// for joinInput
// output ColNames {runtimeVidName, dstVidColName}
PlanNode* GoPlanner::extractVidFromRuntimeInput(PlanNode* dep) {
if (dep == nullptr) {
return dep;
Expand All @@ -166,13 +160,11 @@ PlanNode* GoPlanner::extractVidFromRuntimeInput(PlanNode* dep) {
return dedup;
}

/*
* establish a mapping between the original vId and the expanded destination vId
* during each step of the expansion in the n-step and mton-step scenario
* left: n-1 steps
* right: step n
* output ColNames {runtimeVidName, dstVidColName}
*/
// establish a mapping between the original vId and the expanded destination vId
// during each step of the expansion in the n-step and mton-step scenario
// left: n-1 steps
// right: step n
// output ColNames {runtimeVidName, dstVidColName}
PlanNode* GoPlanner::trackStartVid(PlanNode* left, PlanNode* right) {
auto qctx = goCtx_->qctx;
auto* pool = qctx->objPool();
Expand Down Expand Up @@ -207,10 +199,8 @@ PlanNode* GoPlanner::trackStartVid(PlanNode* left, PlanNode* right) {
return dedup;
}

/*
* output ColNames {srcProps, edgeProps, kVid, "JOIN_DST_VID", "DST_VID",
* dstProps}
*/
// output ColNames {srcProps, edgeProps, kVid, "JOIN_DST_VID", "DST_VID",
// dstProps}
PlanNode* GoPlanner::buildJoinDstPlan(PlanNode* dep) {
auto qctx = goCtx_->qctx;
auto* pool = qctx->objPool();
Expand Down Expand Up @@ -279,11 +269,9 @@ PlanNode* GoPlanner::buildJoinInputPlan(PlanNode* dep) {
return join;
}

/*
* left's colName dstVidColName join right's colName kVid
* left : n-1 steps
* right : last step
*/
// left's colName dstVidColName join right's colName kVid
// left : n-1 steps
// right : last step
PlanNode* GoPlanner::lastStepJoinInput(PlanNode* left, PlanNode* right) {
auto qctx = goCtx_->qctx;
auto* pool = qctx->objPool();
Expand Down
46 changes: 23 additions & 23 deletions src/graph/planner/ngql/PathPlanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,29 +469,29 @@ PlanNode* PathPlanner::buildEdgePlan(PlanNode* dep, const std::string& input) {
return getEdge;
}

/*
The Plan looks like this:
+--------+---------+
+-->+ PassThrough +<----+
| +------------------+ |
+--------+---------+ +---------+------------+
| Project(Nodes) | |Project(RelationShips)|
+--------+---------+ +---------+------------+
| |
+--------+---------+ +---------+--------+
| Unwind | | Unwind |
+--------+---------+ +---------+--------+
| |
+--------+---------+ +---------+--------+
| GetVertices | | GetEdges |
+--------+---------+ +---------+--------+
| |
+------------+---------------+
|
+--------+---------+
| DataCollect |
+--------+---------+
*/
//
// The Plan looks like this:
// +--------+---------+
// +-->+ PassThrough +<----+
// | +------------------+ |
// +--------+---------+ +---------+------------+
// | Project(Nodes) | |Project(RelationShips)|
// +--------+---------+ +---------+------------+
// | |
// +--------+---------+ +---------+--------+
// | Unwind | | Unwind |
// +--------+---------+ +---------+--------+
// | |
// +--------+---------+ +---------+--------+
// | GetVertices | | GetEdges |
// +--------+---------+ +---------+--------+
// | |
// +------------+---------------+
// |
// +--------+---------+
// | DataCollect |
// +--------+---------+
//
PlanNode* PathPlanner::buildPathProp(PlanNode* dep) {
auto qctx = pathCtx_->qctx;
auto* pt = PassThroughNode::make(qctx, dep);
Expand Down
10 changes: 4 additions & 6 deletions src/graph/planner/plan/Admin.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
#include "graph/planner/plan/Query.h"
#include "interface/gen-cpp2/meta_types.h"

/**
* All admin-related nodes would be put in this file.
* These nodes would not exist in a same plan with maintain-related/
* mutate-related/query-related nodes. And they are also isolated
* from each other. This would be guaranteed by parser and validator.
*/
// All admin-related nodes would be put in this file.
// These nodes would not exist in a same plan with maintain-related/
// mutate-related/query-related nodes. And they are also isolated
// from each other. This would be guaranteed by parser and validator.
namespace nebula {
namespace graph {

Expand Down
4 changes: 1 addition & 3 deletions src/graph/planner/plan/Mutate.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
#include "graph/planner/plan/Query.h"
#include "parser/TraverseSentences.h"

/**
* All mutate-related nodes would put in this file.
*/
// All mutate-related nodes would put in this file.
namespace nebula {
namespace graph {
class InsertVertices final : public SingleDependencyNode {
Expand Down

0 comments on commit f106472

Please sign in to comment.