Class CollectComparisons<BaseType,ComparisonType extends BaseType,CollectedType extends BaseType,CollectionKey,CollectionElementType,CollectionType extends Collection<CollectionElementType>>

java.lang.Object
org.apache.druid.sql.calcite.filtration.CollectComparisons<BaseType,ComparisonType,CollectedType,CollectionKey,CollectionElementType,CollectionType>

public abstract class CollectComparisons<BaseType,ComparisonType extends BaseType,CollectedType extends BaseType,CollectionKey,CollectionElementType,CollectionType extends Collection<CollectionElementType>> extends Object
Utility class for collecting point comparisons that are children to an OR, such as equalities. Each set of comparisons with the same CollectComparisons can potentially become a single CollectComparisons. For example: x = 'a', x = 'b' can become x IN ('a', 'b').
  • Constructor Details

    • CollectComparisons

      protected CollectComparisons(List<BaseType> orExprs)
  • Method Details

    • collect

      public List<BaseType> collect()
      Perform collection logic on the exprs provided to the constructor.
    • getCollectibleComparison

      @Nullable protected abstract Pair<ComparisonType,List<BaseType>> getCollectibleComparison(BaseType expr)
      Given an expression, returns a collectible comparison (if the provided expression is collectible), or returns a pair of collectible comparison and other expressions (if the provided expression is an AND of a collectible comparison and those other expressions).
    • makeCollection

      protected abstract CollectionType makeCollection()
    • getCollectionKey

      @Nullable protected abstract CollectionKey getCollectionKey(ComparisonType comparison)
      Given a comparison, returns its collection key, which will be used to group it together with like comparisons. This method will be called on objects returned by getCollectibleComparison(Object). If this method returns null, the filter is considered non-collectible.
    • getMatchValues

      protected abstract Set<CollectionElementType> getMatchValues(ComparisonType comparison)
      Given a comparison, returns the strings that it matches.
    • makeCollectedComparison

      @Nullable protected abstract CollectedType makeCollectedComparison(CollectionKey key, CollectionType values)
      Given a set of strings from getMatchValues(Object) from various comparisons, returns a single collected comparison that matches all those strings.
    • makeAnd

      protected abstract BaseType makeAnd(List<BaseType> exprs)
      Given a list of expressions, returns an AND expression with those exprs as children. Only called if getCollectibleComparison(Object) returns nonempty right-hand-sides.