public class Filters extends Object
| Constructor and Description |
|---|
Filters() |
| Modifier and Type | Method and Description |
|---|---|
static ImmutableBitmap |
allFalse(BitmapIndexSelector selector) |
static ImmutableBitmap |
allTrue(BitmapIndexSelector selector) |
static Filter |
and(List<Filter> filterList)
Create a filter representing an AND relationship across a list of filters.
|
static Filter |
convertToCNFFromQueryContext(Query query,
Filter filter) |
static double |
estimateSelectivity(BitmapIndex bitmapIndex,
it.unimi.dsi.fastutil.ints.IntList bitmaps,
long totalNumRows)
Return an estimated selectivity for bitmaps for the dimension values given by dimValueIndexes.
|
static double |
estimateSelectivity(Iterator<ImmutableBitmap> bitmaps,
long totalNumRows)
Return an estimated selectivity for bitmaps given by an iterator.
|
static double |
estimateSelectivity(String dimension,
BitmapIndexSelector indexSelector,
com.google.common.base.Predicate<String> predicate)
Return an estimated selectivity for bitmaps of all values matching the given predicate.
|
static boolean |
filterMatchesNull(Filter filter) |
static ValueMatcher |
makeValueMatcher(ColumnSelectorFactory columnSelectorFactory,
String columnName,
DruidPredicateFactory predicateFactory)
Create a ValueMatcher that applies a predicate to row values.
|
static ValueMatcher |
makeValueMatcher(ColumnSelectorFactory columnSelectorFactory,
String columnName,
String value)
Create a ValueMatcher that compares row values to the provided string.
|
static <T> T |
matchPredicate(String dimension,
BitmapIndexSelector selector,
BitmapResultFactory<T> bitmapResultFactory,
com.google.common.base.Predicate<String> predicate)
Return the union of bitmaps for all values matching a particular predicate.
|
static Iterable<ImmutableBitmap> |
matchPredicateNoUnion(String dimension,
BitmapIndexSelector selector,
com.google.common.base.Predicate<String> predicate)
Return an iterable of bitmaps for all values matching a particular predicate.
|
static Filter |
or(Set<Filter> filterSet)
Create a filter representing an OR relationship across a set of filters.
|
static boolean |
shouldUseBitmapIndex(Filter filter,
BitmapIndexSelector indexSelector,
FilterTuning filterTuning)
This method provides a "standard" implementation of
Filter.shouldUseBitmapIndex(BitmapIndexSelector) which takes
a Filter, a BitmapIndexSelector, and FilterTuning to determine if:
a) the filter supports bitmap indexes for all required columns
b) the filter tuning specifies that it should use the index
c) the cardinality of the column is above the minimum threshold and below the maximum threshold to use the index
If all these things are true, QueryableIndexStorageAdapter will utilize the
indexes. |
static Filter |
toCnf(Filter current) |
static Filter |
toFilter(DimFilter dimFilter)
Convert a DimFilter to a Filter.
|
static Set<Filter> |
toFilters(List<DimFilter> dimFilters)
Convert a list of DimFilters to a list of Filters.
|
static Set<Filter> |
toNormalizedOrClauses(Filter filter) |
public static Set<Filter> toFilters(List<DimFilter> dimFilters)
dimFilters - list of DimFilters, should all be non-null@Nullable public static Filter toFilter(@Nullable DimFilter dimFilter)
dimFilter - dimFilterpublic static ValueMatcher makeValueMatcher(ColumnSelectorFactory columnSelectorFactory, String columnName, String value)
An implementation of this method should be able to handle dimensions of various types.
columnSelectorFactory - Selector for columns.columnName - The column to filter.value - The value to match against, represented as a String.public static ValueMatcher makeValueMatcher(ColumnSelectorFactory columnSelectorFactory, String columnName, DruidPredicateFactory predicateFactory)
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.
columnSelectorFactory - Selector for columns.columnName - The column to filter.predicateFactory - Predicate factorypublic static ImmutableBitmap allFalse(BitmapIndexSelector selector)
public static ImmutableBitmap allTrue(BitmapIndexSelector selector)
public static <T> T matchPredicate(String dimension, BitmapIndexSelector selector, BitmapResultFactory<T> bitmapResultFactory, com.google.common.base.Predicate<String> predicate)
dimension - dimension to look atselector - bitmap selectorbitmapResultFactory - predicate - predicate to useestimateSelectivity(String, BitmapIndexSelector, Predicate)public static Iterable<ImmutableBitmap> matchPredicateNoUnion(String dimension, BitmapIndexSelector selector, com.google.common.base.Predicate<String> predicate)
matchPredicate(String, BitmapIndexSelector, BitmapResultFactory, Predicate)
would have returned.dimension - dimension to look atselector - bitmap selectorpredicate - predicate to usepublic static double estimateSelectivity(String dimension, BitmapIndexSelector indexSelector, com.google.common.base.Predicate<String> predicate)
dimension - dimension to look atindexSelector - bitmap selectorpredicate - predicate to usematchPredicate(String, BitmapIndexSelector, BitmapResultFactory, Predicate)public static double estimateSelectivity(BitmapIndex bitmapIndex, it.unimi.dsi.fastutil.ints.IntList bitmaps, long totalNumRows)
bitmapIndex - bitmap indexbitmaps - bitmaps to extract, by indextotalNumRows - number of rows in the column associated with this bitmap indexpublic static double estimateSelectivity(Iterator<ImmutableBitmap> bitmaps, long totalNumRows)
bitmaps - iterator of bitmapstotalNumRows - number of rows in the column associated with this bitmap index@Nullable public static Filter convertToCNFFromQueryContext(Query query, @Nullable Filter filter)
public static boolean shouldUseBitmapIndex(Filter filter, BitmapIndexSelector indexSelector, @Nullable FilterTuning filterTuning)
Filter.shouldUseBitmapIndex(BitmapIndexSelector) which takes
a Filter, a BitmapIndexSelector, and FilterTuning to determine if:
a) the filter supports bitmap indexes for all required columns
b) the filter tuning specifies that it should use the index
c) the cardinality of the column is above the minimum threshold and below the maximum threshold to use the index
If all these things are true, QueryableIndexStorageAdapter will utilize the
indexes.@Nullable public static Filter and(List<Filter> filterList)
filterList - List of filters@Nullable public static Filter or(Set<Filter> filterSet)
filterSet - Set of filterspublic static Set<Filter> toNormalizedOrClauses(Filter filter)
filter - the filter.public static boolean filterMatchesNull(Filter filter)
Copyright © 2011–2020 The Apache Software Foundation. All rights reserved.