Class NullableNumericAggregateCombiner<T>
- java.lang.Object
-
- org.apache.druid.query.aggregation.NullableNumericAggregateCombiner<T>
-
- All Implemented Interfaces:
AggregateCombiner<T>
,HotLoopCallee
,BaseDoubleColumnValueSelector
,BaseFloatColumnValueSelector
,BaseLongColumnValueSelector
,BaseNullableColumnValueSelector
,BaseObjectColumnValueSelector<T>
,ColumnValueSelector<T>
public final class NullableNumericAggregateCombiner<T> extends Object implements AggregateCombiner<T>
Null-aware numericAggregateCombiner
. Used byAggregatorFactory.makeAggregateCombiner()
to wrap non-null aware combiners. This class is only used when SQL compatible null handling is enabled.
-
-
Field Summary
-
Fields inherited from interface org.apache.druid.segment.ColumnValueSelector
EMPTY_ARRAY
-
-
Constructor Summary
Constructors Constructor Description NullableNumericAggregateCombiner(AggregateCombiner<T> delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Class
classOfObject()
Most-specific class of object returned byBaseObjectColumnValueSelector.getObject()
, if known in advance.void
fold(ColumnValueSelector selector)
Folds this AggregateCombiner's state value with the value of the given selector and saves it in this AggregateCombiner's state, e.double
getDouble()
float
getFloat()
long
getLong()
T
getObject()
Returns the currently-selected object.boolean
isNull()
Returns true if the primitive long, double, or float value returned by this selector should be treated as null.void
reset(ColumnValueSelector selector)
Resets this AggregateCombiner's state value to the value of the given selector, e.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.druid.query.aggregation.AggregateCombiner
inspectRuntimeShape
-
-
-
-
Constructor Detail
-
NullableNumericAggregateCombiner
public NullableNumericAggregateCombiner(AggregateCombiner<T> delegate)
-
-
Method Detail
-
reset
public void reset(ColumnValueSelector selector)
Description copied from interface:AggregateCombiner
Resets this AggregateCombiner's state value to the value of the given selector, e. g. after calling this method combiner.get*() should return the same value as selector.get*(). If the selector is anObjectColumnSelector
, the object returned fromBaseObjectColumnValueSelector.getObject()
must not be modified, and must not become a subject for modification during subsequentAggregateCombiner.fold(org.apache.druid.segment.ColumnValueSelector)
calls.- Specified by:
reset
in interfaceAggregateCombiner<T>
-
fold
public void fold(ColumnValueSelector selector)
Description copied from interface:AggregateCombiner
Folds this AggregateCombiner's state value with the value of the given selector and saves it in this AggregateCombiner's state, e. g. after calling combiner.fold(selector), combiner.get*() should return the value that would be the result ofaggregatorFactory.combine(combiner.get*(), selector.get*())
call. UnlikeAggregatorFactory.combine(java.lang.Object, java.lang.Object)
, if the selector is anObjectColumnSelector
, the object returned fromBaseObjectColumnValueSelector.getObject()
must not be modified, and must not become a subject for modification during subsequent fold() calls. Since the state of AggregateCombiner is undefined beforeAggregateCombiner.reset(org.apache.druid.segment.ColumnValueSelector)
is ever called on it, the effects of calling fold() are also undefined in this case.- Specified by:
fold
in interfaceAggregateCombiner<T>
- See Also:
AggregatorFactory.combine(java.lang.Object, java.lang.Object)
-
getFloat
public float getFloat()
- Specified by:
getFloat
in interfaceBaseFloatColumnValueSelector
-
getDouble
public double getDouble()
- Specified by:
getDouble
in interfaceBaseDoubleColumnValueSelector
-
getLong
public long getLong()
- Specified by:
getLong
in interfaceBaseLongColumnValueSelector
-
isNull
public boolean isNull()
Description copied from interface:BaseNullableColumnValueSelector
Returns true if the primitive long, double, or float value returned by this selector should be treated as null. Users ofBaseLongColumnValueSelector.getLong()
,BaseDoubleColumnValueSelector.getDouble()
andBaseFloatColumnValueSelector.getFloat()
must check this method first, or else they may improperly use placeholder values returned by the primitive get methods. Users ofBaseObjectColumnValueSelector.getObject()
should not call this method. Instead, call "getObject" and check if it is null.- Specified by:
isNull
in interfaceAggregateCombiner<T>
- Specified by:
isNull
in interfaceBaseNullableColumnValueSelector
-
getObject
@Nullable public T getObject()
Description copied from interface:BaseObjectColumnValueSelector
Returns the currently-selected object. The behavior of this method depends on the type of selector, which can be determined by callingColumnSelectorFactory.getColumnCapabilities(String)
on the sameColumnSelectorFactory
that you got this selector from. If the capabilties are nonnull, the selector type is given byTypeSignature.getType()
. String selectors, where type isColumnType.STRING
, may return any type of object from this method, especially in cases where the selector is casting objects to string at selection time. Callers are encouraged to avoid the need to deal with various objects by usingColumnSelectorFactory.makeDimensionSelector(org.apache.druid.query.dimension.DimensionSpec)
instead. Numeric selectors, whereTypeSignature.isNumeric()
, may return any type ofNumber
. Callers that wish to deal with more specific types should treat the originalColumnValueSelector
as aBaseLongColumnValueSelector
,BaseDoubleColumnValueSelector
, orBaseFloatColumnValueSelector
instead. Array selectors, whereTypeSignature.isArray()
, must returnObject[]
. The array may contain null elements, and the array itself may also be null. Selectors of unknown type, whereColumnSelectorFactory.getColumnCapabilities(String)
returns null, may return any type of object. Callers must be prepared for a wide variety of possible input objects. This case is common during ingestion, where selectors are built on top of external data.- Specified by:
getObject
in interfaceBaseObjectColumnValueSelector<T>
-
classOfObject
public Class classOfObject()
Description copied from interface:BaseObjectColumnValueSelector
Most-specific class of object returned byBaseObjectColumnValueSelector.getObject()
, if known in advance. This method returnsObject
when selectors do not know in advance what class of object they may return.- Specified by:
classOfObject
in interfaceBaseObjectColumnValueSelector<T>
-
-