[GitHub] [calcite] hsyuan commented on a change in pull request #1869: [CALCITE-3868] Remove redundant ruleSet and ruleNames in VolcanoPlanner

2020-03-27 Thread GitBox
hsyuan commented on a change in pull request #1869: [CALCITE-3868] Remove 
redundant ruleSet and ruleNames in VolcanoPlanner
URL: https://github.com/apache/calcite/pull/1869#discussion_r399585261
 
 

 ##
 File path: 
core/src/main/java/org/apache/calcite/plan/AbstractRelOptPlanner.java
 ##
 @@ -44,18 +44,13 @@
  * Abstract base for implementations of the {@link RelOptPlanner} interface.
  */
 public abstract class AbstractRelOptPlanner implements RelOptPlanner {
-  //~ Static fields/initializers -
-
-  /** Regular expression for integer. */
-  private static final Pattern INTEGER_PATTERN = Pattern.compile("[0-9]+");
-
   //~ Instance fields 
 
   /**
* Maps rule description to rule, just to ensure that rules' descriptions
* are unique.
*/
-  private final Map mapDescToRule = new HashMap<>();
+  protected final Map mapDescToRule = new HashMap<>();
 
 Review comment:
   I agree the rules is not very big. But in `onNewClass`, every time we add a 
new logical/physical operator we have to copy it. It will copy N times depends 
on how many operators you have. Though not a significant overhead, but I think 
we still need to avoid multiple times copy.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [calcite] hsyuan commented on a change in pull request #1869: [CALCITE-3868] Remove redundant ruleSet and ruleNames in VolcanoPlanner

2020-03-26 Thread GitBox
hsyuan commented on a change in pull request #1869: [CALCITE-3868] Remove 
redundant ruleSet and ruleNames in VolcanoPlanner
URL: https://github.com/apache/calcite/pull/1869#discussion_r398933698
 
 

 ##
 File path: core/src/main/java/org/apache/calcite/plan/hep/HepPlanner.java
 ##
 @@ -275,7 +253,7 @@ void executeInstruction(
 LOGGER.trace("Applying rule class {}", instruction.ruleClass);
 if (instruction.ruleSet == null) {
   instruction.ruleSet = new LinkedHashSet<>();
-  for (RelOptRule rule : allRules) {
+  for (RelOptRule rule : mapDescToRule.values()) {
 
 Review comment:
   It turns out the size instruction.ruleSet is undetermined, we don't know the 
exact size. So I will leave as it is.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [calcite] hsyuan commented on a change in pull request #1869: [CALCITE-3868] Remove redundant ruleSet and ruleNames in VolcanoPlanner

2020-03-26 Thread GitBox
hsyuan commented on a change in pull request #1869: [CALCITE-3868] Remove 
redundant ruleSet and ruleNames in VolcanoPlanner
URL: https://github.com/apache/calcite/pull/1869#discussion_r398362363
 
 

 ##
 File path: core/src/main/java/org/apache/calcite/plan/hep/HepPlanner.java
 ##
 @@ -275,7 +253,7 @@ void executeInstruction(
 LOGGER.trace("Applying rule class {}", instruction.ruleClass);
 if (instruction.ruleSet == null) {
   instruction.ruleSet = new LinkedHashSet<>();
-  for (RelOptRule rule : allRules) {
+  for (RelOptRule rule : mapDescToRule.values()) {
 
 Review comment:
   Yes, will do.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [calcite] hsyuan commented on a change in pull request #1869: [CALCITE-3868] Remove redundant ruleSet and ruleNames in VolcanoPlanner

2020-03-25 Thread GitBox
hsyuan commented on a change in pull request #1869: [CALCITE-3868] Remove 
redundant ruleSet and ruleNames in VolcanoPlanner
URL: https://github.com/apache/calcite/pull/1869#discussion_r398241191
 
 

 ##
 File path: 
core/src/main/java/org/apache/calcite/plan/volcano/VolcanoPlanner.java
 ##
 @@ -392,35 +382,24 @@ public RelSet getSet(RelNode rel) {
 this.mapRel2Subset.clear();
 this.relImportances.clear();
 this.ruleQueue.clear();
-this.ruleNames.clear();
 this.materializations.clear();
 this.latticeByName.clear();
 this.provenanceMap.clear();
   }
 
   public List getRules() {
-return ImmutableList.copyOf(ruleSet);
+return ImmutableList.copyOf(mapDescToRule.values());
   }
 
   public boolean addRule(RelOptRule rule) {
 
 Review comment:
   @zabetak I have addressed you comments. Thanks.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [calcite] hsyuan commented on a change in pull request #1869: [CALCITE-3868] Remove redundant ruleSet and ruleNames in VolcanoPlanner

2020-03-25 Thread GitBox
hsyuan commented on a change in pull request #1869: [CALCITE-3868] Remove 
redundant ruleSet and ruleNames in VolcanoPlanner
URL: https://github.com/apache/calcite/pull/1869#discussion_r398241191
 
 

 ##
 File path: 
core/src/main/java/org/apache/calcite/plan/volcano/VolcanoPlanner.java
 ##
 @@ -392,35 +382,24 @@ public RelSet getSet(RelNode rel) {
 this.mapRel2Subset.clear();
 this.relImportances.clear();
 this.ruleQueue.clear();
-this.ruleNames.clear();
 this.materializations.clear();
 this.latticeByName.clear();
 this.provenanceMap.clear();
   }
 
   public List getRules() {
-return ImmutableList.copyOf(ruleSet);
+return ImmutableList.copyOf(mapDescToRule.values());
   }
 
   public boolean addRule(RelOptRule rule) {
 
 Review comment:
   @zabetak I have addressed your comments. Thanks.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [calcite] hsyuan commented on a change in pull request #1869: [CALCITE-3868] Remove redundant ruleSet and ruleNames in VolcanoPlanner

2020-03-25 Thread GitBox
hsyuan commented on a change in pull request #1869: [CALCITE-3868] Remove 
redundant ruleSet and ruleNames in VolcanoPlanner
URL: https://github.com/apache/calcite/pull/1869#discussion_r398182889
 
 

 ##
 File path: 
core/src/main/java/org/apache/calcite/plan/AbstractRelOptPlanner.java
 ##
 @@ -44,18 +44,13 @@
  * Abstract base for implementations of the {@link RelOptPlanner} interface.
  */
 public abstract class AbstractRelOptPlanner implements RelOptPlanner {
-  //~ Static fields/initializers -
-
-  /** Regular expression for integer. */
-  private static final Pattern INTEGER_PATTERN = Pattern.compile("[0-9]+");
-
   //~ Instance fields 
 
   /**
* Maps rule description to rule, just to ensure that rules' descriptions
* are unique.
*/
-  private final Map mapDescToRule = new HashMap<>();
+  protected final Map mapDescToRule = new HashMap<>();
 
 Review comment:
   It turns out we still need it to be protected to avoid copying.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [calcite] hsyuan commented on a change in pull request #1869: [CALCITE-3868] Remove redundant ruleSet and ruleNames in VolcanoPlanner

2020-03-24 Thread GitBox
hsyuan commented on a change in pull request #1869: [CALCITE-3868] Remove 
redundant ruleSet and ruleNames in VolcanoPlanner
URL: https://github.com/apache/calcite/pull/1869#discussion_r397319628
 
 

 ##
 File path: 
core/src/main/java/org/apache/calcite/plan/AbstractRelOptPlanner.java
 ##
 @@ -44,18 +44,13 @@
  * Abstract base for implementations of the {@link RelOptPlanner} interface.
  */
 public abstract class AbstractRelOptPlanner implements RelOptPlanner {
-  //~ Static fields/initializers -
-
-  /** Regular expression for integer. */
-  private static final Pattern INTEGER_PATTERN = Pattern.compile("[0-9]+");
-
   //~ Instance fields 
 
   /**
* Maps rule description to rule, just to ensure that rules' descriptions
* are unique.
*/
-  private final Map mapDescToRule = new HashMap<>();
+  protected final Map mapDescToRule = new HashMap<>();
 
 Review comment:
   I think we may need to change it to LinkedHashMap to be consistent with the 
requirement of HepPlanner.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [calcite] hsyuan commented on a change in pull request #1869: [CALCITE-3868] Remove redundant ruleSet and ruleNames in VolcanoPlanner

2020-03-24 Thread GitBox
hsyuan commented on a change in pull request #1869: [CALCITE-3868] Remove 
redundant ruleSet and ruleNames in VolcanoPlanner
URL: https://github.com/apache/calcite/pull/1869#discussion_r397318841
 
 

 ##
 File path: 
core/src/main/java/org/apache/calcite/plan/volcano/VolcanoPlanner.java
 ##
 @@ -392,35 +382,24 @@ public RelSet getSet(RelNode rel) {
 this.mapRel2Subset.clear();
 this.relImportances.clear();
 this.ruleQueue.clear();
-this.ruleNames.clear();
 this.materializations.clear();
 this.latticeByName.clear();
 this.provenanceMap.clear();
   }
 
   public List getRules() {
 
 Review comment:
   Yes.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [calcite] hsyuan commented on a change in pull request #1869: [CALCITE-3868] Remove redundant ruleSet and ruleNames in VolcanoPlanner

2020-03-24 Thread GitBox
hsyuan commented on a change in pull request #1869: [CALCITE-3868] Remove 
redundant ruleSet and ruleNames in VolcanoPlanner
URL: https://github.com/apache/calcite/pull/1869#discussion_r397318993
 
 

 ##
 File path: 
core/src/main/java/org/apache/calcite/plan/AbstractRelOptPlanner.java
 ##
 @@ -156,16 +142,18 @@ protected void mapRuleDescription(RelOptRule rule) {
 + "existing rule=" + existingRule + "; new rule=" + rule);
   }
 }
+return true;
   }
 
   /**
* Removes the mapping between a rule and its description.
*
* @param rule Rule
+   * @return the rule that is removed, or null if no rule is removed
*/
-  protected void unmapRuleDescription(RelOptRule rule) {
+  protected RelOptRule unmapRuleDescription(RelOptRule rule) {
 
 Review comment:
   will do


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [calcite] hsyuan commented on a change in pull request #1869: [CALCITE-3868] Remove redundant ruleSet and ruleNames in VolcanoPlanner

2020-03-24 Thread GitBox
hsyuan commented on a change in pull request #1869: [CALCITE-3868] Remove 
redundant ruleSet and ruleNames in VolcanoPlanner
URL: https://github.com/apache/calcite/pull/1869#discussion_r397312450
 
 

 ##
 File path: 
core/src/main/java/org/apache/calcite/plan/AbstractRelOptPlanner.java
 ##
 @@ -130,24 +125,15 @@ public void checkCancel() {
*
* @param rule Rule
*/
-  protected void mapRuleDescription(RelOptRule rule) {
-// Check that there isn't a rule with the same description,
-// also validating description string.
-
+  protected boolean mapRuleDescription(RelOptRule rule) {
+// Check that there isn't a rule with the same description
 final String description = rule.toString();
 assert description != null;
-assert !description.contains("$")
-: "Rule's description should not contain '$': "
-+ description;
-assert !INTEGER_PATTERN.matcher(description).matches()
-: "Rule's description should not be an integer: "
 
 Review comment:
   When creating the rule


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:
us...@infra.apache.org


With regards,
Apache Git Services