Class JoinConditionAnalysis

java.lang.Object
org.apache.druid.segment.join.JoinConditionAnalysis
All Implemented Interfaces:
Cacheable

public class JoinConditionAnalysis extends Object implements Cacheable
Represents analysis of a join condition. Each condition is decomposed into "equiConditions" and "nonEquiConditions". 1) The equiConditions are of the form ExpressionOfLeft = ColumnFromRight. The right-hand part cannot be an expression because we use this analysis to determine if we can perform the join using hashtables built off right-hand-side columns. 2) The nonEquiConditions are other conditions that should also be ANDed together All of these conditions are ANDed together to get the overall condition.
  • Method Details

    • forExpression

      public static JoinConditionAnalysis forExpression(String condition, String rightPrefix, ExprMacroTable macroTable)
      Analyze a join condition.
      Parameters:
      condition - the condition expression
      rightPrefix - prefix for the right-hand side of the join; will be used to determine which identifiers in the condition come from the right-hand side and which come from the left-hand side
      macroTable - macro table for parsing the condition expression
    • forExpression

      public static JoinConditionAnalysis forExpression(String condition, Expr conditionExpr, String rightPrefix)
      Analyze a join condition from a pre-parsed expression.
      Parameters:
      condition - the condition expression
      conditionExpr - the parsed condition expression. Must match "condition".
      rightPrefix - prefix for the right-hand side of the join; will be used to determine which identifiers in the condition come from the right-hand side and which come from the left-hand side
    • getOriginalExpression

      public String getOriginalExpression()
      Return the condition expression.
    • getEquiConditions

      public List<Equality> getEquiConditions()
      Return a list of equi-conditions (see class-level javadoc).
    • getNonEquiConditions

      public List<Expr> getNonEquiConditions()
      Return a list of non-equi-conditions (see class-level javadoc).
    • isAlwaysFalse

      public boolean isAlwaysFalse()
      Return whether this condition is a constant that is always false.
    • isAlwaysTrue

      public boolean isAlwaysTrue()
      Return whether this condition is a constant that is always true.
    • canHashJoin

      public boolean canHashJoin()
      Returns whether this condition can be satisfied using a hashtable made from the right-hand side.
    • getRightEquiConditionKeys

      public Set<String> getRightEquiConditionKeys()
      Returns the distinct column keys from the RHS required to evaluate the equi conditions.
    • getRequiredColumns

      public Set<String> getRequiredColumns()
      Returns the set of column names required by this join condition. Columns from the right-hand side are returned with their prefixes included.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getCacheKey

      public byte[] getCacheKey()
      Description copied from interface: Cacheable
      Get a byte array used as a cache key.
      Specified by:
      getCacheKey in interface Cacheable
      Returns:
      bytes to be used as cache key - or null if this object should not be cached.