Class PossiblyNullDimensionSelector
- All Implemented Interfaces:
HotLoopCallee,BaseDoubleColumnValueSelector,BaseFloatColumnValueSelector,BaseLongColumnValueSelector,BaseNullableColumnValueSelector,BaseObjectColumnValueSelector<Object>,ColumnValueSelector<Object>,DimensionDictionarySelector,DimensionSelector,IdLookup
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.druid.segment.DimensionSelector
DimensionSelector.NullDimensionSelectorHolder -
Field Summary
Fields inherited from interface org.apache.druid.segment.ColumnValueSelector
EMPTY_ARRAYFields inherited from interface org.apache.druid.segment.DimensionDictionarySelector
CARDINALITY_UNKNOWN -
Constructor Summary
ConstructorsConstructorDescriptionPossiblyNullDimensionSelector(DimensionSelector baseSelector, BooleanSupplier beNull) -
Method Summary
Modifier and TypeMethodDescriptionClass<?> Most-specific class of object returned byBaseObjectColumnValueSelector.getObject(), if known in advance.getRow()Returns the indexed values at the current position in this DimensionSelector.intValue cardinality is the cardinality of the different occurring values.idLookup()ReturnsIdLookupif available for this DimensionSelector, or null.voidinspectRuntimeShape(RuntimeShapeInspector inspector) Implementations of this method should callinspector.visit()with all fields of this class, which meet two conditions: 1.intInverse ofDimensionDictionarySelector.lookupName(int).lookupName(int id) Returns the value for a particular dictionary id as a Java String.makeValueMatcher(String value) makeValueMatcher(DruidPredicateFactory predicateFactory) booleanReturns true if it is possible toDimensionDictionarySelector.lookupName(int)by ids from 0 toDimensionDictionarySelector.getValueCardinality()before the rows with those ids are returned.Methods inherited from class org.apache.druid.segment.AbstractDimensionSelector
getObjectMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.druid.segment.DimensionDictionarySelector
lookupNameUtf8, supportsLookupNameUtf8Methods inherited from interface org.apache.druid.segment.DimensionSelector
defaultGetObject, getDouble, getFloat, getLong, isNull
-
Constructor Details
-
PossiblyNullDimensionSelector
-
-
Method Details
-
getRow
Description copied from interface:DimensionSelectorReturns the indexed values at the current position in this DimensionSelector. IMPORTANT. The returnedIndexedIntsobject could generally be reused inside the implementation of DimensionSelector, i. e. this method could always return the same object for the same selector. Users of this API, such asAggregator.aggregate(),BufferAggregator.aggregate(java.nio.ByteBuffer, int),AggregateCombiner.reset(org.apache.druid.segment.ColumnValueSelector),AggregateCombiner.fold(org.apache.druid.segment.ColumnValueSelector)should be prepared for that and not storing the object returned from this method in their state, assuming that the object will remain unchanged even when the position of the selector changes. This may not be the case.- Specified by:
getRowin interfaceDimensionSelector
-
makeValueMatcher
- Specified by:
makeValueMatcherin interfaceDimensionSelector- Parameters:
value- nullable dimension value
-
makeValueMatcher
- Specified by:
makeValueMatcherin interfaceDimensionSelector
-
getValueCardinality
public int getValueCardinality()Description copied from interface:DimensionDictionarySelectorValue cardinality is the cardinality of the different occurring values. If there were 4 rows: A,B A B A Value cardinality would be 2. Cardinality may be unknown (e.g. the selector used by IncrementalIndex while reading input rows), in which case this method will return -1. If cardinality is unknown, you should assume this dimension selector has no dictionary, and avoid storing ids, calling "lookupId", or calling "lookupName" outside of the context of operating on a single row. If cardinality is known then it is assumed that underlying dictionary is lexicographically sorted by the encoded value. For example if there are values "A" , "B" , "C" in a column with cardinality 3 then it is assumed that id("A") invalid input: '<' id("B") invalid input: '<' id("C")- Specified by:
getValueCardinalityin interfaceDimensionDictionarySelector- Returns:
- the value cardinality, or
DimensionDictionarySelector.CARDINALITY_UNKNOWNif unknown.
-
lookupName
Description copied from interface:DimensionDictionarySelectorReturns the value for a particular dictionary id as a Java String. For example, if a column has four rows: A,B A A,B B getRow() would return getRow(0) => [0 1] getRow(1) => [0] getRow(2) => [0 1] getRow(3) => [1] and then lookupName would return: lookupName(0) => A lookupName(1) => B Performance note: if you want ajava.lang.String, always use this method. It will be at least as fast as callingDimensionDictionarySelector.lookupNameUtf8(int)and decoding the bytes. However, if you want UTF-8 bytes, then check ifDimensionDictionarySelector.supportsLookupNameUtf8()returns true, and if it does, useDimensionDictionarySelector.lookupNameUtf8(int)instead.- Specified by:
lookupNamein interfaceDimensionDictionarySelector- Parameters:
id- id to lookup the dictionary value for- Returns:
- dictionary value for the given id, or null if the value is itself null
-
nameLookupPossibleInAdvance
public boolean nameLookupPossibleInAdvance()Description copied from interface:DimensionDictionarySelectorReturns true if it is possible toDimensionDictionarySelector.lookupName(int)by ids from 0 toDimensionDictionarySelector.getValueCardinality()before the rows with those ids are returned.Returns false if
DimensionDictionarySelector.lookupName(int)could be called with ids, returned from the most recent row (or row vector) returned by this DimensionSelector, but not earlier. IfDimensionDictionarySelector.getValueCardinality()of this selector additionally returnsDimensionDictionarySelector.CARDINALITY_UNKNOWN,lookupName()couldn't be called with ids, returned by not the most recent row (or row vector), i. e. names for ids couldn't be looked up "later". IfDimensionDictionarySelector.getValueCardinality()returns a non-negative number,lookupName()could be called with any ids, returned from rows (or row vectors) returned since the creation of this DimensionSelector.If
DimensionDictionarySelector.lookupName(int)is called with an ineligible id, result is undefined: exception could be thrown, or null returned, or some other random value.- Specified by:
nameLookupPossibleInAdvancein interfaceDimensionDictionarySelector
-
idLookup
Description copied from interface:DimensionDictionarySelectorReturnsIdLookupif available for this DimensionSelector, or null.- Specified by:
idLookupin interfaceDimensionDictionarySelector
-
lookupId
Description copied from interface:IdLookupInverse ofDimensionDictionarySelector.lookupName(int). -
inspectRuntimeShape
Description copied from interface:HotLoopCalleeImplementations of this method should callinspector.visit()with all fields of this class, which meet two conditions: 1. They are used in methods of this class, annotated withCalledFromHotLoop2. They are either: a. Nullable objects b. Instances of HotLoopCallee c. Objects, which don't always have a specific class in runtime. For example, a field of typeSetcould beHashSetorTreeSetin runtime, depending on how this instance (the instance on which inspectRuntimeShape() is called) is configured. d. ByteBuffer or similar objects, where byte order matters e. boolean flags, affecting branch taking f. Arrays of objects, meeting any of conditions a-e.- Specified by:
inspectRuntimeShapein interfaceHotLoopCallee
-
classOfObject
Description copied from interface:BaseObjectColumnValueSelectorMost-specific class of object returned byBaseObjectColumnValueSelector.getObject(), if known in advance. This method returnsObjectwhen selectors do not know in advance what class of object they may return.- Specified by:
classOfObjectin interfaceBaseObjectColumnValueSelector<Object>
-