Skip to content

Commit

Permalink
optimize rewrite visitor (#3053)
Browse files Browse the repository at this point in the history
Co-authored-by: cpw <13495049+CPWstatic@users.noreply.github.com>
  • Loading branch information
czpmango and CPWstatic committed Nov 24, 2021
1 parent 6541438 commit b7c6901
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/graph/validator/GroupByValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Status GroupByValidator::validateYield(const YieldClause* yieldClause) {
needGenProject_ = true;
}
if (!aggs.empty()) {
auto* colRewrited = ExpressionUtils::rewriteAgg2VarProp(colExpr);
auto* colRewrited = ExpressionUtils::rewriteAgg2VarProp(colExpr->clone());
projCols_->addColumn(new YieldColumn(colRewrited, colOldName));
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions src/graph/validator/MatchValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -732,8 +732,8 @@ Status MatchValidator::validateGroup(YieldClauseContext &yieldCtx) const {
yieldCtx.aggOutputColumnNames_.emplace_back(agg->toString());
}
if (!aggs.empty()) {
auto *rewrittenExpr = ExpressionUtils::rewriteAgg2VarProp(colExpr);
yieldCtx.projCols_->addColumn(new YieldColumn(rewrittenExpr, colOldName));
auto *rewritedExpr = ExpressionUtils::rewriteAgg2VarProp(colExpr->clone());
yieldCtx.projCols_->addColumn(new YieldColumn(rewritedExpr, colOldName));
yieldCtx.projOutputColumnNames_.emplace_back(colOldName);
continue;
}
Expand Down
12 changes: 6 additions & 6 deletions src/graph/visitor/RewriteVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,9 @@ Expression *RewriteVisitor::transform(const Expression *expr, Matcher matcher, R
return rewriter(expr);
} else {
RewriteVisitor visitor(std::move(matcher), std::move(rewriter));
auto exprCopy = expr->clone();
exprCopy->accept(&visitor);
return exprCopy;
auto *e = const_cast<Expression *>(expr);
e->accept(&visitor);
return e;
}
}

Expand All @@ -339,9 +339,9 @@ Expression *RewriteVisitor::transform(
return rewriter(expr);
} else {
RewriteVisitor visitor(std::move(matcher), std::move(rewriter), std::move(needVisitedTypes));
auto exprCopy = expr->clone();
exprCopy->accept(&visitor);
return exprCopy;
auto *e = const_cast<Expression *>(expr);
e->accept(&visitor);
return e;
}
}
} // namespace graph
Expand Down

0 comments on commit b7c6901

Please sign in to comment.