public class LoptMultiJoin
extends java.lang.Object
MultiJoin
.Modifier and Type | Class and Description |
---|---|
(package private) static class |
LoptMultiJoin.Edge
Information about a join-condition.
|
private class |
LoptMultiJoin.RemovableSelfJoin
Utility class used to keep track of the factors in a removable self-join.
|
Modifier and Type | Field and Description |
---|---|
private java.util.List<RexNode> |
allJoinFilters
All join filters associated with the MultiJoin, decomposed into a
list.
|
(package private) ImmutableBitSet[] |
factorsRefByFactor
Bitmap indicating which factors each factor references in join filters
that correspond to comparisons
|
private java.util.Map<RexNode,ImmutableBitSet> |
factorsRefByJoinFilter
For each join filter, associates a bitmap indicating all factors
referenced by the filter
|
(package private) int[][] |
factorWeights
Weights of each factor combination
|
(package private) RelDataTypeFactory |
factory
Type factory
|
private java.util.Map<RexNode,ImmutableBitSet> |
fieldsRefByJoinFilter
For each join filter, associates a bitmap indicating all fields
referenced by the filter
|
private com.google.common.collect.ImmutableList<RelNode> |
joinFactors
Original inputs into the MultiJoin
|
private java.util.Map<java.lang.Integer,int[]> |
joinFieldRefCountsMap
Map containing reference counts of the fields referenced in join
conditions for each join factor.
|
private java.util.List<RexNode> |
joinFilters
Join filters associated with the MultiJoin, decomposed into a list.
|
(package private) java.lang.Integer[] |
joinRemovalFactors
Indicates for each factor whether its join can be removed because it is
the dimension table in a semijoin.
|
(package private) LogicalJoin[] |
joinRemovalSemiJoins
The semijoins that allow the join of a dimension table to be removed
|
(package private) int[] |
joinStart
Starting RexInputRef index corresponding to each join factor
|
private com.google.common.collect.ImmutableList<JoinRelType> |
joinTypes
If a join factor is null generating in a left or right outer join,
joinTypes indicates the join type corresponding to the factor.
|
(package private) MultiJoin |
multiJoin
The MultiJoin being optimized
|
(package private) int[] |
nFieldsInJoinFactor
Number of fields in each join factor
|
private int |
nJoinFactors
Number of factors into the MultiJoin
|
private int |
nTotalFields
Total number of fields in the MultiJoin
|
private ImmutableBitSet[] |
outerJoinFactors
If a join factor is null generating in a left or right outer join, the
bitmap contains the non-null generating factors that the null generating
factor is dependent upon
|
private java.util.List<ImmutableBitSet> |
projFields
Bitmap corresponding to the fields projected from each join factor, after
row scan processing has completed.
|
(package private) java.util.Set<java.lang.Integer> |
removableOuterJoinFactors
Set of null-generating factors whose corresponding outer join can be
removed from the query plan
|
(package private) java.util.Map<java.lang.Integer,LoptMultiJoin.RemovableSelfJoin> |
removableSelfJoinPairs
Map consisting of all pairs of self-joins where the self-join can be
removed because the join between the identical factors is an equality
join on the same set of unique keys.
|
Constructor and Description |
---|
LoptMultiJoin(MultiJoin multiJoin) |
Modifier and Type | Method and Description |
---|---|
void |
addRemovableOuterJoinFactor(int factIdx)
Adds a join factor to the set of factors that can be removed because the
factor is the null generating factor in an outer join, its join keys are
unique, and the factor is not projected in the query
|
void |
addRemovableSelfJoinPair(int factor1,
int factor2)
Adds to a map that keeps track of removable self-join pairs.
|
LoptMultiJoin.Edge |
createEdge(RexNode condition) |
private ImmutableBitSet |
factorBitmap(ImmutableBitSet fieldRefBitmap)
Sets the bitmap indicating which factors a filter references based on
which fields it references
|
private ImmutableBitSet |
fieldBitmap(RexNode joinFilter) |
int |
findRef(int rexInputRef)
Determines the join factor corresponding to a RexInputRef
|
void |
getChildFactors(LoptJoinTree joinTree,
ImmutableBitSet.Builder childFactors)
Deprecated.
|
ImmutableBitSet |
getFactorsRefByFactor(int factIdx) |
ImmutableBitSet |
getFactorsRefByJoinFilter(RexNode joinFilter) |
int[][] |
getFactorWeights() |
ImmutableBitSet |
getFieldsRefByJoinFilter(RexNode joinFilter) |
RelNode |
getJoinFactor(int factIdx) |
int[] |
getJoinFieldRefCounts(int factIdx) |
java.util.List<RelDataTypeField> |
getJoinFields(LoptJoinTree left,
LoptJoinTree right)
Retrieves the fields corresponding to a join between a left and right
tree
|
(package private) ImmutableBitSet |
getJoinFilterFactorBitmap(RexNode joinFilter,
boolean setFields)
Returns a bitmap representing the factors referenced in a join filter
|
java.util.List<RexNode> |
getJoinFilters() |
java.lang.Integer |
getJoinRemovalFactor(int dimIdx) |
LogicalJoin |
getJoinRemovalSemiJoin(int dimIdx) |
int |
getJoinStart(int factIdx) |
java.util.List<RelDataTypeField> |
getMultiJoinFields()
Returns array of fields contained within the multi-join
|
MultiJoin |
getMultiJoinRel() |
int |
getNumFieldsInJoinFactor(int factIdx) |
int |
getNumJoinFactors() |
int |
getNumTotalFields() |
java.lang.Integer |
getOtherSelfJoinFactor(int factIdx)
Returns the other factor in a self-join pair if the factor passed in is
a factor in a removable self-join; otherwise, returns null.
|
RexNode |
getOuterJoinCond(int factIdx) |
ImmutableBitSet |
getOuterJoinFactors(int factIdx) |
ImmutableBitSet |
getProjFields(int factIdx) |
java.lang.Integer |
getRightColumnMapping(int rightFactor,
int rightOffset)
Determines whether there is a mapping from a column in the right factor
of a self-join to a column from the left factor.
|
boolean |
hasAllFactors(LoptJoinTree joinTree,
java.util.BitSet factorsNeeded)
Returns true if a join tree contains all factors required
|
boolean |
isLeftFactorInRemovableSelfJoin(int factIdx) |
boolean |
isNullGenerating(int factIdx) |
boolean |
isRemovableOuterJoinFactor(int factIdx) |
boolean |
isRightFactorInRemovableSelfJoin(int factIdx) |
private void |
setFactorWeight(int weight,
int leftFactor,
int rightFactor)
Sets an individual weight if the new weight is better than the current
one
|
void |
setFactorWeights()
Sets weighting for each combination of factors, depending on which join
filters reference which factors.
|
private void |
setJoinFilterRefs()
Sets bitmaps indicating which factors and fields each join filter
references
|
void |
setJoinRemovalFactor(int dimIdx,
int factIdx)
Indicates that a dimension factor's join can be removed because of a
semijoin with a fact table.
|
void |
setJoinRemovalSemiJoin(int dimIdx,
LogicalJoin semiJoin)
Indicates the semijoin that allows the join of a dimension table to be
removed
|
MultiJoin multiJoin
private java.util.List<RexNode> joinFilters
private java.util.List<RexNode> allJoinFilters
private final int nJoinFactors
private int nTotalFields
private final com.google.common.collect.ImmutableList<RelNode> joinFactors
private final com.google.common.collect.ImmutableList<JoinRelType> joinTypes
private final ImmutableBitSet[] outerJoinFactors
private java.util.List<ImmutableBitSet> projFields
private java.util.Map<java.lang.Integer,int[]> joinFieldRefCountsMap
private java.util.Map<RexNode,ImmutableBitSet> factorsRefByJoinFilter
private java.util.Map<RexNode,ImmutableBitSet> fieldsRefByJoinFilter
int[] joinStart
int[] nFieldsInJoinFactor
ImmutableBitSet[] factorsRefByFactor
int[][] factorWeights
final RelDataTypeFactory factory
java.lang.Integer[] joinRemovalFactors
LogicalJoin[] joinRemovalSemiJoins
java.util.Set<java.lang.Integer> removableOuterJoinFactors
java.util.Map<java.lang.Integer,LoptMultiJoin.RemovableSelfJoin> removableSelfJoinPairs
public LoptMultiJoin(MultiJoin multiJoin)
public MultiJoin getMultiJoinRel()
public int getNumJoinFactors()
public RelNode getJoinFactor(int factIdx)
factIdx
- factor to be returnedpublic int getNumTotalFields()
public int getNumFieldsInJoinFactor(int factIdx)
factIdx
- desired factorpublic java.util.List<RexNode> getJoinFilters()
public ImmutableBitSet getFactorsRefByJoinFilter(RexNode joinFilter)
joinFilter
- filter for which information will be returnedpublic java.util.List<RelDataTypeField> getMultiJoinFields()
public ImmutableBitSet getFieldsRefByJoinFilter(RexNode joinFilter)
joinFilter
- the filter for which information will be returnedpublic int[][] getFactorWeights()
public ImmutableBitSet getFactorsRefByFactor(int factIdx)
factIdx
- factor for which information will be returnedpublic int getJoinStart(int factIdx)
factIdx
- factor for which information will be returnedpublic boolean isNullGenerating(int factIdx)
factIdx
- factor for which information will be returnedpublic ImmutableBitSet getOuterJoinFactors(int factIdx)
factIdx
- factor for which information will be returnedpublic RexNode getOuterJoinCond(int factIdx)
factIdx
- factor for which information will be returnedpublic ImmutableBitSet getProjFields(int factIdx)
factIdx
- factor for which information will be returnedpublic int[] getJoinFieldRefCounts(int factIdx)
factIdx
- factor for which information will be returnedpublic java.lang.Integer getJoinRemovalFactor(int dimIdx)
dimIdx
- the dimension factor for which information will be returnedpublic LogicalJoin getJoinRemovalSemiJoin(int dimIdx)
dimIdx
- the dimension factor for which information will be returnedpublic void setJoinRemovalFactor(int dimIdx, int factIdx)
dimIdx
- id of the dimension factorfactIdx
- id of the fact factorpublic void setJoinRemovalSemiJoin(int dimIdx, LogicalJoin semiJoin)
dimIdx
- id of the dimension factorsemiJoin
- the semijoinImmutableBitSet getJoinFilterFactorBitmap(RexNode joinFilter, boolean setFields)
joinFilter
- the join filtersetFields
- if true, add the fields referenced by the join filter
into a mapprivate ImmutableBitSet fieldBitmap(RexNode joinFilter)
private void setJoinFilterRefs()
private ImmutableBitSet factorBitmap(ImmutableBitSet fieldRefBitmap)
fieldRefBitmap
- bitmap representing fields referencedpublic int findRef(int rexInputRef)
rexInputRef
- rexInputRef indexpublic void setFactorWeights()
private void setFactorWeight(int weight, int leftFactor, int rightFactor)
weight
- weight to be setleftFactor
- index of left factorrightFactor
- index of right factorpublic boolean hasAllFactors(LoptJoinTree joinTree, java.util.BitSet factorsNeeded)
joinTree
- join tree to be examinedfactorsNeeded
- bitmap of factors required@Deprecated public void getChildFactors(LoptJoinTree joinTree, ImmutableBitSet.Builder childFactors)
joinTree
- join tree to be examinedchildFactors
- bitmap to be setpublic java.util.List<RelDataTypeField> getJoinFields(LoptJoinTree left, LoptJoinTree right)
left
- left hand side of the joinright
- right hand side of the joinpublic void addRemovableOuterJoinFactor(int factIdx)
factIdx
- join factorpublic boolean isRemovableOuterJoinFactor(int factIdx)
factIdx
- factor in questionpublic void addRemovableSelfJoinPair(int factor1, int factor2)
factor1
- one of the factors in the self-joinfactor2
- the second factor in the self-joinpublic java.lang.Integer getOtherSelfJoinFactor(int factIdx)
factIdx
- one of the factors in a self-join pairpublic boolean isLeftFactorInRemovableSelfJoin(int factIdx)
factIdx
- factor in a self-joinpublic boolean isRightFactorInRemovableSelfJoin(int factIdx)
factIdx
- factor in a self-joinpublic java.lang.Integer getRightColumnMapping(int rightFactor, int rightOffset)
rightFactor
- the index of the right factorrightOffset
- the column offset of the right factorpublic LoptMultiJoin.Edge createEdge(RexNode condition)
Copyright © 2012–2019 The Apache Software Foundation. All rights reserved.