Class DimensionHandlerUtils

java.lang.Object
org.apache.druid.segment.DimensionHandlerUtils

public final class DimensionHandlerUtils extends Object
  • Field Details

  • Method Details

    • registerDimensionHandlerProvider

      public static void registerDimensionHandlerProvider(String type, DimensionHandlerProvider provider)
    • getHandlerFromCapabilities

      public static DimensionHandler<?,?,?> getHandlerFromCapabilities(String dimensionName, @Nullable ColumnCapabilities capabilities, @Nullable DimensionSchema.MultiValueHandling multiValueHandling)
    • getValueTypesFromDimensionSpecs

      public static List<ColumnType> getValueTypesFromDimensionSpecs(List<DimensionSpec> dimSpecs)
    • createColumnSelectorPlus

      public static <Strategy extends ColumnSelectorStrategy> ColumnSelectorPlus<Strategy> createColumnSelectorPlus(ColumnSelectorStrategyFactory<Strategy> strategyFactory, DimensionSpec dimensionSpec, ColumnSelectorFactory cursor)
      Convenience function equivalent to calling createColumnSelectorPluses(ColumnSelectorStrategyFactory, List, ColumnSelectorFactory) with a singleton list of dimensionSpecs and then retrieving the only element in the returned array.
      Type Parameters:
      Strategy - The strategy type created by the provided strategy factory.
      Parameters:
      strategyFactory - A factory provided by query engines that generates type-handling strategies
      dimensionSpec - column to generate a ColumnSelectorPlus object for
      cursor - Used to create value selectors for columns.
      Returns:
      A ColumnSelectorPlus object
      See Also:
    • createColumnSelectorPluses

      public static <Strategy extends ColumnSelectorStrategy> ColumnSelectorPlus<Strategy>[] createColumnSelectorPluses(ColumnSelectorStrategyFactory<Strategy> strategyFactory, List<DimensionSpec> dimensionSpecs, ColumnSelectorFactory columnSelectorFactory)
      Creates an array of ColumnSelectorPlus objects, selectors that handle type-specific operations within query processing engines, using a strategy factory provided by the query engine. One ColumnSelectorPlus will be created for each column specified in dimensionSpecs.

      The ColumnSelectorPlus provides access to a type strategy (e.g., how to group on a float column) and a value selector for a single column.

      A caller should define a strategy factory that provides an interface for type-specific operations in a query engine. See GroupByStrategyFactory for a reference.

      Type Parameters:
      Strategy - The strategy type created by the provided strategy factory.
      Parameters:
      strategyFactory - A factory provided by query engines that generates type-handling strategies
      dimensionSpecs - The set of columns to generate ColumnSelectorPlus objects for
      columnSelectorFactory - Used to create value selectors for columns.
      Returns:
      An array of ColumnSelectorPlus objects, in the order of the columns specified in dimensionSpecs
      See Also:
    • convertObjectToString

      @Nullable public static String convertObjectToString(@Nullable Object valObj)
    • convertObjectToLong

      @Nullable public static Long convertObjectToLong(@Nullable Object valObj, boolean reportParseExceptions, @Nullable String objectKey)
    • convertObjectToLong

      @Nullable public static Long convertObjectToLong(@Nullable Object valObj)
    • convertObjectToLong

      @Nullable public static Long convertObjectToLong(@Nullable Object valObj, boolean reportParseExceptions)
    • convertObjectToLong

      @Nullable public static Long convertObjectToLong(@Nullable Object valObj, @Nullable String fieldName)
    • convertObjectToFloat

      @Nullable public static Float convertObjectToFloat(@Nullable Object valObj)
    • convertObjectToFloat

      @Nullable public static Float convertObjectToFloat(@Nullable Object valObj, boolean reportParseExceptions)
    • convertObjectToFloat

      @Nullable public static Float convertObjectToFloat(@Nullable Object valObj, @Nullable String fieldName)
    • convertObjectToFloat

      @Nullable public static Float convertObjectToFloat(@Nullable Object valObj, boolean reportParseExceptions, @Nullable String fieldName)
    • convertObjectToType

      @Nullable public static Object convertObjectToType(@Nullable Object obj, TypeSignature<ValueType> type, boolean reportParseExceptions, @Nullable String fieldName)
    • convertObjectToType

      @Nullable public static Object convertObjectToType(@Nullable Object obj, TypeSignature<ValueType> type, boolean reportParseExceptions)
    • convertToArray

      @Nullable public static Object[] convertToArray(Object obj, TypeSignature<ValueType> elementType)
    • coerceToObjectArrayWithElementCoercionFunction

      @Nullable public static Object[] coerceToObjectArrayWithElementCoercionFunction(@Nullable Object obj, Function<Object,Object> coercionFunction)
    • coerceToStringArray

      @Nullable public static Object[] coerceToStringArray(Object obj)
    • compareObjectsAsType

      public static int compareObjectsAsType(@Nullable Object lhs, @Nullable Object rhs, ColumnType type)
    • convertObjectToType

      @Nullable public static Object convertObjectToType(@Nullable Object obj, TypeSignature<ValueType> type)
    • converterFromTypeToType

      public static Function<Object,Object> converterFromTypeToType(TypeSignature<ValueType> fromType, TypeSignature<ValueType> toType)
      Used by TopN engine for type coercion
    • convertObjectToDouble

      @Nullable public static Double convertObjectToDouble(@Nullable Object valObj)
    • convertObjectToDouble

      @Nullable public static Double convertObjectToDouble(@Nullable Object valObj, boolean reportParseExceptions)
    • convertObjectToDouble

      @Nullable public static Double convertObjectToDouble(@Nullable Object valObj, @Nullable String fieldName)
    • convertObjectToDouble

      @Nullable public static Double convertObjectToDouble(@Nullable Object valObj, boolean reportParseExceptions, @Nullable String fieldName)
    • getExactLongFromDecimalString

      @Nullable public static Long getExactLongFromDecimalString(String decimalStr)
      Convert a string representing a decimal value to a long.

      If the decimal value is not an exact integral value (e.g. 42.0), or if the decimal value is too large to be contained within a long, this function returns null.

      Parameters:
      decimalStr - string representing a decimal value
      Returns:
      long equivalent of decimalStr, returns null for non-integral decimals and integral decimal values outside of the values representable by longs
    • nullToZero

      public static Double nullToZero(@Nullable Double number)
    • nullToZero

      public static Long nullToZero(@Nullable Long number)
    • nullToZero

      public static Float nullToZero(@Nullable Float number)
    • isNumericNull

      public static boolean isNumericNull(@Nullable Object o)