Class ValueMatchers

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

public class ValueMatchers extends Object
Utility methods for creating ValueMatcher instances. Mainly used by StringConstantValueMatcherFactory and PredicateValueMatcherFactory.
  • Method Details

    • 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 unless includeUnknown is set to true on the match function.
    • makeStringValueMatcher

      public static ValueMatcher makeStringValueMatcher(DimensionSelector selector, String value, boolean hasMultipleValues)
      Creates a constant-based ValueMatcher for a string-typed selector.
      Parameters:
      selector - column selector
      value - value to match
      hasMultipleValues - whether the column selector *might* have multiple values
    • makeStringValueMatcher

      public static ValueMatcher makeStringValueMatcher(DimensionSelector selector, DruidPredicateFactory predicateFactory, boolean hasMultipleValues)
      Creates a predicate-based ValueMatcher for a string-typed selector.
      Parameters:
      selector - column selector
      predicateFactory - predicate to match
      hasMultipleValues - whether the column selector *might* have multiple values
    • makeFloatValueMatcher

      public static ValueMatcher makeFloatValueMatcher(BaseFloatColumnValueSelector selector, String value)
      Creates a constant-based ValueMatcher for a float-typed selector.
      Parameters:
      selector - column selector
      value - value to match
    • makeFloatValueMatcher

      public static ValueMatcher makeFloatValueMatcher(BaseFloatColumnValueSelector selector, float value)
      Creates a constant-based ValueMatcher for a float-typed selector.
      Parameters:
      selector - column selector
      value - value to match
    • makeFloatValueMatcher

      public static ValueMatcher makeFloatValueMatcher(BaseFloatColumnValueSelector selector, DruidPredicateFactory predicateFactory)
      Creates a predicate-based ValueMatcher for a float-typed selector.
      Parameters:
      selector - column selector
      predicateFactory - predicate to match
    • makeLongValueMatcher

      public static ValueMatcher makeLongValueMatcher(BaseLongColumnValueSelector selector, String value)
      Creates a constant-based ValueMatcher for a long-typed selector.
      Parameters:
      selector - column selector
      value - value to match
    • makeLongValueMatcher

      public static ValueMatcher makeLongValueMatcher(BaseLongColumnValueSelector selector, long value)
      Creates a constant-based ValueMatcher for a long-typed selector.
      Parameters:
      selector - column selector
      value - value to match
    • makeLongValueMatcher

      public static ValueMatcher makeLongValueMatcher(BaseLongColumnValueSelector selector, DruidPredicateFactory predicateFactory)
      Creates a predicate-based ValueMatcher for a long-typed selector.
      Parameters:
      selector - column selector
      predicateFactory - predicate to match
    • makeDoubleValueMatcher

      public static ValueMatcher makeDoubleValueMatcher(BaseDoubleColumnValueSelector selector, String value)
      Creates a constant-based ValueMatcher for a double-typed selector.
      Parameters:
      selector - column selector
      value - value to match
    • makeDoubleValueMatcher

      public static ValueMatcher makeDoubleValueMatcher(BaseDoubleColumnValueSelector selector, double value)
      Creates a constant-based ValueMatcher for a double-typed selector.
      Parameters:
      selector - column selector
      value - value to match
    • makeDoubleValueMatcher

      public static ValueMatcher makeDoubleValueMatcher(BaseDoubleColumnValueSelector selector, DruidPredicateFactory predicateFactory)
      Creates a predicate-based ValueMatcher for a double-typed selector.
      Parameters:
      selector - column selector
      predicateFactory - predicate to match
    • makeAlwaysFalseWithNullUnknownDimensionMatcher

      public static ValueMatcher makeAlwaysFalseWithNullUnknownDimensionMatcher(DimensionSelector selector, boolean multiValue)
      Create a matcher that should always return false, except when includeUnknown 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.
    • makeAlwaysFalseWithNullUnknownNumericMatcher

      public static ValueMatcher makeAlwaysFalseWithNullUnknownNumericMatcher(BaseNullableColumnValueSelector selector)
      Create a matcher that should always return false, except when includeUnknown 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.
    • makeAlwaysFalseWithNullUnknownObjectMatcher

      public static ValueMatcher makeAlwaysFalseWithNullUnknownObjectMatcher(BaseObjectColumnValueSelector<?> selector)
      Create a matcher that should always return false, except when includeUnknown 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, DruidObjectPredicate<String> predicate)
      If applying predicate to selector would always return a constant, returns that constant. Otherwise, returns null. This method would have been private, except it's also used by SingleValueStringVectorValueMatcher.
      Parameters:
      selector - string selector
      hasMultipleValues - whether the selector *might* have multiple values
      predicate - predicate to apply