Package org.apache.druid.segment
Interface DimensionHandler<EncodedType extends Comparable<EncodedType>,EncodedKeyComponentType,ActualType extends Comparable<ActualType>>
-
- Type Parameters:
EncodedType
- class of a single encoded valueEncodedKeyComponentType
- A row key contains a component for each dimension, this param specifies the class of this dimension's key component. A column type that supports multivalue rows should use an array type (Strings would use int[]). Column types without multivalue row support should use single objects (e.g., Long, Float).ActualType
- class of a single actual value
- All Known Implementing Classes:
DoubleDimensionHandler
,FloatDimensionHandler
,LongDimensionHandler
,NestedCommonFormatColumnHandler
,NestedDataColumnHandlerV4
,StringDimensionHandler
public interface DimensionHandler<EncodedType extends Comparable<EncodedType>,EncodedKeyComponentType,ActualType extends Comparable<ActualType>>
Processing related interface A DimensionHandler is an object that encapsulates indexing, column merging/building, and querying operations for a given dimension type (e.g., dict-encoded String, Long). These operations are handled by sub-objects created through a DimensionHandler's methods: DimensionIndexer, DimensionMerger, and DimensionColumnReader, respectively. Each DimensionHandler object is associated with a single dimension. This interface allows type-specific behavior column logic, such as choice of indexing structures and disk formats. to be contained within a type-specific set of handler objects, simplifying processing classes such asIncrementalIndex
andIndexMerger
and allowing for abstracted development of additional dimension types. A DimensionHandler is a stateless object, and thus thread-safe; its methods should be pure functions. The EncodedType and ActualType are Comparable because columns used as dimensions must have sortable values.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description String
getDimensionName()
Get the name of the column associated with this handler.DimensionSchema
getDimensionSchema(ColumnCapabilities capabilities)
default DimensionSpec
getDimensionSpec()
Create aDimensionSpec
for this handlerComparator<ColumnValueSelector>
getEncodedValueSelectorComparator()
Returns a comparator that knows how to compareColumnValueSelector
of the assumed dimension type, corresponding to this DimensionHandler.int
getLengthOfEncodedKeyComponent(EncodedKeyComponentType dimVals)
Given an key component representing a single set of row value(s) for this dimension as an Object, return the length of the key component after appropriate type-casting.default DimensionSchema.MultiValueHandling
getMultivalueHandling()
GetDimensionSchema.MultiValueHandling
for the column associated with this handler.DimensionIndexer<EncodedType,EncodedKeyComponentType,ActualType>
makeIndexer(boolean useMaxMemoryEstimates)
Creates a new DimensionIndexer, a per-dimension object responsible for processing ingested rows in-memory, used by the IncrementalIndex.DimensionMergerV9
makeMerger(IndexSpec indexSpec, SegmentWriteOutMedium segmentWriteOutMedium, ColumnCapabilities capabilities, ProgressIndicator progress, Closer closer)
Creates a new DimensionMergerV9, a per-dimension object responsible for merging indexes/row data across segments and building the on-disk representation of a dimension.SettableColumnValueSelector
makeNewSettableEncodedValueSelector()
Creates and returns a new object of some implementation ofSettableColumnValueSelector
, that corresponds to the type of this DimensionHandler.
-
-
-
Method Detail
-
getDimensionName
String getDimensionName()
Get the name of the column associated with this handler. This string would be the output name of the column during ingestion, and the name of an input column when querying.- Returns:
- Dimension name
-
getDimensionSpec
default DimensionSpec getDimensionSpec()
Create aDimensionSpec
for this handler
-
getDimensionSchema
DimensionSchema getDimensionSchema(ColumnCapabilities capabilities)
-
getMultivalueHandling
@Nullable default DimensionSchema.MultiValueHandling getMultivalueHandling()
GetDimensionSchema.MultiValueHandling
for the column associated with this handler. Only string columns can haveDimensionSchema.MultiValueHandling
currently.
-
makeIndexer
DimensionIndexer<EncodedType,EncodedKeyComponentType,ActualType> makeIndexer(boolean useMaxMemoryEstimates)
Creates a new DimensionIndexer, a per-dimension object responsible for processing ingested rows in-memory, used by the IncrementalIndex. SeeDimensionIndexer
interface for more information.- Parameters:
useMaxMemoryEstimates
- true if the created DimensionIndexer should use maximum values to estimate on-heap memory- Returns:
- A new DimensionIndexer object.
-
makeMerger
DimensionMergerV9 makeMerger(IndexSpec indexSpec, SegmentWriteOutMedium segmentWriteOutMedium, ColumnCapabilities capabilities, ProgressIndicator progress, Closer closer)
Creates a new DimensionMergerV9, a per-dimension object responsible for merging indexes/row data across segments and building the on-disk representation of a dimension. For use with IndexMergerV9 only. SeeDimensionMergerV9
interface for more information.- Parameters:
indexSpec
- Specification object for the index mergesegmentWriteOutMedium
- this SegmentWriteOutMedium object could be used internally in the created merger, if neededcapabilities
- The ColumnCapabilities of the dimension represented by this DimensionHandlerprogress
- ProgressIndicator used by the merging process- Returns:
- A new DimensionMergerV9 object.
-
getLengthOfEncodedKeyComponent
int getLengthOfEncodedKeyComponent(EncodedKeyComponentType dimVals)
Given an key component representing a single set of row value(s) for this dimension as an Object, return the length of the key component after appropriate type-casting. For example, a dictionary encoded String dimension would receive an int[] as input to this method, while a Long numeric dimension would receive a single Long object (no multivalue support)- Parameters:
dimVals
- Values for this dimension from a row- Returns:
- Size of dimVals
-
getEncodedValueSelectorComparator
Comparator<ColumnValueSelector> getEncodedValueSelectorComparator()
Returns a comparator that knows how to compareColumnValueSelector
of the assumed dimension type, corresponding to this DimensionHandler. E. g.StringDimensionHandler
returns a comparator, that comparesColumnValueSelector
s asDimensionSelector
s. The comparison rules used by this method should match the rules used byDimensionIndexer.compareUnsortedEncodedKeyComponents(EncodedKeyComponentType, EncodedKeyComponentType)
, otherwise incorrect ordering/merging of rows can occur during ingestion, causing issues such as imperfect rollup.
-
makeNewSettableEncodedValueSelector
SettableColumnValueSelector makeNewSettableEncodedValueSelector()
Creates and returns a new object of some implementation ofSettableColumnValueSelector
, that corresponds to the type of this DimensionHandler. E. g.LongDimensionHandler
returnsSettableLongColumnValueSelector
, etc.
-
-