-
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 sequential
- Loading branch information
Showing
22 changed files
with
384 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* Copyright (c) 2021 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License. | ||
*/ | ||
|
||
#include "graph/optimizer/rule/EliminateRowCollectRule.h" | ||
|
||
#include "graph/optimizer/OptContext.h" | ||
#include "graph/optimizer/OptGroup.h" | ||
#include "graph/planner/plan/PlanNode.h" | ||
#include "graph/planner/plan/Query.h" | ||
|
||
using nebula::graph::DataCollect; | ||
using nebula::graph::PlanNode; | ||
using nebula::graph::Project; | ||
using nebula::graph::QueryContext; | ||
|
||
namespace nebula { | ||
namespace opt { | ||
|
||
std::unique_ptr<OptRule> EliminateRowCollectRule::kInstance = | ||
std::unique_ptr<EliminateRowCollectRule>(new EliminateRowCollectRule()); | ||
|
||
EliminateRowCollectRule::EliminateRowCollectRule() { | ||
RuleSet::QueryRules().addRule(this); | ||
} | ||
|
||
// TODO match DataCollect->(Any Node with real result) | ||
const Pattern& EliminateRowCollectRule::pattern() const { | ||
static Pattern pattern = Pattern::create(graph::PlanNode::Kind::kDataCollect, | ||
{Pattern::create(graph::PlanNode::Kind::kProject)}); | ||
return pattern; | ||
} | ||
|
||
bool EliminateRowCollectRule::match(OptContext* octx, const MatchedResult& matched) const { | ||
if (!OptRule::match(octx, matched)) { | ||
return false; | ||
} | ||
const auto* collectNode = static_cast<const DataCollect*>(matched.node->node()); | ||
if (collectNode->kind() != DataCollect::DCKind::kRowBasedMove) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
StatusOr<OptRule::TransformResult> EliminateRowCollectRule::transform( | ||
OptContext* octx, const MatchedResult& matched) const { | ||
auto dataCollectGroupNode = matched.node; | ||
auto projGroupNode = matched.dependencies.front().node; | ||
|
||
const auto dataCollect = static_cast<const DataCollect*>(dataCollectGroupNode->node()); | ||
const auto proj = static_cast<const Project*>(projGroupNode->node()); | ||
|
||
auto newProj = static_cast<Project*>(proj->clone()); | ||
newProj->setOutputVar(dataCollect->outputVar()); | ||
auto newProjGroupNode = OptGroupNode::create(octx, newProj, dataCollectGroupNode->group()); | ||
|
||
for (auto dep : projGroupNode->dependencies()) { | ||
newProjGroupNode->dependsOn(dep); | ||
} | ||
|
||
TransformResult result; | ||
result.eraseAll = true; | ||
result.newGroupNodes.emplace_back(newProjGroupNode); | ||
return result; | ||
} | ||
|
||
std::string EliminateRowCollectRule::toString() const { | ||
return "EliminateRowCollectRule"; | ||
} | ||
|
||
} // namespace opt | ||
} // 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,30 @@ | ||
/* Copyright (c) 2021 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "graph/optimizer/OptRule.h" | ||
|
||
namespace nebula { | ||
namespace opt { | ||
|
||
class EliminateRowCollectRule final : public OptRule { | ||
public: | ||
const Pattern &pattern() const override; | ||
|
||
bool match(OptContext *ctx, const MatchedResult &matched) const override; | ||
|
||
StatusOr<TransformResult> transform(OptContext *ctx, const MatchedResult &matched) const override; | ||
|
||
std::string toString() const override; | ||
|
||
private: | ||
EliminateRowCollectRule(); | ||
|
||
static std::unique_ptr<OptRule> kInstance; | ||
}; | ||
|
||
} // namespace opt | ||
} // 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
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
Oops, something went wrong.