diff --git a/src/graph/planner/Planner.h b/src/graph/planner/Planner.h index ec207774491..49238ee1735 100644 --- a/src/graph/planner/Planner.h +++ b/src/graph/planner/Planner.h @@ -36,17 +36,28 @@ struct MatchAndInstantiate { PlannerInstantiateFunc instantiate; }; +// A planner generates plans for statements. +// For example, we have MatchPlanner that generates plan for Match statement. +// And we have GoPlanner that generates plan for Go statements. Each planner +// will be registered into the plannersMap in the PlannersRegister when the +// graphd service starts up. class Planner { public: virtual ~Planner() = default; + // Each statement might have many planners that match different situations. + // Each planner should provide two funtions: + // 1. MatchFunc that matchs the proper situation + // 2. PlannerInstantiateFunc that instantiates the planner static auto& plannersMap() { static std::unordered_map> plannersMap; return plannersMap; } + // Generates plans for each statement based on AsrContext. static StatusOr toPlan(AstContext* astCtx); + // Transforms the AstContext to a plan which determined by the implementations. virtual StatusOr transform(AstContext* astCtx) = 0; protected: diff --git a/src/graph/planner/match/ArgumentFinder.h b/src/graph/planner/match/ArgumentFinder.h index 381bf210254..1c7a31d3ba5 100644 --- a/src/graph/planner/match/ArgumentFinder.h +++ b/src/graph/planner/match/ArgumentFinder.h @@ -10,6 +10,8 @@ namespace nebula { namespace graph { +// ArgumentFinder finds if a pattern uses a named alias that has already been declared +// in former patterns. class ArgumentFinder final : public StartVidFinder { public: static std::unique_ptr make() { diff --git a/src/graph/planner/match/LabelIndexSeek.h b/src/graph/planner/match/LabelIndexSeek.h index 932d3b7197d..24f6b550d23 100644 --- a/src/graph/planner/match/LabelIndexSeek.h +++ b/src/graph/planner/match/LabelIndexSeek.h @@ -11,10 +11,7 @@ namespace nebula { namespace graph { -/* - * The LabelIndexSeek was designed to find if could get the starting vids by tag - * index. - */ +// The LabelIndexSeek finds if a plan could get the starting vids by tag index. class LabelIndexSeek final : public StartVidFinder { public: static std::unique_ptr make() { diff --git a/src/graph/planner/match/MatchClausePlanner.h b/src/graph/planner/match/MatchClausePlanner.h index 446b7a8131e..e7c08e281bf 100644 --- a/src/graph/planner/match/MatchClausePlanner.h +++ b/src/graph/planner/match/MatchClausePlanner.h @@ -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; @@ -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, diff --git a/src/graph/planner/match/MatchPlanner.h b/src/graph/planner/match/MatchPlanner.h index 0017ee66db3..7ce142dfe6d 100644 --- a/src/graph/planner/match/MatchPlanner.h +++ b/src/graph/planner/match/MatchPlanner.h @@ -11,6 +11,7 @@ namespace nebula { namespace graph { +// MatchPlanner generates plans for Match statement based on AstContext. class MatchPlanner final : public Planner { public: static std::unique_ptr make() { diff --git a/src/graph/planner/match/OrderByClausePlanner.h b/src/graph/planner/match/OrderByClausePlanner.h index de6c0859311..fbb892cda53 100644 --- a/src/graph/planner/match/OrderByClausePlanner.h +++ b/src/graph/planner/match/OrderByClausePlanner.h @@ -10,9 +10,7 @@ namespace nebula { namespace graph { -/* - * The OrderByClausePlanner was designed to generate plan for order by clause; - */ +// The OrderByClausePlanner generates plan for order by clause; class OrderByClausePlanner final : public CypherClausePlanner { public: OrderByClausePlanner() = default; diff --git a/src/graph/planner/match/PaginationPlanner.h b/src/graph/planner/match/PaginationPlanner.h index c76bb9981f3..3cad9ab2a7a 100644 --- a/src/graph/planner/match/PaginationPlanner.h +++ b/src/graph/planner/match/PaginationPlanner.h @@ -10,9 +10,7 @@ namespace nebula { namespace graph { -/* - * The PaginationPlanner was designed to generate subplan for skip/limit clause. - */ +// The PaginationPlanner generates subplan for skip/limit clause. class PaginationPlanner final : public CypherClausePlanner { public: PaginationPlanner() = default; diff --git a/src/graph/planner/match/PropIndexSeek.h b/src/graph/planner/match/PropIndexSeek.h index e83c65e600a..821178e1615 100644 --- a/src/graph/planner/match/PropIndexSeek.h +++ b/src/graph/planner/match/PropIndexSeek.h @@ -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 finds if a plan could get starting vids by tag +// props or edge props index. class PropIndexSeek final : public StartVidFinder { public: static std::unique_ptr make() { diff --git a/src/graph/planner/match/ReturnClausePlanner.h b/src/graph/planner/match/ReturnClausePlanner.h index 4431a2a7c7a..e93f741af4b 100644 --- a/src/graph/planner/match/ReturnClausePlanner.h +++ b/src/graph/planner/match/ReturnClausePlanner.h @@ -10,9 +10,7 @@ namespace nebula { namespace graph { -/* - * The ReturnClausePlanner was designed to generated plan for return clause. - */ +// The ReturnClausePlanner generates plan for return clause. class ReturnClausePlanner final : public CypherClausePlanner { public: ReturnClausePlanner() = default; diff --git a/src/graph/planner/match/ScanSeek.h b/src/graph/planner/match/ScanSeek.h index 1142723d974..c07243d8a7f 100644 --- a/src/graph/planner/match/ScanSeek.h +++ b/src/graph/planner/match/ScanSeek.h @@ -11,10 +11,7 @@ namespace nebula { namespace graph { -/* - * The ScanSeek was designed to find if could get the starting vids in - * filter. - */ +// The ScanSeek finds if a plan could get the starting vids in filter. class ScanSeek final : public StartVidFinder { public: static std::unique_ptr make() { diff --git a/src/graph/planner/match/SegmentsConnector.h b/src/graph/planner/match/SegmentsConnector.h index 1594879c348..29bf4ff8bfd 100644 --- a/src/graph/planner/match/SegmentsConnector.h +++ b/src/graph/planner/match/SegmentsConnector.h @@ -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; diff --git a/src/graph/planner/match/StartVidFinder.h b/src/graph/planner/match/StartVidFinder.h index 7a740fd57d9..bc841274e71 100644 --- a/src/graph/planner/match/StartVidFinder.h +++ b/src/graph/planner/match/StartVidFinder.h @@ -15,6 +15,27 @@ class StartVidFinder; using StartVidFinderInstantiateFunc = std::function()>; +// A StartVidFinder finds 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 finds 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 finds 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 finds 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 finds if a plan could traverse from some vids by scanning. class StartVidFinder { public: virtual ~StartVidFinder() = default; @@ -26,8 +47,12 @@ class StartVidFinder { bool match(PatternContext* patternCtx); + // The derived class should implement matchNode if the finder has + // the ability to find vids from node pattern. virtual bool matchNode(NodeContext* nodeCtx) = 0; + // The derived class should implement matchEdge if the finder has + // the ability to find vids from edge pattern. virtual bool matchEdge(EdgeContext* nodeCtx) = 0; StatusOr transform(PatternContext* patternCtx); diff --git a/src/graph/planner/match/UnwindClausePlanner.h b/src/graph/planner/match/UnwindClausePlanner.h index 46b0f8777bd..36f21afe133 100644 --- a/src/graph/planner/match/UnwindClausePlanner.h +++ b/src/graph/planner/match/UnwindClausePlanner.h @@ -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; diff --git a/src/graph/planner/match/VertexIdSeek.h b/src/graph/planner/match/VertexIdSeek.h index 2fd58a172aa..b3ea83d5f60 100644 --- a/src/graph/planner/match/VertexIdSeek.h +++ b/src/graph/planner/match/VertexIdSeek.h @@ -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 make() { diff --git a/src/graph/planner/match/WhereClausePlanner.h b/src/graph/planner/match/WhereClausePlanner.h index c9a04e4c607..3a68b057f7e 100644 --- a/src/graph/planner/match/WhereClausePlanner.h +++ b/src/graph/planner/match/WhereClausePlanner.h @@ -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) diff --git a/src/graph/planner/match/WithClausePlanner.h b/src/graph/planner/match/WithClausePlanner.h index 812cba8ba19..4e481e8179b 100644 --- a/src/graph/planner/match/WithClausePlanner.h +++ b/src/graph/planner/match/WithClausePlanner.h @@ -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; diff --git a/src/graph/planner/match/YieldClausePlanner.h b/src/graph/planner/match/YieldClausePlanner.h index 725335f5758..9260335532e 100644 --- a/src/graph/planner/match/YieldClausePlanner.h +++ b/src/graph/planner/match/YieldClausePlanner.h @@ -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; diff --git a/src/graph/planner/ngql/GoPlanner.cpp b/src/graph/planner/ngql/GoPlanner.cpp index 9142e40960c..8f7215b7bb0 100644 --- a/src/graph/planner/ngql/GoPlanner.cpp +++ b/src/graph/planner/ngql/GoPlanner.cpp @@ -90,11 +90,8 @@ 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"} - */ +// Extracts vid and edge's prop from GN for joinDst & joinInput. +// The root plan node will output colNames of {srcProps, edgeProps, kVid, "JOIN_DST_VID"}. PlanNode* GoPlanner::extractSrcEdgePropsFromGN(PlanNode* dep, const std::string& input) { auto& srcEdgePropsExpr = goCtx_->srcEdgePropsExpr; auto* pool = goCtx_->qctx->objPool(); @@ -116,11 +113,8 @@ PlanNode* GoPlanner::extractSrcEdgePropsFromGN(PlanNode* dep, const std::string& return project; } -/* - * extract vid and dst from GN - * for trackStartVid - * output ColNames {srcVidColName, "TRACK_DST_VID"} - */ +// Extracts vid and dst from GN for trackStartVid. +// The root plan node will output ColNames of {srcVidColName, "TRACK_DST_VID"}. PlanNode* GoPlanner::extractSrcDstFromGN(PlanNode* dep, const std::string& input) { auto qctx = goCtx_->qctx; auto* pool = qctx->objPool(); @@ -138,11 +132,8 @@ PlanNode* GoPlanner::extractSrcDstFromGN(PlanNode* dep, const std::string& input return dedup; } -/* - * extract vid from runTime input - * for joinInput - * output ColNames {runtimeVidName, dstVidColName} - */ +// Extracts vid from runTime input for joinInput. +// The root plan node will output ColNames of {runtimeVidName, dstVidColName}. PlanNode* GoPlanner::extractVidFromRuntimeInput(PlanNode* dep) { if (dep == nullptr) { return dep; @@ -166,13 +157,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} - */ +// Establishes 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. +// The root plan node will output ColNames of {runtimeVidName, dstVidColName}. +// left: (n-1)th step +// right: (n)th step PlanNode* GoPlanner::trackStartVid(PlanNode* left, PlanNode* right) { auto qctx = goCtx_->qctx; auto* pool = qctx->objPool(); @@ -207,10 +196,8 @@ PlanNode* GoPlanner::trackStartVid(PlanNode* left, PlanNode* right) { return dedup; } -/* - * output ColNames {srcProps, edgeProps, kVid, "JOIN_DST_VID", "DST_VID", - * dstProps} - */ +// The root plan node will output ColNames of +// {srcProps, edgeProps, kVid, "JOIN_DST_VID", "DST_VID", dstProps} PlanNode* GoPlanner::buildJoinDstPlan(PlanNode* dep) { auto qctx = goCtx_->qctx; auto* pool = qctx->objPool(); @@ -279,11 +266,10 @@ PlanNode* GoPlanner::buildJoinInputPlan(PlanNode* dep) { return join; } -/* - * left's colName dstVidColName join right's colName kVid - * left : n-1 steps - * right : last step - */ +// The column named as dstVidColName of the left plan node join on the column named as kVid of the +// right one. +// left : (n-1)th step +// right : last step PlanNode* GoPlanner::lastStepJoinInput(PlanNode* left, PlanNode* right) { auto qctx = goCtx_->qctx; auto* pool = qctx->objPool(); @@ -374,8 +360,7 @@ PlanNode* GoPlanner::buildSampleLimitImpl(PlanNode* input, T sampleLimit) { return node; } -// generate -// $limits[$step-1] +// Generates $limits[$step-1] Expression* GoPlanner::stepSampleLimit() { auto qctx = goCtx_->qctx; // $limits diff --git a/src/graph/planner/ngql/PathPlanner.cpp b/src/graph/planner/ngql/PathPlanner.cpp index 297d749d936..1d18be5b45a 100644 --- a/src/graph/planner/ngql/PathPlanner.cpp +++ b/src/graph/planner/ngql/PathPlanner.cpp @@ -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); diff --git a/src/graph/planner/plan/Admin.h b/src/graph/planner/plan/Admin.h index d9204647c02..2fd3526fc0b 100644 --- a/src/graph/planner/plan/Admin.h +++ b/src/graph/planner/plan/Admin.h @@ -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 { diff --git a/src/graph/planner/plan/ExecutionPlan.h b/src/graph/planner/plan/ExecutionPlan.h index 86bfe10cbbd..469a7ed4b89 100644 --- a/src/graph/planner/plan/ExecutionPlan.h +++ b/src/graph/planner/plan/ExecutionPlan.h @@ -23,6 +23,7 @@ struct SubPlan { PlanNode* tail{nullptr}; }; +// An ExecutionPlan is a Directed Cyclic Graph which composed by PlanNodes. class ExecutionPlan final { public: explicit ExecutionPlan(PlanNode* root = nullptr); diff --git a/src/graph/planner/plan/Logic.h b/src/graph/planner/plan/Logic.h index c128031c811..286a2352364 100644 --- a/src/graph/planner/plan/Logic.h +++ b/src/graph/planner/plan/Logic.h @@ -11,6 +11,7 @@ namespace nebula { namespace graph { +// StartNode is a spetial leaf node that helps the scheduler to work properly. class StartNode final : public PlanNode { public: static StartNode* make(QueryContext* qctx) { @@ -47,6 +48,7 @@ class BinarySelect : public SingleInputNode { Expression* condition_{nullptr}; }; +// Select the if branch or else branch at runtime class Select final : public BinarySelect { public: static Select* make(QueryContext* qctx, @@ -92,6 +94,7 @@ class Select final : public BinarySelect { PlanNode* else_{nullptr}; }; +// Executing the branch multi times at runtime. class Loop final : public BinarySelect { public: static Loop* make(QueryContext* qctx, @@ -123,9 +126,7 @@ class Loop final : public BinarySelect { PlanNode* body_{nullptr}; }; -/** - * This operator is used for pass through situation. - */ +// This operator is used for pass through situation. class PassThroughNode final : public SingleInputNode { public: static PassThroughNode* make(QueryContext* qctx, PlanNode* input) { @@ -141,9 +142,7 @@ class PassThroughNode final : public SingleInputNode { void cloneMembers(const PassThroughNode&); }; -/** - * This operator is used for getting a named alias from another executed operator. - */ +// This operator is used for getting a named alias from another executed operator. class Argument final : public PlanNode { public: static Argument* make(QueryContext* qctx, std::string alias) { diff --git a/src/graph/planner/plan/Mutate.h b/src/graph/planner/plan/Mutate.h index f6ffc49ea07..a45d01dff69 100644 --- a/src/graph/planner/plan/Mutate.h +++ b/src/graph/planner/plan/Mutate.h @@ -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 { diff --git a/src/graph/planner/plan/PlanNode.h b/src/graph/planner/plan/PlanNode.h index 71ea608440d..774e57eed21 100644 --- a/src/graph/planner/plan/PlanNode.h +++ b/src/graph/planner/plan/PlanNode.h @@ -16,10 +16,8 @@ namespace graph { class PlanNodeVisitor; -/** - * PlanNode is an abstraction of nodes in an execution plan which - * is a kind of directed cyclic graph. - */ +// PlanNode is an abstraction of nodes in an execution plan which +// is a kind of directed cyclic graph. class PlanNode { public: enum class Kind : uint8_t { @@ -362,6 +360,7 @@ class SingleDependencyNode : public PlanNode { std::unique_ptr explain() const override; }; +// SingleInputNode has one dependency and it sinks data from the dependency. class SingleInputNode : public SingleDependencyNode { public: std::unique_ptr explain() const override; @@ -385,6 +384,7 @@ class SingleInputNode : public SingleDependencyNode { SingleInputNode(QueryContext* qctx, Kind kind, const PlanNode* dep); }; +// BinaryInputNode has two dependencies and it sinks data from them. class BinaryInputNode : public PlanNode { public: void setLeftDep(const PlanNode* left) { diff --git a/src/graph/planner/plan/Query.h b/src/graph/planner/plan/Query.h index 14d97f7ee38..76ca25acd9c 100644 --- a/src/graph/planner/plan/Query.h +++ b/src/graph/planner/plan/Query.h @@ -13,19 +13,15 @@ #include "parser/Clauses.h" #include "parser/TraverseSentences.h" -/** - * All query-related nodes would be put in this file, - * and they are derived from PlanNode. - */ +// All query-related nodes would be put in this file, +// and they are derived from PlanNode. namespace nebula { namespace graph { -/** - * Now we have four kind of exploration nodes: - * GetNeighbors, - * GetVertices, - * GetEdges, - * IndexScan - */ +// Now we have four kind of exploration nodes: +// GetNeighbors, +// GetVertices, +// GetEdges, +// IndexScan class Explore : public SingleInputNode { public: GraphSpaceID space() const { @@ -137,9 +133,8 @@ using EdgeProp = nebula::storage::cpp2::EdgeProp; using StatProp = nebula::storage::cpp2::StatProp; using Expr = nebula::storage::cpp2::Expr; using Direction = nebula::storage::cpp2::EdgeDirection; -/** - * Get neighbors' property - */ + +// Get neighbors' property class GetNeighbors : public Explore { public: static GetNeighbors* make(QueryContext* qctx, PlanNode* input, GraphSpaceID space) { @@ -263,9 +258,7 @@ class GetNeighbors : public Explore { bool random_{false}; }; -/** - * Get property with given vertex keys. - */ +// Get property with given vertex keys. class GetVertices : public Explore { public: static GetVertices* make(QueryContext* qctx, @@ -346,9 +339,7 @@ class GetVertices : public Explore { std::unique_ptr> exprs_; }; -/** - * Get property with given edge keys. - */ +// Get property with given edge keys. class GetEdges final : public Explore { public: static GetEdges* make(QueryContext* qctx, @@ -450,9 +441,7 @@ class GetEdges final : public Explore { std::unique_ptr> exprs_; }; -/** - * Read data through the index. - */ +// Read data through the index. class IndexScan : public Explore { public: using IndexQueryContext = storage::cpp2::IndexQueryContext; @@ -569,9 +558,7 @@ class IndexScan : public Explore { YieldColumns* yieldColumns_; }; -/** - * Scan vertices - */ +// Scan vertices class ScanVertices final : public Explore { public: static ScanVertices* make(QueryContext* qctx, @@ -636,9 +623,7 @@ class ScanVertices final : public Explore { std::unique_ptr> exprs_; }; -/** - * Scan edges - */ +// Scan edges class ScanEdges final : public Explore { public: static ScanEdges* make(QueryContext* qctx, @@ -703,9 +688,7 @@ class ScanEdges final : public Explore { std::unique_ptr> exprs_; }; -/** - * A Filter node helps filt some records with condition. - */ +// A Filter node helps filt some records with condition. class Filter final : public SingleInputNode { public: static Filter* make(QueryContext* qctx, @@ -742,12 +725,10 @@ class Filter final : public SingleInputNode { bool needStableFilter_; }; -/** - * Now we have three kind of set operations: - * UNION, - * INTERSECT, - * MINUS - */ +// Now we have three kind of set operations: +// UNION, +// INTERSECT, +// MINUS class SetOp : public BinaryInputNode { protected: SetOp(QueryContext* qctx, Kind kind, PlanNode* left, PlanNode* right) @@ -758,9 +739,7 @@ class SetOp : public BinaryInputNode { void cloneMembers(const SetOp&); }; -/** - * Combine two set of records. - */ +// Combine two set of records. class Union final : public SetOp { public: static Union* make(QueryContext* qctx, PlanNode* left, PlanNode* right) { @@ -776,9 +755,7 @@ class Union final : public SetOp { void cloneMembers(const Union&); }; -/** - * Return the intersected records between two sets. - */ +// Return the intersected records between two sets. class Intersect final : public SetOp { public: static Intersect* make(QueryContext* qctx, PlanNode* left, PlanNode* right) { @@ -794,9 +771,7 @@ class Intersect final : public SetOp { void cloneMembers(const Intersect&); }; -/** - * Do subtraction between two sets. - */ +// Do subtraction between two sets. class Minus final : public SetOp { public: static Minus* make(QueryContext* qctx, PlanNode* left, PlanNode* right) { @@ -812,9 +787,7 @@ class Minus final : public SetOp { void cloneMembers(const Minus&); }; -/** - * Project is used to specify output vars or field. - */ +// Project is used to specify output vars or field. class Project final : public SingleInputNode { public: static Project* make(QueryContext* qctx, PlanNode* input, YieldColumns* cols = nullptr) { @@ -839,6 +812,7 @@ class Project final : public SingleInputNode { YieldColumns* cols_{nullptr}; }; +// Thansforms a list to column. class Unwind final : public SingleInputNode { public: static Unwind* make(QueryContext* qctx, @@ -870,9 +844,7 @@ class Unwind final : public SingleInputNode { std::string alias_; }; -/** - * Sort the given record set. - */ +// Sort the given record set. class Sort final : public SingleInputNode { public: static Sort* make(QueryContext* qctx, @@ -916,9 +888,7 @@ class Sort final : public SingleInputNode { std::vector> factors_; }; -/** - * Output the records with the given limitation. - */ +// Output the records with the given limitation. class Limit final : public SingleInputNode { public: static Limit* make(QueryContext* qctx, PlanNode* input, int64_t offset = -1, int64_t count = -1) { @@ -976,9 +946,7 @@ class Limit final : public SingleInputNode { Expression* count_{nullptr}; }; -/** - * Get the Top N record set. - */ +// Get the Top N record set. class TopN final : public SingleInputNode { public: static TopN* make(QueryContext* qctx, @@ -1040,9 +1008,7 @@ class TopN final : public SingleInputNode { int64_t count_{-1}; }; -/** - * Sample the given input data. - */ +// Sample the given input data. class Sample final : public SingleInputNode { public: static Sample* make(QueryContext* qctx, PlanNode* input, const int64_t count) { @@ -1093,10 +1059,8 @@ class Sample final : public SingleInputNode { Expression* count_{nullptr}; }; -/** - * Do Aggregation with the given set of records, - * such as AVG(), COUNT()... - */ +// Do Aggregation with the given set of records, +// such as AVG(), COUNT()... class Aggregate final : public SingleInputNode { public: static Aggregate* make(QueryContext* qctx, @@ -1137,6 +1101,7 @@ class Aggregate final : public SingleInputNode { std::vector groupItems_; }; +// Change the space that specified for current session. class SwitchSpace final : public SingleInputNode { public: static SwitchSpace* make(QueryContext* qctx, PlanNode* input, std::string spaceName) { @@ -1162,6 +1127,7 @@ class SwitchSpace final : public SingleInputNode { std::string spaceName_; }; +// Dedup the rows. class Dedup final : public SingleInputNode { public: static Dedup* make(QueryContext* qctx, PlanNode* input) { @@ -1176,6 +1142,7 @@ class Dedup final : public SingleInputNode { void cloneMembers(const Dedup&); }; +// Collect the variable results. class DataCollect final : public VariableDependencyNode { public: enum class DCKind : uint8_t { @@ -1252,6 +1219,8 @@ class DataCollect final : public VariableDependencyNode { bool distinct_{false}; }; +// Join two result set based on the keys +// We have LeftJoin and InnerJoin now. class Join : public SingleDependencyNode { public: const std::pair& leftVar() const { @@ -1309,9 +1278,7 @@ class Join : public SingleDependencyNode { std::vector probeKeys_; }; -/* - * left join - */ +// Left join class LeftJoin final : public Join { public: static LeftJoin* make(QueryContext* qctx, @@ -1349,9 +1316,7 @@ class LeftJoin final : public Join { void cloneMembers(const LeftJoin&); }; -/* - * inner join - */ +// Inner join class InnerJoin final : public Join { public: static InnerJoin* make(QueryContext* qctx, @@ -1389,9 +1354,7 @@ class InnerJoin final : public Join { void cloneMembers(const InnerJoin&); }; -/* - * set var = value - */ +// Binding a value to a variable class Assign final : public SingleInputNode { public: static Assign* make(QueryContext* qctx, PlanNode* input) { @@ -1421,10 +1384,8 @@ class Assign final : public SingleInputNode { std::vector> items_; }; -/** - * Union all versions of the variable in the dependency - * The input is a single PlanNode - */ +// Union all versions of the variable in the dependency +// The input is a single PlanNode class UnionAllVersionVar final : public SingleInputNode { public: static UnionAllVersionVar* make(QueryContext* qctx, PlanNode* input) { @@ -1440,6 +1401,7 @@ class UnionAllVersionVar final : public SingleInputNode { void cloneMembers(const UnionAllVersionVar&); }; +// Traverse several steps based on condition. class Traverse final : public GetNeighbors { public: using VertexProps = std::unique_ptr>; @@ -1535,6 +1497,7 @@ class Traverse final : public GetNeighbors { bool trackPrevPath_{true}; }; +// Append vertices to a path. class AppendVertices final : public GetVertices { public: static AppendVertices* make(QueryContext* qctx, PlanNode* input, GraphSpaceID space) { @@ -1584,6 +1547,7 @@ class AppendVertices final : public GetVertices { bool trackPrevPath_{true}; }; +// Binary Join that joins two results from two inputs. class BiJoin : public BinaryInputNode { public: const std::vector& hashKeys() const { @@ -1621,9 +1585,7 @@ class BiJoin : public BinaryInputNode { std::vector probeKeys_; }; -/* - * left join - */ +// Left join class BiLeftJoin final : public BiJoin { public: static BiLeftJoin* make(QueryContext* qctx, @@ -1649,9 +1611,7 @@ class BiLeftJoin final : public BiJoin { void cloneMembers(const BiLeftJoin&); }; -/* - * inner join - */ +// Inner join class BiInnerJoin final : public BiJoin { public: static BiInnerJoin* make(QueryContext* qctx,