-
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.
Merge branch 'master' into format_lookup
- Loading branch information
Showing
56 changed files
with
981 additions
and
600 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* Copyright (c) 2021 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License, | ||
* attached with Common Clause Condition 1.0, found in the LICENSES directory. | ||
*/ | ||
|
||
#include "graph/planner/ngql/FetchVerticesPlanner.h" | ||
|
||
#include "graph/planner/plan/Query.h" | ||
#include "graph/util/PlannerUtil.h" | ||
|
||
namespace nebula { | ||
namespace graph { | ||
|
||
std::unique_ptr<FetchVerticesPlanner::VertexProps> FetchVerticesPlanner::buildVertexProps( | ||
const ExpressionProps::TagIDPropsMap& propsMap) { | ||
if (propsMap.empty()) { | ||
return nullptr; | ||
} | ||
auto vertexProps = std::make_unique<VertexProps>(propsMap.size()); | ||
auto fun = [](auto& tag) { | ||
VertexProp vp; | ||
vp.set_tag(tag.first); | ||
std::vector<std::string> props(tag.second.begin(), tag.second.end()); | ||
vp.set_props(std::move(props)); | ||
return vp; | ||
}; | ||
std::transform(propsMap.begin(), propsMap.end(), vertexProps->begin(), fun); | ||
return vertexProps; | ||
} | ||
|
||
StatusOr<SubPlan> FetchVerticesPlanner::transform(AstContext* astCtx) { | ||
fetchCtx_ = static_cast<FetchVerticesContext*>(astCtx); | ||
auto qctx = fetchCtx_->qctx; | ||
auto space = fetchCtx_->space; | ||
auto& starts = fetchCtx_->from; | ||
|
||
std::string vidsVar; | ||
if (!starts.vids.empty() && starts.originalSrc == nullptr) { | ||
PlannerUtil::buildConstantInput(qctx, starts, vidsVar); | ||
} else { | ||
starts.src = starts.originalSrc; | ||
if (starts.fromType == kVariable) { | ||
vidsVar = starts.userDefinedVarName; | ||
} else { | ||
vidsVar = fetchCtx_->inputVarName; | ||
} | ||
} | ||
|
||
SubPlan subPlan; | ||
auto* getVertices = GetVertices::make(qctx, | ||
nullptr, | ||
space.id, | ||
starts.src, | ||
buildVertexProps(fetchCtx_->exprProps.tagProps()), | ||
{}, | ||
fetchCtx_->distinct); | ||
getVertices->setInputVar(vidsVar); | ||
|
||
subPlan.root = Project::make(qctx, getVertices, fetchCtx_->yieldExpr); | ||
if (fetchCtx_->distinct) { | ||
subPlan.root = Dedup::make(qctx, subPlan.root); | ||
} | ||
subPlan.tail = getVertices; | ||
return subPlan; | ||
} | ||
|
||
} // 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,43 @@ | ||
/* Copyright (c) 2021 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License, | ||
* attached with Common Clause Condition 1.0, found in the LICENSES directory. | ||
*/ | ||
|
||
#ifndef GRAPH_PLANNER_NGQL_FETCH_VERTICES_PLANNER_H_ | ||
#define GRAPH_PLANNER_NGQL_FETCH_VERTICES_PLANNER_H_ | ||
|
||
#include "common/base/Base.h" | ||
#include "graph/context/ast/QueryAstContext.h" | ||
#include "graph/planner/Planner.h" | ||
#include "graph/planner/plan/PlanNode.h" | ||
|
||
namespace nebula { | ||
namespace graph { | ||
class FetchVerticesPlanner final : public Planner { | ||
public: | ||
using VertexProp = nebula::storage::cpp2::VertexProp; | ||
using VertexProps = std::vector<VertexProp>; | ||
|
||
static std::unique_ptr<FetchVerticesPlanner> make() { | ||
return std::unique_ptr<FetchVerticesPlanner>(new FetchVerticesPlanner()); | ||
} | ||
|
||
static bool match(AstContext* astCtx) { | ||
return astCtx->sentence->kind() == Sentence::Kind::kFetchVertices; | ||
} | ||
|
||
StatusOr<SubPlan> transform(AstContext* astCtx) override; | ||
|
||
private: | ||
std::unique_ptr<VertexProps> buildVertexProps(const ExpressionProps::TagIDPropsMap& propsMap); | ||
|
||
private: | ||
FetchVerticesPlanner() = default; | ||
|
||
FetchVerticesContext* fetchCtx_{nullptr}; | ||
}; | ||
} // namespace graph | ||
} // namespace nebula | ||
|
||
#endif // GRAPH_PLANNER_NGQL_FETCH_VERTICES_PLANNER_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
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
Oops, something went wrong.