Package org.apache.calcite.rel.rules
Class LoptMultiJoin
java.lang.Object
org.apache.calcite.rel.rules.LoptMultiJoin
Utility class that keeps track of the join factors that
make up a
MultiJoin
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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.org.apache.calcite.rel.rules.LoptMultiJoin.Edge
createEdge
(RexNode condition) int
findRef
(int rexInputRef) Determines the join factor corresponding to a RexInputRef.void
getChildFactors
(LoptJoinTree joinTree, ImmutableBitSet.Builder childFactors) Deprecated.getFactorsRefByFactor
(int factIdx) Returns a bitmap corresponding to the factors referenced by the specified factor in the various join filters that correspond to comparisons.getFactorsRefByJoinFilter
(RexNode joinFilter) Returns a bitmap corresponding to the factors referenced within the specified join filter.int[] @Nullable []
Returns weights of the different factors relative to one another.getFieldsRefByJoinFilter
(RexNode joinFilter) Returns a bitmap corresponding to the fields referenced by a join filter.getJoinFactor
(int factIdx) Returns the factor corresponding to the given factor index.int[]
getJoinFieldRefCounts
(int factIdx) Returns the join field reference counts for a factor.getJoinFields
(LoptJoinTree left, LoptJoinTree right) Retrieves the fields corresponding to a join between a left and right tree.Returns all non-outer join filters in this multi-join.@Nullable Integer
getJoinRemovalFactor
(int dimIdx) Returns the factor id of the fact table corresponding to a dimension table in a semi-join, in the case where the join with the dimension table can be removed.getJoinRemovalSemiJoin
(int dimIdx) Returns the semi-join that allows the join of a dimension table to be removed.int
getJoinStart
(int factIdx) Returns the starting offset within the multi-join for the specified factor.Returns an array of fields contained within the multi-join.Returns the MultiJoin corresponding to this multi-join.int
getNumFieldsInJoinFactor
(int factIdx) Returns the number of fields in a given factor.int
Returns the number of factors in this multi-join.int
Returns the total number of fields in the multi-join.@Nullable 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.@Nullable RexNode
getOuterJoinCond
(int factIdx) Returns outer join conditions associated with the specified null-generating factor.getOuterJoinFactors
(int factIdx) Returns a bitmap containing the factors that a null-generating factor is dependent upon, if the factor is null-generating in a left or right outer join; otherwise null is returned.@Nullable ImmutableBitSet
getProjFields
(int factIdx) Returns a bitmap containing the fields that are projected from a factor.@Nullable 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, BitSet factorsNeeded) Returns whether if a join tree contains all factors required.boolean
isLeftFactorInRemovableSelfJoin
(int factIdx) Returns whether the factor is the left factor in a self-join.boolean
isNullGenerating
(int factIdx) Returns whether the factor corresponds to a null-generating factor in a left or right outer join.boolean
isRemovableOuterJoinFactor
(int factIdx) Return whether the factor corresponds to the null-generating factor in an outer join that can be removed.boolean
isRightFactorInRemovableSelfJoin
(int factIdx) Returns whether the factor is the right factor in a self-join.void
Sets weighting for each combination of factors, depending on which join filters reference which factors.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 semi-join that allows the join of a dimension table to be removed.
-
Constructor Details
-
LoptMultiJoin
-
-
Method Details
-
getMultiJoinRel
Returns the MultiJoin corresponding to this multi-join. -
getNumJoinFactors
public int getNumJoinFactors()Returns the number of factors in this multi-join. -
getJoinFactor
Returns the factor corresponding to the given factor index.- Parameters:
factIdx
- Factor to be returned
-
getNumTotalFields
public int getNumTotalFields()Returns the total number of fields in the multi-join. -
getNumFieldsInJoinFactor
public int getNumFieldsInJoinFactor(int factIdx) Returns the number of fields in a given factor.- Parameters:
factIdx
- Desired factor
-
getJoinFilters
Returns all non-outer join filters in this multi-join. -
getFactorsRefByJoinFilter
Returns a bitmap corresponding to the factors referenced within the specified join filter.- Parameters:
joinFilter
- Filter for which information will be returned
-
getMultiJoinFields
Returns an array of fields contained within the multi-join. -
getFieldsRefByJoinFilter
Returns a bitmap corresponding to the fields referenced by a join filter.- Parameters:
joinFilter
- the filter for which information will be returned
-
getFactorWeights
public int[] @Nullable [] getFactorWeights()Returns weights of the different factors relative to one another. -
getFactorsRefByFactor
Returns a bitmap corresponding to the factors referenced by the specified factor in the various join filters that correspond to comparisons.- Parameters:
factIdx
- Factor for which information will be returned
-
getJoinStart
public int getJoinStart(int factIdx) Returns the starting offset within the multi-join for the specified factor.- Parameters:
factIdx
- Factor for which information will be returned
-
isNullGenerating
public boolean isNullGenerating(int factIdx) Returns whether the factor corresponds to a null-generating factor in a left or right outer join.- Parameters:
factIdx
- Factor for which information will be returned
-
getOuterJoinFactors
Returns a bitmap containing the factors that a null-generating factor is dependent upon, if the factor is null-generating in a left or right outer join; otherwise null is returned.- Parameters:
factIdx
- Factor for which information will be returned
-
getOuterJoinCond
Returns outer join conditions associated with the specified null-generating factor.- Parameters:
factIdx
- Factor for which information will be returned
-
getProjFields
Returns a bitmap containing the fields that are projected from a factor.- Parameters:
factIdx
- Factor for which information will be returned
-
getJoinFieldRefCounts
public int[] getJoinFieldRefCounts(int factIdx) Returns the join field reference counts for a factor.- Parameters:
factIdx
- Factor for which information will be returned
-
getJoinRemovalFactor
Returns the factor id of the fact table corresponding to a dimension table in a semi-join, in the case where the join with the dimension table can be removed.- Parameters:
dimIdx
- Dimension factor for which information will be returned
-
getJoinRemovalSemiJoin
Returns the semi-join that allows the join of a dimension table to be removed.- Parameters:
dimIdx
- Dimension factor for which information will be returned
-
setJoinRemovalFactor
public void setJoinRemovalFactor(int dimIdx, int factIdx) Indicates that a dimension factor's join can be removed because of a semijoin with a fact table.- Parameters:
dimIdx
- Dimension factorfactIdx
- Fact factor
-
setJoinRemovalSemiJoin
Indicates the semi-join that allows the join of a dimension table to be removed.- Parameters:
dimIdx
- Dimension factorsemiJoin
- the semijoin
-
findRef
@RequiresNonNull({"joinStart","nFieldsInJoinFactor"}) public int findRef(@UnknownInitialization LoptMultiJoin this, int rexInputRef) Determines the join factor corresponding to a RexInputRef.- Parameters:
rexInputRef
- rexInputRef index- Returns:
- index corresponding to join factor
-
setFactorWeights
public void setFactorWeights()Sets weighting for each combination of factors, depending on which join filters reference which factors. Greater weight is given to equality conditions. Also, sets bitmaps indicating which factors are referenced by each factor within join filters that are comparisons. -
hasAllFactors
Returns whether if a join tree contains all factors required.- Parameters:
joinTree
- Join tree to be examinedfactorsNeeded
- Bitmap of factors required- Returns:
- true if join tree contains all required factors
-
getChildFactors
@Deprecated public void getChildFactors(LoptJoinTree joinTree, ImmutableBitSet.Builder childFactors) Deprecated.Sets a bitmap indicating all child RelNodes in a join tree.- Parameters:
joinTree
- join tree to be examinedchildFactors
- bitmap to be set
-
getJoinFields
Retrieves the fields corresponding to a join between a left and right tree.- Parameters:
left
- left hand side of the joinright
- right hand side of the join- Returns:
- fields of the join
-
addRemovableOuterJoinFactor
public 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.- Parameters:
factIdx
- Join factor
-
isRemovableOuterJoinFactor
public boolean isRemovableOuterJoinFactor(int factIdx) Return whether the factor corresponds to the null-generating factor in an outer join that can be removed.- Parameters:
factIdx
- Factor in question
-
addRemovableSelfJoinPair
public void addRemovableSelfJoinPair(int factor1, int factor2) Adds to a map that keeps track of removable self-join pairs.- Parameters:
factor1
- one of the factors in the self-joinfactor2
- the second factor in the self-join
-
getOtherSelfJoinFactor
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.- Parameters:
factIdx
- one of the factors in a self-join pair
-
isLeftFactorInRemovableSelfJoin
public boolean isLeftFactorInRemovableSelfJoin(int factIdx) Returns whether the factor is the left factor in a self-join.- Parameters:
factIdx
- Factor in a self-join
-
isRightFactorInRemovableSelfJoin
public boolean isRightFactorInRemovableSelfJoin(int factIdx) Returns whether the factor is the right factor in a self-join.- Parameters:
factIdx
- Factor in a self-join
-
getRightColumnMapping
Determines whether there is a mapping from a column in the right factor of a self-join to a column from the left factor. Assumes that the right factor is a part of a self-join.- Parameters:
rightFactor
- the index of the right factorrightOffset
- the column offset of the right factor- Returns:
- the offset of the corresponding column in the left factor, if such a column mapping exists; otherwise, null is returned
-
createEdge
-