Class Filters

java.lang.Object
org.apache.druid.segment.filter.Filters

public class Filters extends Object
  • Constructor Details

    • Filters

      public Filters()
  • Method Details

    • toFilter

      @Nullable public static Filter toFilter(@Nullable DimFilter dimFilter)
      Convert a DimFilter to an optimized Filter for use at the top level of a query. Must not be used by DimFilter to convert their children, because the three-valued logic parameter "includeUnknown" will not be correctly propagated. For DimFilter that convert their children, use DimFilter.toOptimizedFilter(boolean) instead.
      Parameters:
      dimFilter - dimFilter
      Returns:
      converted filter, or null if input was null
    • makeValueMatcher

      public static ValueMatcher makeValueMatcher(ColumnSelectorFactory columnSelectorFactory, String columnName, DruidPredicateFactory predicateFactory)
      Create a ValueMatcher that applies a predicate to row values.

      The caller provides a predicate factory that can create a predicate for each value type supported by Druid. See DruidPredicateFactory for more information.

      When creating the ValueMatcher, the ValueMatcherFactory implementation should decide what type of predicate to create from the predicate factory based on the ValueType of the specified dimension.

      Parameters:
      columnSelectorFactory - Selector for columns.
      columnName - The column to filter.
      predicateFactory - Predicate factory
      Returns:
      An object that applies a predicate to row values
    • makePredicateIndex

      @Nullable public static BitmapColumnIndex makePredicateIndex(String column, ColumnIndexSelector selector, DruidPredicateFactory predicateFactory)
    • makeMissingColumnNullIndex

      public static BitmapColumnIndex makeMissingColumnNullIndex(DruidPredicateMatch match, ColumnIndexSelector selector)
    • computeDefaultBitmapResults

      public static ImmutableBitmap computeDefaultBitmapResults(Filter filter, ColumnIndexSelector selector)
    • convertToCNFFromQueryContext

      @Nullable public static Filter convertToCNFFromQueryContext(Query query, @Nullable Filter filter)
    • toCnf

      public static Filter toCnf(Filter current) throws CNFFilterExplosionException
      Throws:
      CNFFilterExplosionException
    • checkFilterTuningUseIndex

      public static boolean checkFilterTuningUseIndex(String columnName, ColumnIndexSelector indexSelector, @Nullable FilterTuning filterTuning)
    • and

      public static Filter and(List<Filter> filters)
      Create a filter representing an AND relationship across a list of filters. Deduplicates filters, flattens stacks, and removes null filters and literal "false" filters.
      Parameters:
      filters - List of filters
      Returns:
      If "filters" has more than one filter remaining after processing, returns AndFilter. If "filters" has a single element remaining after processing, return that filter alone.
      Throws:
      IllegalArgumentException - if "filters" is empty or only contains nulls
    • maybeAnd

      public static Optional<Filter> maybeAnd(List<Filter> filters)
      Like and(java.util.List<org.apache.druid.query.filter.Filter>), but returns an empty Optional instead of throwing an exception if "filters" is empty or only contains nulls.
    • or

      public static Filter or(List<Filter> filters)
      Create a filter representing an OR relationship across a list of filters. Deduplicates filters, flattens stacks, and removes null filters and literal "false" filters.
      Parameters:
      filters - List of filters
      Returns:
      If "filters" has more than one filter remaining after processing, returns OrFilter. If "filters" has a single element remaining after processing, return that filter alone.
      Throws:
      IllegalArgumentException - if "filters" is empty
    • maybeOr

      public static Optional<Filter> maybeOr(List<Filter> filters)
      Like or(java.util.List<org.apache.druid.query.filter.Filter>), but returns an empty Optional instead of throwing an exception if "filters" is empty or only contains nulls.
    • toNormalizedOrClauses

      public static List<Filter> toNormalizedOrClauses(Filter filter) throws CNFFilterExplosionException
      Parameters:
      filter - the filter.
      Returns:
      The normalized or clauses for the provided filter.
      Throws:
      CNFFilterExplosionException
    • filterMatchesNull

      public static boolean filterMatchesNull(Filter filter)
    • countNumberOfFilters

      public static int countNumberOfFilters(@Nullable Filter filter)
    • conjunction

      public static Filter conjunction(Filter... filters)