Class LoptMultiJoin

java.lang.Object
org.apache.calcite.rel.rules.LoptMultiJoin

public class LoptMultiJoin extends Object
Utility class that keeps track of the join factors that make up a MultiJoin.
  • Constructor Details

    • LoptMultiJoin

      public LoptMultiJoin(MultiJoin multiJoin)
  • Method Details

    • getMultiJoinRel

      public MultiJoin getMultiJoinRel()
      Returns the MultiJoin corresponding to this multi-join.
    • getNumJoinFactors

      public int getNumJoinFactors()
      Returns the number of factors in this multi-join.
    • getJoinFactor

      public RelNode getJoinFactor(int factIdx)
      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

      public List<RexNode> getJoinFilters()
      Returns all non-outer join filters in this multi-join.
    • getFactorsRefByJoinFilter

      public ImmutableBitSet getFactorsRefByJoinFilter(RexNode joinFilter)
      Returns a bitmap corresponding to the factors referenced within the specified join filter.
      Parameters:
      joinFilter - Filter for which information will be returned
    • getMultiJoinFields

      public List<RelDataTypeField> getMultiJoinFields()
      Returns an array of fields contained within the multi-join.
    • getFieldsRefByJoinFilter

      public ImmutableBitSet getFieldsRefByJoinFilter(RexNode joinFilter)
      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

      public ImmutableBitSet getFactorsRefByFactor(int factIdx)
      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

      public ImmutableBitSet 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.
      Parameters:
      factIdx - Factor for which information will be returned
    • getOuterJoinCond

      public @Nullable RexNode getOuterJoinCond(int factIdx)
      Returns outer join conditions associated with the specified null-generating factor.
      Parameters:
      factIdx - Factor for which information will be returned
    • getProjFields

      public @Nullable ImmutableBitSet getProjFields(int factIdx)
      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

      public @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.
      Parameters:
      dimIdx - Dimension factor for which information will be returned
    • getJoinRemovalSemiJoin

      public LogicalJoin getJoinRemovalSemiJoin(int dimIdx)
      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 factor
      factIdx - Fact factor
    • setJoinRemovalSemiJoin

      public void setJoinRemovalSemiJoin(int dimIdx, LogicalJoin semiJoin)
      Indicates the semi-join that allows the join of a dimension table to be removed.
      Parameters:
      dimIdx - Dimension factor
      semiJoin - 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

      public boolean hasAllFactors(LoptJoinTree joinTree, BitSet factorsNeeded)
      Returns whether if a join tree contains all factors required.
      Parameters:
      joinTree - Join tree to be examined
      factorsNeeded - 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 examined
      childFactors - bitmap to be set
    • getJoinFields

      public List<RelDataTypeField> getJoinFields(LoptJoinTree left, LoptJoinTree right)
      Retrieves the fields corresponding to a join between a left and right tree.
      Parameters:
      left - left hand side of the join
      right - 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-join
      factor2 - the second factor in the self-join
    • getOtherSelfJoinFactor

      public @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.
      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

      public @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. Assumes that the right factor is a part of a self-join.
      Parameters:
      rightFactor - the index of the right factor
      rightOffset - 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

      public org.apache.calcite.rel.rules.LoptMultiJoin.Edge createEdge(RexNode condition)