Package org.apache.druid.segment
Class DimensionDictionary<T extends Comparable<T>>
- java.lang.Object
-
- org.apache.druid.segment.DimensionDictionary<T>
-
- Direct Known Subclasses:
StringDimensionDictionary
public abstract class DimensionDictionary<T extends Comparable<T>> extends Object
Buildable dictionary for some comparable type. Values are unsorted, or rather sorted in the order which they are added. ASortedDimensionDictionarycan be constructed with a mapping of ids from this dictionary to the sorted dictionary with thesort()method.Concrete implementations of this dictionary must be thread-safe.
-
-
Field Summary
Fields Modifier and Type Field Description static intABSENT_VALUE_ID
-
Constructor Summary
Constructors Constructor Description DimensionDictionary(Class<T> cls)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description intadd(T originalValue)abstract booleancomputeOnHeapSize()Whether on-heap size of this dictionary should be computed.abstract longestimateSizeOfValue(T value)Estimates the size of the dimension value in bytes.intgetId(T value)intgetIdForNull()TgetMaxValue()TgetMinValue()TgetValue(int id)T[]getValues(int[] ids)intsize()longsizeInBytes()Gets the current size of this dictionary in bytes.SortedDimensionDictionary<T>sort()
-
-
-
Field Detail
-
ABSENT_VALUE_ID
public static final int ABSENT_VALUE_ID
- See Also:
- Constant Field Values
-
-
Method Detail
-
getValues
public T[] getValues(int[] ids)
-
size
public int size()
-
sizeInBytes
public long sizeInBytes()
Gets the current size of this dictionary in bytes.- Throws:
IllegalStateException- if size computation is disabled.
-
getMinValue
public T getMinValue()
-
getMaxValue
public T getMaxValue()
-
getIdForNull
public int getIdForNull()
-
sort
public SortedDimensionDictionary<T> sort()
-
estimateSizeOfValue
public abstract long estimateSizeOfValue(T value)
Estimates the size of the dimension value in bytes.This method is called when adding a new dimension value to the lookup only if
computeOnHeapSize()returns true.
-
computeOnHeapSize
public abstract boolean computeOnHeapSize()
Whether on-heap size of this dictionary should be computed.
-
-