hbtoo commented on a change in pull request #2187:
URL: https://github.com/apache/calcite/pull/2187#discussion_r502818769
##########
File path: core/src/main/java/org/apache/calcite/plan/volcano/RelSubset.java
##########
@@ -375,76 +373,6 @@ RelNode buildCheapestPlan(VolcanoPlanner planner) {
return cheapest;
}
- /**
- * Checks whether a relexp has made its subset cheaper, and if it so,
- * propagate new cost to parent rel nodes using breadth first manner.
- *
- * @param planner Planner
- * @param mq Metadata query
- * @param rel Relational expression whose cost has improved
- * @param activeSet Set of active subsets, for cycle detection
- */
- void propagateCostImprovements(VolcanoPlanner planner, RelMetadataQuery mq,
- RelNode rel, Set<RelSubset> activeSet) {
- Queue<Pair<RelSubset, RelNode>> propagationQueue = new ArrayDeque<>();
- for (RelSubset subset : set.subsets) {
- if (rel.getTraitSet().satisfies(subset.traitSet)) {
- propagationQueue.offer(Pair.of(subset, rel));
- }
- }
-
- while (!propagationQueue.isEmpty()) {
- Pair<RelSubset, RelNode> p = propagationQueue.poll();
- p.left.propagateCostImprovements0(planner, mq, p.right, activeSet,
propagationQueue);
- }
- }
-
- void propagateCostImprovements0(VolcanoPlanner planner, RelMetadataQuery mq,
- RelNode rel, Set<RelSubset> activeSet,
- Queue<Pair<RelSubset, RelNode>> propagationQueue) {
- ++timestamp;
-
- if (!activeSet.add(this)) {
- // This subset is already in the chain being propagated to. This
- // means that the graph is cyclic, and therefore the cost of this
- // relational expression - not this subset - must be infinite.
- LOGGER.trace("cyclic: {}", this);
Review comment:
The cyclic check is necessary for the old update logic, i.e. DFS. Now
since it is a Dijkstra like algorithm, always propagating the changed relNode
with smallest best cost, the update will automatically stop after traveling a
full cycle. So no special handling is needed any more.
----------------------------------------------------------------
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:
[email protected]