|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eigenbase.sql2rel.RelDecorrelator
public class RelDecorrelator
RelDecorrelator replaces all correlated expressions(corExp) in a relational expression (RelNode) tree with non-correlated expressions that are produced from joining the RelNode that produces the corExp with the RelNode that references it.
Nested Class Summary | |
---|---|
private class |
RelDecorrelator.AdjustProjectForCountAggregateRule
|
private class |
RelDecorrelator.DecorrelateRelVisitor
|
private class |
RelDecorrelator.DecorrelateRexShuttle
|
private class |
RelDecorrelator.RemoveCorrelationForScalarAggregateRule
|
private class |
RelDecorrelator.RemoveCorrelationForScalarProjectRule
|
private class |
RelDecorrelator.RemoveCorrelationRexShuttle
|
private class |
RelDecorrelator.RemoveSingleAggregateRule
Rule to remove single_value rel. |
Field Summary | |
---|---|
private RelNode |
currentRel
|
private RelDecorrelator.DecorrelateRelVisitor |
decorrelateVisitor
|
private HashSet<CorrelatorRel> |
generatedCorRels
|
private SortedMap<CorrelatorRel.Correlation,CorrelatorRel> |
mapCorVarToCorRel
|
private Map<RexFieldAccess,CorrelatorRel.Correlation> |
mapFieldAccessToCorVar
|
private Map<RelNode,SortedMap<CorrelatorRel.Correlation,Integer>> |
mapNewRelToMapCorVarToOutputPos
|
private Map<RelNode,Map<Integer,Integer>> |
mapNewRelToMapOldToNewOutputPos
|
private Map<RelNode,RelNode> |
mapOldToNewRel
|
private Map<RelNode,SortedSet<CorrelatorRel.Correlation>> |
mapRefRelToCorVar
|
private RexBuilder |
rexBuilder
|
private static Logger |
sqlToRelTracer
|
Constructor Summary | |
---|---|
RelDecorrelator(RexBuilder rexBuilder,
Map<RelNode,SortedSet<CorrelatorRel.Correlation>> mapRefRelToCorVar,
SortedMap<CorrelatorRel.Correlation,CorrelatorRel> mapCorVarToCorRel,
Map<RexFieldAccess,CorrelatorRel.Correlation> mapFieldAccessToCorVar)
|
Method Summary | |
---|---|
private RelNode |
aggregateCorrelatorOutput(CorrelatorRel corRel,
ProjectRel projRel,
Set<Integer> isCount)
Pulls projRel above the joinRel from its RHS input. |
private boolean |
checkCorVars(CorrelatorRel corRel,
ProjectRel projRel,
FilterRel filterRel,
List<RexFieldAccess> correlatedJoinKeys)
Checks whether the correlations in projRel and filterRel are related to the correlated variables provided by corRel. |
private RelNode |
createProjectWithAdditionalExprs(RelNode childRel,
RexNode[] additionalExprs,
String[] additionalExprNames)
Project all childRel output fields plus the additional expressions. |
private RelNode |
createValueGenerator(SortedSet<CorrelatorRel.Correlation> correlations,
int valueGenFieldOffset,
SortedMap<CorrelatorRel.Correlation,Integer> mapCorVarToOutputPos)
Create RelNode tree that produces a list of correlated variables. |
RelNode |
decorrelate(RelNode root)
|
protected RexNode |
decorrelateExpr(RexNode exp)
|
private void |
decorrelateInputWithValueGenerator(RelNode rel)
|
void |
decorrelateRel(AggregateRel rel)
Rewrite AggregateRel. |
void |
decorrelateRel(CorrelatorRel rel)
Rewrite CorrelatorRel into a left outer join. |
void |
decorrelateRel(FilterRel rel)
Rewrite FilterRel. |
void |
decorrelateRel(JoinRel rel)
Rewrite JoinRel. |
void |
decorrelateRel(ProjectRel rel)
Rewrite ProjectRel. |
void |
decorrelateRel(SortRel rel)
Rewrite SortRel. |
void |
decorrelateRelGeneric(RelNode rel)
|
private RexInputRef |
getNewForOldInputRef(RexInputRef oldInputRef)
|
private RelNode |
projectJoinOutputWithNullability(JoinRel joinRel,
ProjectRel projRel,
int nullIndicatorPos)
Pull projRel above the joinRel from its RHS input. |
protected RexNode |
removeCorrelationExpr(RexNode exp,
boolean projectPulledAboveLeftCorrelator)
|
protected RexNode |
removeCorrelationExpr(RexNode exp,
boolean projectPulledAboveLeftCorrelator,
RexInputRef nullIndicator)
|
protected RexNode |
removeCorrelationExpr(RexNode exp,
boolean projectPulledAboveLeftCorrelator,
Set<Integer> isCount)
|
RelNode |
removeCorrelationViaRule(RelNode root)
|
private void |
removeCorVarFromTree(CorrelatorRel corRel)
Remove correlated variables from the tree at root corRel |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final Logger sqlToRelTracer
private final Map<RelNode,SortedSet<CorrelatorRel.Correlation>> mapRefRelToCorVar
private final SortedMap<CorrelatorRel.Correlation,CorrelatorRel> mapCorVarToCorRel
private final Map<RexFieldAccess,CorrelatorRel.Correlation> mapFieldAccessToCorVar
private final RelDecorrelator.DecorrelateRelVisitor decorrelateVisitor
private final RexBuilder rexBuilder
private RelNode currentRel
private final Map<RelNode,RelNode> mapOldToNewRel
private final Map<RelNode,SortedMap<CorrelatorRel.Correlation,Integer>> mapNewRelToMapCorVarToOutputPos
private final Map<RelNode,Map<Integer,Integer>> mapNewRelToMapOldToNewOutputPos
private final HashSet<CorrelatorRel> generatedCorRels
Constructor Detail |
---|
public RelDecorrelator(RexBuilder rexBuilder, Map<RelNode,SortedSet<CorrelatorRel.Correlation>> mapRefRelToCorVar, SortedMap<CorrelatorRel.Correlation,CorrelatorRel> mapCorVarToCorRel, Map<RexFieldAccess,CorrelatorRel.Correlation> mapFieldAccessToCorVar)
Method Detail |
---|
public RelNode decorrelate(RelNode root)
public RelNode removeCorrelationViaRule(RelNode root)
protected RexNode decorrelateExpr(RexNode exp)
protected RexNode removeCorrelationExpr(RexNode exp, boolean projectPulledAboveLeftCorrelator)
protected RexNode removeCorrelationExpr(RexNode exp, boolean projectPulledAboveLeftCorrelator, RexInputRef nullIndicator)
protected RexNode removeCorrelationExpr(RexNode exp, boolean projectPulledAboveLeftCorrelator, Set<Integer> isCount)
public void decorrelateRelGeneric(RelNode rel)
public void decorrelateRel(SortRel rel)
rel
- SortRel to be rewrittenpublic void decorrelateRel(AggregateRel rel)
rel
- the project rel to rewritepublic void decorrelateRel(ProjectRel rel)
rel
- the project rel to rewriteprivate RelNode createValueGenerator(SortedSet<CorrelatorRel.Correlation> correlations, int valueGenFieldOffset, SortedMap<CorrelatorRel.Correlation,Integer> mapCorVarToOutputPos)
correlations
- correlated variables to generatevalueGenFieldOffset
- offset in the output that generated columns
will startmapCorVarToOutputPos
- output positions for the correlated variables
generated
private void decorrelateInputWithValueGenerator(RelNode rel)
public void decorrelateRel(FilterRel rel)
rel
- the filter rel to rewritepublic void decorrelateRel(CorrelatorRel rel)
rel
- CorrelatorRelpublic void decorrelateRel(JoinRel rel)
rel
- JoinRelprivate RexInputRef getNewForOldInputRef(RexInputRef oldInputRef)
private RelNode projectJoinOutputWithNullability(JoinRel joinRel, ProjectRel projRel, int nullIndicatorPos)
joinRel
- projRel
- the orginal projRel as the RHS input of the join.nullIndicatorPos
-
private RelNode aggregateCorrelatorOutput(CorrelatorRel corRel, ProjectRel projRel, Set<Integer> isCount)
corRel
- CorrelatorprojRel
- the orginal ProjectRel as the RHS input of the joinisCount
- Positions which are calls to the COUNT
aggregation function
private boolean checkCorVars(CorrelatorRel corRel, ProjectRel projRel, FilterRel filterRel, List<RexFieldAccess> correlatedJoinKeys)
corRel
- CorrelatorprojRel
- the orginal ProjectRel as the RHS input of the joinfilterRel
- FiltercorrelatedJoinKeys
- Correlated join keys
private void removeCorVarFromTree(CorrelatorRel corRel)
corRel
- private RelNode createProjectWithAdditionalExprs(RelNode childRel, RexNode[] additionalExprs, String[] additionalExprNames)
childRel
- additionalExprs
- additionalExprNames
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |