You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2020/07/19 09:18:25 UTC

[GitHub] [calcite] Aaaaaaron opened a new pull request #2076: [CALCITE-4111] Remove VolcanoPlannerPhase in Planner (Jiatao Tao)

Aaaaaaron opened a new pull request #2076:
URL: https://github.com/apache/calcite/pull/2076


   


----------------------------------------------------------------
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.

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



[GitHub] [calcite] Aaaaaaron commented on a change in pull request #2076: [CALCITE-4111] Remove VolcanoPlannerPhase in Planner (Jiatao Tao)

Posted by GitBox <gi...@apache.org>.
Aaaaaaron commented on a change in pull request #2076:
URL: https://github.com/apache/calcite/pull/2076#discussion_r457812900



##########
File path: core/src/main/java/org/apache/calcite/plan/volcano/IterativeRuleQueue.java
##########
@@ -101,51 +63,31 @@
    */
   @Override public boolean clear() {
     boolean empty = true;
-    for (PhaseMatchList matchList : matchListMap.values()) {
-      if (!matchList.queue.isEmpty() || !matchList.preQueue.isEmpty()) {
-        empty = false;
-      }
-      matchList.clear();
+    if (!matchList.queue.isEmpty() || !matchList.preQueue.isEmpty()) {
+      empty = false;
     }
+    matchList.clear();
     return !empty;
   }
 
-  /**
-   * Removes the {@link PhaseMatchList rule-match list} for the given planner
-   * phase.
-   */
-  public void phaseCompleted(VolcanoPlannerPhase phase) {
-    matchListMap.get(phase).clear();
-  }
-
   /**
    * Adds a rule match. The rule-matches are automatically added to all
-   * existing {@link PhaseMatchList per-phase rule-match lists} which allow
+   * existing {@link MatchList per-phase rule-match lists} which allow
    * the rule referenced by the match.
    */
   public void addMatch(VolcanoRuleMatch match) {
     final String matchName = match.toString();
-    for (PhaseMatchList matchList : matchListMap.values()) {
-      Set<String> phaseRuleSet = phaseRuleMapping.get(matchList.phase);
-      if (phaseRuleSet != ALL_RULES) {
-        String ruleDescription = match.getRule().toString();
-        if (!phaseRuleSet.contains(ruleDescription)) {
-          continue;
-        }
-      }
 
-      if (!matchList.names.add(matchName)) {
-        // Identical match has already been added.
-        continue;
-      }
+    if (!matchList.names.add(matchName)) {
+      // Identical match has already been added.
+      return;
+    }
 
-      LOGGER.trace("{} Rule-match queued: {}", matchList.phase.toString(), matchName);
+    LOGGER.trace("{} Rule-match queued: {}", matchList.toString(), matchName);

Review comment:
       > You don't want to log matchlist. Remove the first argument.
   
   Thanks for your suggestion, Revised.




----------------------------------------------------------------
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.

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



[GitHub] [calcite] hsyuan commented on a change in pull request #2076: [CALCITE-4111] Remove VolcanoPlannerPhase in Planner (Jiatao Tao)

Posted by GitBox <gi...@apache.org>.
hsyuan commented on a change in pull request #2076:
URL: https://github.com/apache/calcite/pull/2076#discussion_r459869069



##########
File path: core/src/main/java/org/apache/calcite/plan/volcano/IterativeRuleQueue.java
##########
@@ -101,51 +63,31 @@
    */
   @Override public boolean clear() {
     boolean empty = true;
-    for (PhaseMatchList matchList : matchListMap.values()) {
-      if (!matchList.queue.isEmpty() || !matchList.preQueue.isEmpty()) {
-        empty = false;
-      }
-      matchList.clear();
+    if (!matchList.queue.isEmpty() || !matchList.preQueue.isEmpty()) {
+      empty = false;
     }
+    matchList.clear();
     return !empty;
   }
 
-  /**
-   * Removes the {@link PhaseMatchList rule-match list} for the given planner
-   * phase.
-   */
-  public void phaseCompleted(VolcanoPlannerPhase phase) {
-    matchListMap.get(phase).clear();
-  }
-
   /**
    * Adds a rule match. The rule-matches are automatically added to all
-   * existing {@link PhaseMatchList per-phase rule-match lists} which allow
+   * existing {@link MatchList per-phase rule-match lists} which allow

Review comment:
       There is no phase anymore, you need to update the comment




----------------------------------------------------------------
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.

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



[GitHub] [calcite] hsyuan commented on a change in pull request #2076: [CALCITE-4111] Remove VolcanoPlannerPhase in Planner (Jiatao Tao)

Posted by GitBox <gi...@apache.org>.
hsyuan commented on a change in pull request #2076:
URL: https://github.com/apache/calcite/pull/2076#discussion_r457807922



##########
File path: core/src/main/java/org/apache/calcite/plan/volcano/IterativeRuleDriver.java
##########
@@ -22,11 +22,11 @@
 import org.slf4j.Logger;
 
 /***
- * <p>The algorithm executes repeatedly in a series of phases. In each phase
- * the exact rules that may be fired varies. The mapping of phases to rule
- * sets is maintained in the {@link #ruleQueue}.
+ * <p>The algorithm executes repeatedly.
+ * The exact rules that may be fired varies.
+ * The rule sets is maintained in the {@link #ruleQueue}.

Review comment:
       Remove this sentence. It is not needed anymore.

##########
File path: core/src/main/java/org/apache/calcite/plan/volcano/IterativeRuleQueue.java
##########
@@ -101,51 +63,31 @@
    */
   @Override public boolean clear() {
     boolean empty = true;
-    for (PhaseMatchList matchList : matchListMap.values()) {
-      if (!matchList.queue.isEmpty() || !matchList.preQueue.isEmpty()) {
-        empty = false;
-      }
-      matchList.clear();
+    if (!matchList.queue.isEmpty() || !matchList.preQueue.isEmpty()) {
+      empty = false;
     }
+    matchList.clear();
     return !empty;
   }
 
-  /**
-   * Removes the {@link PhaseMatchList rule-match list} for the given planner
-   * phase.
-   */
-  public void phaseCompleted(VolcanoPlannerPhase phase) {
-    matchListMap.get(phase).clear();
-  }
-
   /**
    * Adds a rule match. The rule-matches are automatically added to all
-   * existing {@link PhaseMatchList per-phase rule-match lists} which allow
+   * existing {@link MatchList per-phase rule-match lists} which allow
    * the rule referenced by the match.
    */
   public void addMatch(VolcanoRuleMatch match) {
     final String matchName = match.toString();
-    for (PhaseMatchList matchList : matchListMap.values()) {
-      Set<String> phaseRuleSet = phaseRuleMapping.get(matchList.phase);
-      if (phaseRuleSet != ALL_RULES) {
-        String ruleDescription = match.getRule().toString();
-        if (!phaseRuleSet.contains(ruleDescription)) {
-          continue;
-        }
-      }
 
-      if (!matchList.names.add(matchName)) {
-        // Identical match has already been added.
-        continue;
-      }
+    if (!matchList.names.add(matchName)) {
+      // Identical match has already been added.
+      return;
+    }
 
-      LOGGER.trace("{} Rule-match queued: {}", matchList.phase.toString(), matchName);
+    LOGGER.trace("{} Rule-match queued: {}", matchList.toString(), matchName);

Review comment:
       You don't want to log matchlist. Remove the first argument.




----------------------------------------------------------------
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.

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



[GitHub] [calcite] hsyuan commented on a change in pull request #2076: [CALCITE-4111] Remove VolcanoPlannerPhase in Planner (Jiatao Tao)

Posted by GitBox <gi...@apache.org>.
hsyuan commented on a change in pull request #2076:
URL: https://github.com/apache/calcite/pull/2076#discussion_r460609784



##########
File path: core/src/main/java/org/apache/calcite/plan/volcano/IterativeRuleQueue.java
##########
@@ -43,56 +40,21 @@
 
   private static final Logger LOGGER = CalciteTrace.getPlannerTracer();
 
-  private static final Set<String> ALL_RULES = ImmutableSet.of("<ALL RULES>");
-
   //~ Instance fields --------------------------------------------------------
 
   /**
-   * Map of {@link VolcanoPlannerPhase} to a list of rule-matches. Initially,
-   * there is an empty {@link PhaseMatchList} for each planner phase. As the
+   * A list of rule-matches.
+   * Initially, there is an empty {@link MatchList}. As the
    * planner invokes {@link #addMatch(VolcanoRuleMatch)} the rule-match is
-   * added to the appropriate PhaseMatchList(s). As the planner completes
-   * phases, the matching entry is removed from this list to avoid unused
-   * work.
-   */
-  final Map<VolcanoPlannerPhase, PhaseMatchList> matchListMap =
-      new EnumMap<>(VolcanoPlannerPhase.class);
-
-  /**
-   * Maps a {@link VolcanoPlannerPhase} to a set of rule descriptions. Named rules
-   * may be invoked in their corresponding phase.
-   *
-   * <p>See {@link VolcanoPlannerPhaseRuleMappingInitializer} for more
-   * information regarding the contents of this Map and how it is initialized.
+   * added to the appropriate MatchList(s). As the planner completes the match,
+   * the matching entry is removed from this list to avoid unused work.
    */
-  private final Map<VolcanoPlannerPhase, Set<String>> phaseRuleMapping;

Review comment:
       You have to keep the set, to avoid duplicate rulematch adding into the queue.




----------------------------------------------------------------
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.

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



[GitHub] [calcite] Aaaaaaron commented on a change in pull request #2076: [CALCITE-4111] Remove VolcanoPlannerPhase in Planner (Jiatao Tao)

Posted by GitBox <gi...@apache.org>.
Aaaaaaron commented on a change in pull request #2076:
URL: https://github.com/apache/calcite/pull/2076#discussion_r457812692



##########
File path: core/src/main/java/org/apache/calcite/plan/volcano/IterativeRuleDriver.java
##########
@@ -22,11 +22,11 @@
 import org.slf4j.Logger;
 
 /***
- * <p>The algorithm executes repeatedly in a series of phases. In each phase
- * the exact rules that may be fired varies. The mapping of phases to rule
- * sets is maintained in the {@link #ruleQueue}.
+ * <p>The algorithm executes repeatedly.
+ * The exact rules that may be fired varies.
+ * The rule sets is maintained in the {@link #ruleQueue}.

Review comment:
       Revised




----------------------------------------------------------------
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.

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



[GitHub] [calcite] Aaaaaaron commented on a change in pull request #2076: [CALCITE-4111] Remove VolcanoPlannerPhase in Planner (Jiatao Tao)

Posted by GitBox <gi...@apache.org>.
Aaaaaaron commented on a change in pull request #2076:
URL: https://github.com/apache/calcite/pull/2076#discussion_r457812998



##########
File path: core/src/main/java/org/apache/calcite/plan/volcano/IterativeRuleQueue.java
##########
@@ -101,51 +63,31 @@
    */
   @Override public boolean clear() {
     boolean empty = true;
-    for (PhaseMatchList matchList : matchListMap.values()) {
-      if (!matchList.queue.isEmpty() || !matchList.preQueue.isEmpty()) {
-        empty = false;
-      }
-      matchList.clear();
+    if (!matchList.queue.isEmpty() || !matchList.preQueue.isEmpty()) {
+      empty = false;
     }
+    matchList.clear();
     return !empty;
   }
 
-  /**
-   * Removes the {@link PhaseMatchList rule-match list} for the given planner
-   * phase.
-   */
-  public void phaseCompleted(VolcanoPlannerPhase phase) {
-    matchListMap.get(phase).clear();
-  }
-
   /**
    * Adds a rule match. The rule-matches are automatically added to all
-   * existing {@link PhaseMatchList per-phase rule-match lists} which allow
+   * existing {@link MatchList per-phase rule-match lists} which allow
    * the rule referenced by the match.
    */
   public void addMatch(VolcanoRuleMatch match) {
     final String matchName = match.toString();
-    for (PhaseMatchList matchList : matchListMap.values()) {
-      Set<String> phaseRuleSet = phaseRuleMapping.get(matchList.phase);
-      if (phaseRuleSet != ALL_RULES) {
-        String ruleDescription = match.getRule().toString();
-        if (!phaseRuleSet.contains(ruleDescription)) {
-          continue;
-        }
-      }
 
-      if (!matchList.names.add(matchName)) {
-        // Identical match has already been added.
-        continue;
-      }
+    if (!matchList.names.add(matchName)) {
+      // Identical match has already been added.
+      return;
+    }
 
-      LOGGER.trace("{} Rule-match queued: {}", matchList.phase.toString(), matchName);
+    LOGGER.trace("{} Rule-match queued: {}", matchList.toString(), matchName);

Review comment:
       > You don't want to log matchlist. Remove the first argument.
   
   Thanks for your suggestion, Revised.




----------------------------------------------------------------
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.

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



[GitHub] [calcite] Aaaaaaron commented on a change in pull request #2076: [CALCITE-4111] Remove VolcanoPlannerPhase in Planner (Jiatao Tao)

Posted by GitBox <gi...@apache.org>.
Aaaaaaron commented on a change in pull request #2076:
URL: https://github.com/apache/calcite/pull/2076#discussion_r457812834



##########
File path: core/src/main/java/org/apache/calcite/plan/volcano/IterativeRuleDriver.java
##########
@@ -22,11 +22,11 @@
 import org.slf4j.Logger;
 
 /***
- * <p>The algorithm executes repeatedly in a series of phases. In each phase
- * the exact rules that may be fired varies. The mapping of phases to rule
- * sets is maintained in the {@link #ruleQueue}.
+ * <p>The algorithm executes repeatedly.
+ * The exact rules that may be fired varies.
+ * The rule sets is maintained in the {@link #ruleQueue}.

Review comment:
       > Remove this sentence. It is not needed anymore.
   
   Thanks for your suggestion, Revised.




----------------------------------------------------------------
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.

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



[GitHub] [calcite] hsyuan closed pull request #2076: [CALCITE-4111] Remove VolcanoPlannerPhase in Planner (Jiatao Tao)

Posted by GitBox <gi...@apache.org>.
hsyuan closed pull request #2076:
URL: https://github.com/apache/calcite/pull/2076


   


----------------------------------------------------------------
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.

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