Skip to content

Commit

Permalink
Fix after #4146
Browse files Browse the repository at this point in the history
OptGroup was refactored in #4146
  • Loading branch information
wey-gu committed May 27, 2022
1 parent 030eabb commit 0726413
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/graph/optimizer/rule/GetEdgesTransformLimitRule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,16 @@ StatusOr<OptRule::TransformResult> GetEdgesTransformLimitRule::transform(

auto newProject = project->clone();
auto newProjectGroupNode = OptGroupNode::create(ctx, newProject, projectGroupNode->group());
newProject->setOutputVar(project->outputVar());

auto limitGroupNode = matched.dependencies.front().node;
auto limit = static_cast<const Limit *>(limitGroupNode->node());

auto newLimit = limit->clone();
auto newLimitGroup = OptGroup::create(ctx);
auto newLimitGroupNode = newLimitGroup->makeGroupNode(newLimit);
newLimit->setOutputVar(limit->outputVar());
newProject->setInputVar(newLimit->outputVar());

newProjectGroupNode->dependsOn(newLimitGroup);

Expand All @@ -99,6 +102,8 @@ StatusOr<OptRule::TransformResult> GetEdgesTransformLimitRule::transform(
auto newAppendVertices = appendVertices->clone();
auto newAppendVerticesGroup = OptGroup::create(ctx);
auto colSize = appendVertices->colNames().size();
newAppendVertices->setOutputVar(appendVertices->outputVar());
newLimit->setInputVar(appendVertices->outputVar());
newAppendVertices->setColNames(
{appendVertices->colNames()[colSize - 2], appendVertices->colNames()[colSize - 1]});
auto newAppendVerticesGroupNode = newAppendVerticesGroup->makeGroupNode(newAppendVertices);
Expand Down
2 changes: 1 addition & 1 deletion src/graph/optimizer/rule/GetEdgesTransformLimitRule.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace opt {
// 1. Match the pattern
// Benefits:
// 1. Avoid doing Traverse to optimize performance
// Quey example:
// Query example:
// 1. match ()-[e]->() return e limit 1
//
// Tranformation:
Expand Down
2 changes: 2 additions & 0 deletions src/graph/optimizer/rule/GetEdgesTransformRule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ StatusOr<OptRule::TransformResult> GetEdgesTransformRule::transform(

auto newProject = project->clone();
auto newProjectGroupNode = OptGroupNode::create(ctx, newProject, projectGroupNode->group());
newProject->setOutputVar(project->outputVar());

auto appendVerticesGroupNode = matched.dependencies.front().node;
auto appendVertices = static_cast<const AppendVertices *>(appendVerticesGroupNode->node());
Expand All @@ -85,6 +86,7 @@ StatusOr<OptRule::TransformResult> GetEdgesTransformRule::transform(
auto newAppendVerticesGroup = OptGroup::create(ctx);
auto colSize = appendVertices->colNames().size();
newAppendVertices->setOutputVar(appendVertices->outputVar());
newProject->setInputVar(newAppendVertices->outputVar());
newAppendVertices->setColNames(
{appendVertices->colNames()[colSize - 2], appendVertices->colNames()[colSize - 1]});
auto newAppendVerticesGroupNode = newAppendVerticesGroup->makeGroupNode(newAppendVertices);
Expand Down
2 changes: 2 additions & 0 deletions src/graph/optimizer/rule/GetEdgesTransformRule.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class PlanNode;
namespace opt {

// Convert [[ScanVertices]] to [[ScanEdges]] in certain cases
// Note: match ()-[e]->() return e limit 3
// will be handed seperately in GetEdgesTransformLimitRule
// Required conditions:
// 1. Match the pattern
// Benefits:
Expand Down

0 comments on commit 0726413

Please sign in to comment.