You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/07/15 10:35:44 UTC

[GitHub] [doris] englefly opened a new pull request, #10891: [refactor] Memo.copyIn() return a pair

englefly opened a new pull request, #10891:
URL: https://github.com/apache/doris/pull/10891

   # Proposed changes
   
   Issue Number: close #xxx
   
   ## Problem Summary:
   
   Describe the overview of changes.
   
   ## Checklist(Required)
   
   1. Does it affect the original behavior: (Yes/No/I Don't know)
   2. Has unit tests been added: (Yes/No/No Need)
   3. Has document been added or modified: (Yes/No/No Need)
   4. Does it need to update dependencies: (Yes/No)
   5. Are there any changes that cannot be rolled back: (Yes/No)
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at [dev@doris.apache.org](mailto:dev@doris.apache.org) by explaining why you chose the solution you did and what alternatives you considered, etc...
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] morrySnow commented on a diff in pull request #10891: [refactor] Memo.copyIn() return a pair

Posted by GitBox <gi...@apache.org>.
morrySnow commented on code in PR #10891:
URL: https://github.com/apache/doris/pull/10891#discussion_r922140493


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/memo/Memo.java:
##########
@@ -82,13 +83,15 @@ public GroupExpression copyIn(Plan node, @Nullable Group target, boolean rewrite
             } else if (child.getGroupExpression().isPresent()) {
                 childrenGroups.add(child.getGroupExpression().get().getParent());
             } else {
-                childrenGroups.add(copyIn(child, null, rewrite).getParent());
+                childrenGroups.add(copyIn(child, null, rewrite).second.getParent());
             }
         }
         node = replaceChildrenToGroupPlan(node, childrenGroups);
         GroupExpression newGroupExpression = new GroupExpression(node);
         newGroupExpression.setChildren(childrenGroups);
-        return insertOrRewriteGroupExpression(newGroupExpression, target, rewrite, node.getLogicalProperties());
+        newGroupExpression = insertOrRewriteGroupExpression(newGroupExpression, target, rewrite,

Review Comment:
   insertOrRewriteGroupExpression could also return exist group expression



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/cascades/ApplyRuleJob.java:
##########
@@ -63,7 +63,7 @@ public void execute() throws AnalysisException {
             List<Plan> newPlans = rule.transform(plan, context.getPlannerContext());
             for (Plan newPlan : newPlans) {
                 GroupExpression newGroupExpression = context.getPlannerContext().getMemo()
-                        .copyIn(newPlan, groupExpression.getParent(), rule.isRewrite());
+                        .copyIn(newPlan, groupExpression.getParent(), rule.isRewrite()).second;

Review Comment:
   when we return a exist group expression, maybe we could just return



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] 924060929 merged pull request #10891: [refactor] (Nereids) Memo.copyIn() return a pair

Posted by GitBox <gi...@apache.org>.
924060929 merged PR #10891:
URL: https://github.com/apache/doris/pull/10891


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] morrySnow commented on a diff in pull request #10891: [refactor] Memo.copyIn() return a pair

Posted by GitBox <gi...@apache.org>.
morrySnow commented on code in PR #10891:
URL: https://github.com/apache/doris/pull/10891#discussion_r923315243


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/memo/Memo.java:
##########
@@ -69,10 +70,10 @@ public Map<GroupExpression, GroupExpression> getGroupExpressions() {
      * @param rewrite whether to rewrite the node to the target group
      * @return Reference of node in Memo
      */
-    public GroupExpression copyIn(Plan node, @Nullable Group target, boolean rewrite) {
+    public Pair<Boolean, GroupExpression> copyIn(Plan node, @Nullable Group target, boolean rewrite) {
         Optional<GroupExpression> groupExpr = node.getGroupExpression();
         if (!rewrite && groupExpr.isPresent() && groupExpressions.containsKey(groupExpr.get())) {
-            return groupExpr.get();
+            return new Pair(true, groupExpr.get());

Review Comment:
   i think it is better to use `true` represent insert a new GroupExpression



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/rewrite/RewriteBottomUpJob.java:
##########
@@ -81,11 +82,14 @@ public void execute() throws AnalysisException {
                 Preconditions.checkArgument(afters.size() == 1);
                 Plan after = afters.get(0);
                 if (after != before) {
-                    GroupExpression groupExpr = context.getPlannerContext()
+                    Pair<Boolean, GroupExpression> pair = context.getPlannerContext()
                             .getMemo()
                             .copyIn(after, group, rule.isRewrite());
+                    GroupExpression groupExpr = pair.second;
                     groupExpr.setApplied(rule);

Review Comment:
   we need move this line out of the inner for loop, i.e. after Line 91



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/rewrite/RewriteTopDownJob.java:
##########
@@ -72,9 +73,10 @@ public void execute() {
                 Preconditions.checkArgument(afters.size() == 1);
                 Plan after = afters.get(0);
                 if (after != before) {
-                    GroupExpression expression = context.getPlannerContext()
+                    Pair<Boolean, GroupExpression> pair = context.getPlannerContext()
                             .getMemo().copyIn(after, group, rule.isRewrite());
-                    expression.setApplied(rule);
+

Review Comment:
   i think if we return a exists GroupExpression, we should skip Line 80 and 81



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/jobs/rewrite/RewriteTopDownJob.java:
##########
@@ -72,9 +73,10 @@ public void execute() {
                 Preconditions.checkArgument(afters.size() == 1);
                 Plan after = afters.get(0);
                 if (after != before) {
-                    GroupExpression expression = context.getPlannerContext()
+                    Pair<Boolean, GroupExpression> pair = context.getPlannerContext()
                             .getMemo().copyIn(after, group, rule.isRewrite());
-                    expression.setApplied(rule);
+
+                    pair.second.setApplied(rule);

Review Comment:
   we need move this line out of the inner for loop, i.e. after Line 81



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/memo/Memo.java:
##########
@@ -69,10 +70,10 @@ public Map<GroupExpression, GroupExpression> getGroupExpressions() {
      * @param rewrite whether to rewrite the node to the target group
      * @return Reference of node in Memo
      */
-    public GroupExpression copyIn(Plan node, @Nullable Group target, boolean rewrite) {
+    public Pair<Boolean, GroupExpression> copyIn(Plan node, @Nullable Group target, boolean rewrite) {

Review Comment:
   please modify return comment in java doc



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/memo/Memo.java:
##########
@@ -120,14 +122,14 @@ private Plan groupToTreeNode(Group group) {
      * @param rewrite whether to rewrite the groupExpression to target group
      * @return existing groupExpression in memo or newly generated groupExpression
      */
-    private GroupExpression insertOrRewriteGroupExpression(GroupExpression groupExpression, Group target,
-            boolean rewrite, LogicalProperties logicalProperties) {
+    private Pair<Boolean, GroupExpression> insertOrRewriteGroupExpression(GroupExpression groupExpression, Group target,

Review Comment:
   please modify return comment in java doc



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] englefly closed pull request #10891: [refactor] Memo.copyIn() return a pair

Posted by GitBox <gi...@apache.org>.
englefly closed pull request #10891: [refactor]  Memo.copyIn() return a pair<exists, GroupExpression>
URL: https://github.com/apache/doris/pull/10891


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] morrySnow commented on pull request #10891: [refactor] (Nereids) Memo.copyIn() return a pair

Posted by GitBox <gi...@apache.org>.
morrySnow commented on PR #10891:
URL: https://github.com/apache/doris/pull/10891#issuecomment-1190545629

   merge master code please~
   BTW, chinese parenthesis in title 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org