Package org.apache.calcite.rel.rules
Class MultiJoinOptimizeBushyRule
- java.lang.Object
-
- org.apache.calcite.plan.RelOptRule
-
- org.apache.calcite.rel.rules.MultiJoinOptimizeBushyRule
-
public class MultiJoinOptimizeBushyRule extends RelOptRule
Planner rule that finds an approximately optimal ordering for join operators using a heuristic algorithm.It is triggered by the pattern
LogicalProject
(MultiJoin
).It is similar to
LoptOptimizeJoinRule
.LoptOptimizeJoinRule
is only capable of producing left-deep joins; this rule is capable of producing bushy joins.TODO:
- Join conditions that touch 1 factor.
- Join conditions that touch 3 factors.
- More than 1 join conditions that touch the same pair of factors,
e.g.
t0.c1 = t1.c1 and t1.c2 = t0.c3
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
MultiJoinOptimizeBushyRule.JoinVertex
Participant in a join which is itself a join.(package private) static class
MultiJoinOptimizeBushyRule.LeafVertex
Relation participating in a join.(package private) static class
MultiJoinOptimizeBushyRule.Vertex
Participant in a join (relation or join).
-
Field Summary
Fields Modifier and Type Field Description static MultiJoinOptimizeBushyRule
INSTANCE
private java.io.PrintWriter
pw
-
Fields inherited from class org.apache.calcite.plan.RelOptRule
description, operands, relBuilderFactory
-
-
Constructor Summary
Constructors Constructor Description MultiJoinOptimizeBushyRule(RelFactories.JoinFactory joinFactory, RelFactories.ProjectFactory projectFactory)
Deprecated.MultiJoinOptimizeBushyRule(RelBuilderFactory relBuilderFactory)
Creates an MultiJoinOptimizeBushyRule.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) int
chooseBestEdge(java.util.List<LoptMultiJoin.Edge> edges, java.util.Comparator<LoptMultiJoin.Edge> comparator)
(package private) static <E> int
minPos(java.util.List<E> list, java.util.Comparator<E> fn)
Returns the index within a list at which compares least according to a comparator.void
onMatch(RelOptRuleCall call)
Receives notification about a rule match.private void
trace(java.util.List<MultiJoinOptimizeBushyRule.Vertex> vertexes, java.util.List<LoptMultiJoin.Edge> unusedEdges, java.util.List<LoptMultiJoin.Edge> usedEdges, int edgeOrdinal, java.io.PrintWriter pw)
-
Methods inherited from class org.apache.calcite.plan.RelOptRule
any, convert, convert, convertList, convertOperand, convertOperand, equals, equals, getOperand, getOperands, getOutConvention, getOutTrait, hashCode, matches, none, operand, operand, operand, operand, operand, operandJ, operandJ, some, toString, unordered
-
-
-
-
Field Detail
-
INSTANCE
public static final MultiJoinOptimizeBushyRule INSTANCE
-
pw
private final java.io.PrintWriter pw
-
-
Constructor Detail
-
MultiJoinOptimizeBushyRule
public MultiJoinOptimizeBushyRule(RelBuilderFactory relBuilderFactory)
Creates an MultiJoinOptimizeBushyRule.
-
MultiJoinOptimizeBushyRule
@Deprecated public MultiJoinOptimizeBushyRule(RelFactories.JoinFactory joinFactory, RelFactories.ProjectFactory projectFactory)
Deprecated.
-
-
Method Detail
-
onMatch
public void onMatch(RelOptRuleCall call)
Description copied from class:RelOptRule
Receives notification about a rule match. At the time that this method is called,call.rels
holds the set of relational expressions which match the operands to the rule;call.rels[0]
is the root expression.Typically a rule would check that the nodes are valid matches, creates a new expression, then calls back
RelOptRuleCall.transformTo(org.apache.calcite.rel.RelNode, java.util.Map<org.apache.calcite.rel.RelNode, org.apache.calcite.rel.RelNode>)
to register the expression.- Specified by:
onMatch
in classRelOptRule
- Parameters:
call
- Rule call- See Also:
RelOptRule.matches(RelOptRuleCall)
-
trace
private void trace(java.util.List<MultiJoinOptimizeBushyRule.Vertex> vertexes, java.util.List<LoptMultiJoin.Edge> unusedEdges, java.util.List<LoptMultiJoin.Edge> usedEdges, int edgeOrdinal, java.io.PrintWriter pw)
-
chooseBestEdge
int chooseBestEdge(java.util.List<LoptMultiJoin.Edge> edges, java.util.Comparator<LoptMultiJoin.Edge> comparator)
-
minPos
static <E> int minPos(java.util.List<E> list, java.util.Comparator<E> fn)
Returns the index within a list at which compares least according to a comparator.In the case of a tie, returns the earliest such element.
If the list is empty, returns -1.
-
-