Package org.apache.druid.segment.filter
Class Filters
- java.lang.Object
-
- org.apache.druid.segment.filter.Filters
-
public class Filters extends Object
-
-
Constructor Summary
Constructors Constructor Description Filters()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Filterand(List<Filter> filters)Create a filter representing an AND relationship across a list of filters.static booleancheckFilterTuningUseIndex(String columnName, ColumnIndexSelector indexSelector, FilterTuning filterTuning)static ImmutableBitmapcomputeDefaultBitmapResults(Filter filter, ColumnIndexSelector selector)static FilterconvertToCNFFromQueryContext(Query query, Filter filter)static intcountNumberOfFilters(Filter filter)static booleanfilterMatchesNull(Filter filter)static BitmapColumnIndexmakeMissingColumnNullIndex(DruidPredicateMatch match, ColumnIndexSelector selector)static BitmapColumnIndexmakePredicateIndex(String column, ColumnIndexSelector selector, DruidPredicateFactory predicateFactory)static ValueMatchermakeValueMatcher(ColumnSelectorFactory columnSelectorFactory, String columnName, DruidPredicateFactory predicateFactory)Create a ValueMatcher that applies a predicate to row values.static Optional<Filter>maybeAnd(List<Filter> filters)Likeand(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.static Optional<Filter>maybeOr(List<Filter> filters)Likeor(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.static Filteror(List<Filter> filters)Create a filter representing an OR relationship across a list of filters.static FiltertoCnf(Filter current)static FiltertoFilter(DimFilter dimFilter)static List<Filter>toNormalizedOrClauses(Filter filter)
-
-
-
Method Detail
-
toFilter
@Nullable public static Filter toFilter(@Nullable DimFilter dimFilter)
Convert aDimFilterto an optimizedFilterfor use at the top level of a query. Must not be used byDimFilterto convert their children, because the three-valued logic parameter "includeUnknown" will not be correctly propagated. ForDimFilterthat convert their children, useDimFilter.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
DruidPredicateFactoryfor 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)
Likeand(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)
Likeor(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)
-
-