Package org.apache.druid.query.filter
Class DimFilterUtils
- java.lang.Object
-
- org.apache.druid.query.filter.DimFilterUtils
-
public class DimFilterUtils extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static byteBLOOM_DIM_FILTER_CACHE_IDstatic byteSTRING_SEPARATOR
-
Constructor Summary
Constructors Constructor Description DimFilterUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Set<T>filterShards(DimFilter dimFilter, Set<String> filterFields, Iterable<T> input, com.google.common.base.Function<T,ShardSpec> converter, Map<String,Optional<com.google.common.collect.RangeSet<String>>> dimensionRangeCache)Filter the given iterable of objects by removing any object whose ShardSpec, obtained from the converter function, does not fit in the RangeSet of the dimFilterDimFilter.getDimensionRangeSet(String).static Set<String>onlyBaseFields(Set<String> fields, DataSourceAnalysis dataSourceAnalysis)Returns a copy of "fields" only including base fields fromDataSourceAnalysis.
-
-
-
Field Detail
-
BLOOM_DIM_FILTER_CACHE_ID
public static final byte BLOOM_DIM_FILTER_CACHE_ID
- See Also:
- Constant Field Values
-
STRING_SEPARATOR
public static final byte STRING_SEPARATOR
- See Also:
- Constant Field Values
-
-
Method Detail
-
filterShards
public static <T> Set<T> filterShards(@Nullable DimFilter dimFilter, @Nullable Set<String> filterFields, Iterable<T> input, com.google.common.base.Function<T,ShardSpec> converter, Map<String,Optional<com.google.common.collect.RangeSet<String>>> dimensionRangeCache)
Filter the given iterable of objects by removing any object whose ShardSpec, obtained from the converter function, does not fit in the RangeSet of the dimFilterDimFilter.getDimensionRangeSet(String). The returned set contains the filtered objects in the same order as they appear in input. DimensionRangedCache stores the RangeSets of different dimensions for the dimFilter. It should be re-used between calls with the same dimFilter to save redundant calls ofDimFilter.getDimensionRangeSet(String)on same dimensions.- Type Parameters:
T- This can be any type, as long as transform function is provided to convert this to ShardSpec- Parameters:
dimFilter- The filter to usefilterFields- Set of fields to consider for pruning, or null to consider all fieldsinput- The iterable of objects to be filteredconverter- The function to convert T to ShardSpec that can be filtered bydimensionRangeCache- The cache of RangeSets of different dimensions for the dimFilter- Returns:
- The set of filtered object, in the same order as input
-
onlyBaseFields
public static Set<String> onlyBaseFields(Set<String> fields, DataSourceAnalysis dataSourceAnalysis)
Returns a copy of "fields" only including base fields fromDataSourceAnalysis.- Parameters:
fields- field list, must be nonnulldataSourceAnalysis- analyzed datasource
-
-