public abstract class DictionaryEncodedColumnIndexer<KeyType,ActualType extends Comparable<ActualType>> extends Object implements DimensionIndexer<Integer,KeyType,ActualType>
Modifier and Type | Field and Description |
---|---|
protected DimensionDictionary<ActualType> |
dimLookup |
protected boolean |
isSparse |
protected SortedDimensionDictionary<ActualType> |
sortedLookup |
Constructor and Description |
---|
DictionaryEncodedColumnIndexer(DimensionDictionary<ActualType> dimLookup)
Creates a new DictionaryEncodedColumnIndexer.
|
Modifier and Type | Method and Description |
---|---|
ColumnValueSelector |
convertUnsortedValuesToSorted(ColumnValueSelector selectorWithUnsortedValues)
Converts dictionary-encoded row values from unspecified (random) encoding order, to sorted encoding.
|
protected boolean |
dictionaryEncodesAllValues()
returns true if all values are encoded in
dimLookup |
protected ActualType |
getActualValue(int intermediateValue,
boolean idSorted) |
int |
getCardinality()
Get the cardinality of this dimension's values.
|
protected int |
getEncodedValue(ActualType fullValue,
boolean idSorted) |
ActualType |
getMaxValue()
Get the maximum dimension value seen by this indexer.
|
ActualType |
getMinValue()
Get the minimum dimension value seen by this indexer.
|
int |
getSortedEncodedValueFromUnsorted(Integer unsortedIntermediateValue) |
CloseableIndexed<ActualType> |
getSortedIndexedValues()
Returns an indexed structure of this dimension's sorted actual values.
|
Integer |
getUnsortedEncodedValueFromSorted(Integer sortedIntermediateValue)
Given an encoded value that was ordered by associated actual value, return the equivalent
encoded value ordered by time of ingestion.
|
ColumnValueSelector<?> |
makeColumnValueSelector(IncrementalIndexRowHolder currEntry,
IncrementalIndex.DimensionDesc desc)
Return an object used to read values from this indexer's column.
|
void |
setSparseIndexed()
This method will be called while building an
IncrementalIndex whenever a known dimension column (either
through an explicit schema on the ingestion spec, or auto-discovered while processing rows) is absent in any row
that is processed, to allow an indexer to account for any missing rows if necessary. |
protected SortedDimensionDictionary<ActualType> |
sortedLookup() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
checkUnsortedEncodedKeyComponentsEqual, compareUnsortedEncodedKeyComponents, convertUnsortedEncodedKeyComponentToActualList, fillBitmapsFromUnsortedEncodedKeyComponent, getColumnCapabilities, getFormat, getUnsortedEncodedKeyComponentHashCode, makeDimensionSelector, processRowValsToUnsortedEncodedKeyComponent
protected final DimensionDictionary<ActualType extends Comparable<ActualType>> dimLookup
protected volatile boolean isSparse
@Nullable protected SortedDimensionDictionary<ActualType extends Comparable<ActualType>> sortedLookup
public DictionaryEncodedColumnIndexer(@NotNull DimensionDictionary<ActualType> dimLookup)
dimLookup
- Dimension Dictionary to lookup dimension values.public void setSparseIndexed()
DimensionIndexer
IncrementalIndex
whenever a known dimension column (either
through an explicit schema on the ingestion spec, or auto-discovered while processing rows) is absent in any row
that is processed, to allow an indexer to account for any missing rows if necessary. Useful so that a string
DimensionSelector
built on top of an IncrementalIndex
may accurately report
DimensionDictionarySelector.nameLookupPossibleInAdvance()
by allowing it to track if it has any implicit null valued
rows.
At index persist/merge time all missing columns for a row will be explicitly replaced with the value appropriate
null or default value.setSparseIndexed
in interface DimensionIndexer<Integer,KeyType,ActualType extends Comparable<ActualType>>
public int getSortedEncodedValueFromUnsorted(Integer unsortedIntermediateValue)
public Integer getUnsortedEncodedValueFromSorted(Integer sortedIntermediateValue)
DimensionIndexer
getUnsortedEncodedValueFromSorted
in interface DimensionIndexer<Integer,KeyType,ActualType extends Comparable<ActualType>>
sortedIntermediateValue
- value to convertpublic CloseableIndexed<ActualType> getSortedIndexedValues()
DimensionIndexer
getSortedIndexedValues
in interface DimensionIndexer<Integer,KeyType,ActualType extends Comparable<ActualType>>
public ActualType getMinValue()
DimensionIndexer
getMinValue
in interface DimensionIndexer<Integer,KeyType,ActualType extends Comparable<ActualType>>
public ActualType getMaxValue()
DimensionIndexer
getMaxValue
in interface DimensionIndexer<Integer,KeyType,ActualType extends Comparable<ActualType>>
public int getCardinality()
DimensionIndexer
getCardinality
in interface DimensionIndexer<Integer,KeyType,ActualType extends Comparable<ActualType>>
public ColumnValueSelector<?> makeColumnValueSelector(IncrementalIndexRowHolder currEntry, IncrementalIndex.DimensionDesc desc)
DimensionIndexer
makeColumnValueSelector
in interface DimensionIndexer<Integer,KeyType,ActualType extends Comparable<ActualType>>
currEntry
- Provides access to the current Row object in the Cursordesc
- Descriptor object for this dimension within an IncrementalIndexpublic ColumnValueSelector convertUnsortedValuesToSorted(ColumnValueSelector selectorWithUnsortedValues)
DimensionIndexer
DimensionMerger.convertSortedSegmentRowValuesToMergedRowValues(int, org.apache.druid.segment.ColumnValueSelector)
. The latter method requires sorted encoding
values on the input, because DimensionMerger.writeMergedValueDictionary(java.util.List<org.apache.druid.segment.IndexableAdapter>)
takes sorted lookups as it's input.
For columns which do not use the DimensionMerger
to merge dictionary encoded values, this method should
provide a selector which is compatible with the expectations of
DimensionMerger.processMergedRow(ColumnValueSelector)
, which might simply be to pass-through the 'unsorted'
selector.convertUnsortedValuesToSorted
in interface DimensionIndexer<Integer,KeyType,ActualType extends Comparable<ActualType>>
protected boolean dictionaryEncodesAllValues()
dimLookup
protected SortedDimensionDictionary<ActualType> sortedLookup()
@Nullable protected ActualType getActualValue(int intermediateValue, boolean idSorted)
protected int getEncodedValue(@Nullable ActualType fullValue, boolean idSorted)
Copyright © 2011–2023 The Apache Software Foundation. All rights reserved.