Package org.apache.druid.segment
Class DimensionHandlerUtils
java.lang.Object
org.apache.druid.segment.DimensionHandlerUtils
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ColumnCapabilitiesstatic final ConcurrentHashMap<String, DimensionHandlerProvider> static final Doublestatic final Floatstatic final Long -
Method Summary
Modifier and TypeMethodDescriptionstatic Object[]coerceToObjectArrayWithElementCoercionFunction(Object obj, Function<Object, Object> coercionFunction) static Object[]static intcompareObjectsAsType(Object lhs, Object rhs, ColumnType type) converterFromTypeToType(TypeSignature<ValueType> fromType, TypeSignature<ValueType> toType) Used by TopN engine for type coercionstatic DoubleconvertObjectToDouble(Object valObj) static DoubleconvertObjectToDouble(Object valObj, boolean reportParseExceptions) static DoubleconvertObjectToDouble(Object valObj, boolean reportParseExceptions, String fieldName) static DoubleconvertObjectToDouble(Object valObj, String fieldName) static FloatconvertObjectToFloat(Object valObj) static FloatconvertObjectToFloat(Object valObj, boolean reportParseExceptions) static FloatconvertObjectToFloat(Object valObj, boolean reportParseExceptions, String fieldName) static FloatconvertObjectToFloat(Object valObj, String fieldName) static LongconvertObjectToLong(Object valObj) static LongconvertObjectToLong(Object valObj, boolean reportParseExceptions) static LongconvertObjectToLong(Object valObj, boolean reportParseExceptions, String objectKey) static LongconvertObjectToLong(Object valObj, String fieldName) static StringconvertObjectToString(Object valObj) static ObjectconvertObjectToType(Object obj, TypeSignature<ValueType> type) static ObjectconvertObjectToType(Object obj, TypeSignature<ValueType> type, boolean reportParseExceptions) static ObjectconvertObjectToType(Object obj, TypeSignature<ValueType> type, boolean reportParseExceptions, String fieldName) static Object[]convertToArray(Object obj, TypeSignature<ValueType> elementType) static <Strategy extends ColumnSelectorStrategy>
ColumnSelectorPlus<Strategy> createColumnSelectorPlus(ColumnSelectorStrategyFactory<Strategy> strategyFactory, DimensionSpec dimensionSpec, ColumnSelectorFactory cursor) Convenience function equivalent to callingcreateColumnSelectorPluses(ColumnSelectorStrategyFactory, List, ColumnSelectorFactory)with a singleton list of dimensionSpecs and then retrieving the only element in the returned array.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.static LonggetExactLongFromDecimalString(String decimalStr) Convert a string representing a decimal value to a long.static DimensionHandler<?, ?, ?> getHandlerFromCapabilities(String dimensionName, ColumnCapabilities capabilities, DimensionSchema.MultiValueHandling multiValueHandling) static List<ColumnType> getValueTypesFromDimensionSpecs(List<DimensionSpec> dimSpecs) static booleanstatic DoublenullToZero(Double number) static FloatnullToZero(Float number) static LongnullToZero(Long number) static voidregisterDimensionHandlerProvider(String type, DimensionHandlerProvider provider)
-
Field Details
-
ZERO_DOUBLE
-
ZERO_FLOAT
-
ZERO_LONG
-
DEFAULT_STRING_CAPABILITIES
-
DIMENSION_HANDLER_PROVIDERS
-
-
Method Details
-
registerDimensionHandlerProvider
-
getHandlerFromCapabilities
public static DimensionHandler<?,?, getHandlerFromCapabilities?> (String dimensionName, @Nullable ColumnCapabilities capabilities, @Nullable DimensionSchema.MultiValueHandling multiValueHandling) -
getValueTypesFromDimensionSpecs
-
createColumnSelectorPlus
public static <Strategy extends ColumnSelectorStrategy> ColumnSelectorPlus<Strategy> createColumnSelectorPlus(ColumnSelectorStrategyFactory<Strategy> strategyFactory, DimensionSpec dimensionSpec, ColumnSelectorFactory cursor) Convenience function equivalent to callingcreateColumnSelectorPluses(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 strategiesdimensionSpec- column to generate a ColumnSelectorPlus object forcursor- 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 strategiesdimensionSpecs- The set of columns to generate ColumnSelectorPlus objects forcolumnSelectorFactory- 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
-
convertObjectToLong
-
convertObjectToLong
-
convertObjectToLong
-
convertObjectToLong
-
convertObjectToFloat
-
convertObjectToFloat
-
convertObjectToFloat
-
convertObjectToFloat
-
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
-
coerceToObjectArrayWithElementCoercionFunction
-
coerceToStringArray
-
compareObjectsAsType
-
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
-
convertObjectToDouble
-
convertObjectToDouble
-
convertObjectToDouble
-
getExactLongFromDecimalString
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
-
nullToZero
-
nullToZero
-
isNumericNull
-