Package org.apache.druid.segment.filter
Class ValueMatchers
- java.lang.Object
-
- org.apache.druid.segment.filter.ValueMatchers
-
public class ValueMatchers extends Object
Utility methods for creatingValueMatcher
instances. Mainly used byStringConstantValueMatcherFactory
andPredicateValueMatcherFactory
.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ValueMatcher
allFalse()
Matcher for constant 'false' condition, where rows will never be matchedstatic ValueMatcher
allTrue()
Matcher for constant 'true' condition, where all rows should always matchstatic ValueMatcher
allUnknown()
Matcher for constant 'unknown' condition, such as a column of all null values, where rows will never match unlessincludeUnknown
is set to true on the match function.static ValueMatcher
makeAlwaysFalseDimensionMatcher(DimensionSelector selector, boolean multiValue)
Create a matcher that should always return false, except whenincludeUnknown
is set, in which case only null values will be matched.static ValueMatcher
makeAlwaysFalseNumericMatcher(BaseNullableColumnValueSelector selector)
Create a matcher that should always return false, except whenincludeUnknown
is set, in which case only null values will be matched.static ValueMatcher
makeAlwaysFalseObjectMatcher(BaseObjectColumnValueSelector<?> selector)
Create a matcher that should always return false, except whenincludeUnknown
is set, in which case only null values will be matched.static ValueMatcher
makeDoubleValueMatcher(BaseDoubleColumnValueSelector selector, double value)
Creates a constant-basedValueMatcher
for a double-typed selector.static ValueMatcher
makeDoubleValueMatcher(BaseDoubleColumnValueSelector selector, String value)
Creates a constant-basedValueMatcher
for a double-typed selector.static ValueMatcher
makeDoubleValueMatcher(BaseDoubleColumnValueSelector selector, DruidPredicateFactory predicateFactory)
Creates a predicate-basedValueMatcher
for a double-typed selector.static ValueMatcher
makeFloatValueMatcher(BaseFloatColumnValueSelector selector, float value)
Creates a constant-basedValueMatcher
for a float-typed selector.static ValueMatcher
makeFloatValueMatcher(BaseFloatColumnValueSelector selector, String value)
Creates a constant-basedValueMatcher
for a float-typed selector.static ValueMatcher
makeFloatValueMatcher(BaseFloatColumnValueSelector selector, DruidPredicateFactory predicateFactory)
Creates a predicate-basedValueMatcher
for a float-typed selector.static ValueMatcher
makeLongValueMatcher(BaseLongColumnValueSelector selector, long value)
Creates a constant-basedValueMatcher
for a long-typed selector.static ValueMatcher
makeLongValueMatcher(BaseLongColumnValueSelector selector, String value)
Creates a constant-basedValueMatcher
for a long-typed selector.static ValueMatcher
makeLongValueMatcher(BaseLongColumnValueSelector selector, DruidPredicateFactory predicateFactory)
Creates a predicate-basedValueMatcher
for a long-typed selector.static ValueMatcher
makeStringValueMatcher(DimensionSelector selector, String value, boolean hasMultipleValues)
Creates a constant-basedValueMatcher
for a string-typed selector.static ValueMatcher
makeStringValueMatcher(DimensionSelector selector, DruidPredicateFactory predicateFactory, boolean hasMultipleValues)
Creates a predicate-basedValueMatcher
for a string-typed selector.static ConstantMatcherType
toConstantMatcherTypeIfPossible(DimensionDictionarySelector selector, boolean hasMultipleValues, com.google.common.base.Predicate<String> predicate)
If applyingpredicate
toselector
would always return a constant, returns that constant.
-
-
-
Method Detail
-
allTrue
public static ValueMatcher allTrue()
Matcher for constant 'true' condition, where all rows should always match
-
allFalse
public static ValueMatcher allFalse()
Matcher for constant 'false' condition, where rows will never be matched
-
allUnknown
public static ValueMatcher allUnknown()
Matcher for constant 'unknown' condition, such as a column of all null values, where rows will never match unlessincludeUnknown
is set to true on the match function.
-
makeStringValueMatcher
public static ValueMatcher makeStringValueMatcher(DimensionSelector selector, String value, boolean hasMultipleValues)
Creates a constant-basedValueMatcher
for a string-typed selector.- Parameters:
selector
- column selectorvalue
- value to matchhasMultipleValues
- whether the column selector *might* have multiple values
-
makeStringValueMatcher
public static ValueMatcher makeStringValueMatcher(DimensionSelector selector, DruidPredicateFactory predicateFactory, boolean hasMultipleValues)
Creates a predicate-basedValueMatcher
for a string-typed selector.- Parameters:
selector
- column selectorpredicateFactory
- predicate to matchhasMultipleValues
- whether the column selector *might* have multiple values
-
makeFloatValueMatcher
public static ValueMatcher makeFloatValueMatcher(BaseFloatColumnValueSelector selector, String value)
Creates a constant-basedValueMatcher
for a float-typed selector.- Parameters:
selector
- column selectorvalue
- value to match
-
makeFloatValueMatcher
public static ValueMatcher makeFloatValueMatcher(BaseFloatColumnValueSelector selector, float value)
Creates a constant-basedValueMatcher
for a float-typed selector.- Parameters:
selector
- column selectorvalue
- value to match
-
makeFloatValueMatcher
public static ValueMatcher makeFloatValueMatcher(BaseFloatColumnValueSelector selector, DruidPredicateFactory predicateFactory)
Creates a predicate-basedValueMatcher
for a float-typed selector.- Parameters:
selector
- column selectorpredicateFactory
- predicate to match
-
makeLongValueMatcher
public static ValueMatcher makeLongValueMatcher(BaseLongColumnValueSelector selector, String value)
Creates a constant-basedValueMatcher
for a long-typed selector.- Parameters:
selector
- column selectorvalue
- value to match
-
makeLongValueMatcher
public static ValueMatcher makeLongValueMatcher(BaseLongColumnValueSelector selector, long value)
Creates a constant-basedValueMatcher
for a long-typed selector.- Parameters:
selector
- column selectorvalue
- value to match
-
makeLongValueMatcher
public static ValueMatcher makeLongValueMatcher(BaseLongColumnValueSelector selector, DruidPredicateFactory predicateFactory)
Creates a predicate-basedValueMatcher
for a long-typed selector.- Parameters:
selector
- column selectorpredicateFactory
- predicate to match
-
makeDoubleValueMatcher
public static ValueMatcher makeDoubleValueMatcher(BaseDoubleColumnValueSelector selector, String value)
Creates a constant-basedValueMatcher
for a double-typed selector.- Parameters:
selector
- column selectorvalue
- value to match
-
makeDoubleValueMatcher
public static ValueMatcher makeDoubleValueMatcher(BaseDoubleColumnValueSelector selector, double value)
Creates a constant-basedValueMatcher
for a double-typed selector.- Parameters:
selector
- column selectorvalue
- value to match
-
makeDoubleValueMatcher
public static ValueMatcher makeDoubleValueMatcher(BaseDoubleColumnValueSelector selector, DruidPredicateFactory predicateFactory)
Creates a predicate-basedValueMatcher
for a double-typed selector.- Parameters:
selector
- column selectorpredicateFactory
- predicate to match
-
makeAlwaysFalseDimensionMatcher
public static ValueMatcher makeAlwaysFalseDimensionMatcher(DimensionSelector selector, boolean multiValue)
Create a matcher that should always return false, except whenincludeUnknown
is set, in which case only null values will be matched. This is typically used when the filter should never match any actual values, but still needs to be able to report 'unknown' matches.
-
makeAlwaysFalseNumericMatcher
public static ValueMatcher makeAlwaysFalseNumericMatcher(BaseNullableColumnValueSelector selector)
Create a matcher that should always return false, except whenincludeUnknown
is set, in which case only null values will be matched. This is typically used when the filter should never match any actual values, but still needs to be able to report 'unknown' matches.
-
makeAlwaysFalseObjectMatcher
public static ValueMatcher makeAlwaysFalseObjectMatcher(BaseObjectColumnValueSelector<?> selector)
Create a matcher that should always return false, except whenincludeUnknown
is set, in which case only null values will be matched. This is typically used when the filter should never match any actual values, but still needs to be able to report 'unknown' matches.
-
toConstantMatcherTypeIfPossible
@Nullable public static ConstantMatcherType toConstantMatcherTypeIfPossible(DimensionDictionarySelector selector, boolean hasMultipleValues, com.google.common.base.Predicate<String> predicate)
If applyingpredicate
toselector
would always return a constant, returns that constant. Otherwise, returns null. This method would have been private, except it's also used bySingleValueStringVectorValueMatcher
.- Parameters:
selector
- string selectorhasMultipleValues
- whether the selector *might* have multiple valuespredicate
- predicate to apply
-
-