mihaibudiu commented on code in PR #5272:
URL: https://github.com/apache/calcite/pull/5272#discussion_r4124912445


##########
core/src/main/java/org/apache/calcite/plan/hep/HepPlanner.java:
##########
@@ -744,24 +761,56 @@ protected List<HepRelVertex> 
getVertexParents(HepRelVertex vertex) {
     return parents;
   }
 
+  /**
+   * Returns whether {@code rel} and its descendants match {@code operand} and 
its child
+   * operands.
+   *
+   * <p>A rel matches an operand if the operand {@link 
RelOptRuleOperand#matches matches} it
+   * by class, trait and predicate, and each of the operand's child operands 
matches one of
+   * the rel's children: the child in the same position, or any child for an
+   * {@code UNORDERED} child policy. A rel whose inputs are not all vertices 
of the graph
+   * never matches, as the graph can be partially optimized for a materialized 
view.

Review Comment:
   does the materialized view comment belong here?



##########
core/src/main/java/org/apache/calcite/plan/hep/HepPlanner.java:
##########
@@ -744,24 +761,56 @@ protected List<HepRelVertex> 
getVertexParents(HepRelVertex vertex) {
     return parents;
   }
 
+  /**
+   * Returns whether {@code rel} and its descendants match {@code operand} and 
its child
+   * operands.
+   *
+   * <p>A rel matches an operand if the operand {@link 
RelOptRuleOperand#matches matches} it
+   * by class, trait and predicate, and each of the operand's child operands 
matches one of
+   * the rel's children: the child in the same position, or any child for an
+   * {@code UNORDERED} child policy. A rel whose inputs are not all vertices 
of the graph
+   * never matches, as the graph can be partially optimized for a materialized 
view.
+   *
+   * <p>Appends each matched rel to {@code bindings}, in operand order, and 
for an

Review Comment:
   does this happen unconditionally or only when the rel matches?



##########
core/src/main/java/org/apache/calcite/plan/hep/HepPlanner.java:
##########
@@ -744,24 +761,56 @@ protected List<HepRelVertex> 
getVertexParents(HepRelVertex vertex) {
     return parents;
   }
 
+  /**
+   * Returns whether {@code rel} and its descendants match {@code operand} and 
its child
+   * operands.
+   *
+   * <p>A rel matches an operand if the operand {@link 
RelOptRuleOperand#matches matches} it
+   * by class, trait and predicate, and each of the operand's child operands 
matches one of
+   * the rel's children: the child in the same position, or any child for an
+   * {@code UNORDERED} child policy. A rel whose inputs are not all vertices 
of the graph
+   * never matches, as the graph can be partially optimized for a materialized 
view.
+   *
+   * <p>Appends each matched rel to {@code bindings}, in operand order, and 
for an
+   * {@code UNORDERED} child policy records the matched rel's children in
+   * {@code nodeChildren}.
+   */
   private static boolean matchOperands(
       RelOptRuleOperand operand,
       RelNode rel,
       List<RelNode> bindings,
       Map<RelNode, List<RelNode>> nodeChildren) {
-    if (!operand.matches(rel)) {
-      return false;
-    }
-    for (RelNode input : rel.getInputs()) {
-      if (!(input instanceof HepRelVertex)) {
+    return operand.matches(rel)
+        && matchOperandsForMatchedRel(operand, rel, bindings, nodeChildren);
+  }
+
+  /**
+   * Returns whether {@code rel} and its descendants match {@code operand} and 
its child
+   * operands, as {@link #matchOperands} does, given that {@code operand} 
already
+   * {@link RelOptRuleOperand#matches matches} {@code rel}. A caller that has 
made that test

Review Comment:
   the comment about the caller is not needed, just describe what this function 
does.
   use short phrases which can be read easily.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to