Class NullableNumericAggregatorFactory<T extends BaseNullableColumnValueSelector>
- java.lang.Object
-
- org.apache.druid.query.aggregation.AggregatorFactory
-
- org.apache.druid.query.aggregation.NullableNumericAggregatorFactory<T>
-
- All Implemented Interfaces:
Cacheable
- Direct Known Subclasses:
SimpleDoubleAggregatorFactory
,SimpleFloatAggregatorFactory
,SimpleLongAggregatorFactory
public abstract class NullableNumericAggregatorFactory<T extends BaseNullableColumnValueSelector> extends AggregatorFactory
Abstract superclass for null-aware numeric aggregators. Includes functionality to wrapAggregator
,BufferAggregator
,VectorAggregator
, andAggregateCombiner
to support nullable aggregations. The result of this aggregator will be null if all the values to be aggregated are null values, or if no values are aggregated at all. If any of the values are non-null, the result will be the aggregated value of the non-null values. This superclass should only be extended by aggregators that read primitive numbers. It implements logic that is not valid for non-numeric selector methods such asBaseObjectColumnValueSelector.getObject()
.
-
-
Constructor Summary
Constructors Constructor Description NullableNumericAggregatorFactory()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Aggregator
factorize(ColumnSelectorFactory columnSelectorFactory)
protected abstract Aggregator
factorize(ColumnSelectorFactory columnSelectorFactory, T selector)
Creates anAggregator
to aggregate values from several rows, by using the provided selector.BufferAggregator
factorizeBuffered(ColumnSelectorFactory columnSelectorFactory)
protected abstract BufferAggregator
factorizeBuffered(ColumnSelectorFactory columnSelectorFactory, T selector)
Creates anBufferAggregator
to aggregate values from several rows into a ByteBuffer.VectorAggregator
factorizeVector(VectorColumnSelectorFactory columnSelectorFactory)
Create a VectorAggregator based on the provided column selector factory.protected VectorAggregator
factorizeVector(VectorColumnSelectorFactory columnSelectorFactory, VectorValueSelector selector)
Creates aVectorAggregator
to aggregate values from several rows into a ByteBuffer.int
getMaxIntermediateSizeWithNulls()
Returns the maximum size that this aggregator will require in bytes for intermediate storage of results.ColumnType
getResultType()
Get theColumnType
for the final form of this aggregator, i.e.AggregateCombiner
makeNullableAggregateCombiner()
Creates anAggregateCombiner
which supports nullability.protected abstract T
selector(ColumnSelectorFactory columnSelectorFactory)
Creates aColumnValueSelector
for the aggregated column.protected VectorValueSelector
vectorSelector(VectorColumnSelectorFactory columnSelectorFactory)
Creates aVectorValueSelector
for the aggregated column.-
Methods inherited from class org.apache.druid.query.aggregation.AggregatorFactory
canVectorize, combine, deserialize, factorizeWithSize, finalizeComputation, getCombiningFactory, getComparator, getComplexTypeName, getFinalizedType, getIntermediateType, getMaxIntermediateSize, getMergingFactory, getName, getRequiredColumns, getType, guessAggregatorHeapFootprint, makeAggregateCombiner, mergeAggregators, optimizeForSegment, requiredFields, withName
-
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.java.util.common.Cacheable
getCacheKey
-
-
-
-
Method Detail
-
factorize
public final Aggregator factorize(ColumnSelectorFactory columnSelectorFactory)
- Specified by:
factorize
in classAggregatorFactory
-
factorizeBuffered
public final BufferAggregator factorizeBuffered(ColumnSelectorFactory columnSelectorFactory)
- Specified by:
factorizeBuffered
in classAggregatorFactory
-
factorizeVector
public final VectorAggregator factorizeVector(VectorColumnSelectorFactory columnSelectorFactory)
Description copied from class:AggregatorFactory
Create a VectorAggregator based on the provided column selector factory. Will throw an exception if this aggregation class does not support vectorization: check "canVectorize" first.- Overrides:
factorizeVector
in classAggregatorFactory
-
makeNullableAggregateCombiner
public final AggregateCombiner makeNullableAggregateCombiner()
Description copied from class:AggregatorFactory
Creates anAggregateCombiner
which supports nullability. Implementations ofAggregatorFactory
which need to Support Nullable Aggregations are encouraged to extendNullableNumericAggregatorFactory
instead of overriding this method. Default implementation callsAggregatorFactory.makeAggregateCombiner()
for backwards compatibility.- Overrides:
makeNullableAggregateCombiner
in classAggregatorFactory
- See Also:
AggregateCombiner
,NullableNumericAggregatorFactory
-
getMaxIntermediateSizeWithNulls
public final int getMaxIntermediateSizeWithNulls()
Description copied from class:AggregatorFactory
Returns the maximum size that this aggregator will require in bytes for intermediate storage of results. Implementations ofAggregatorFactory
which need to Support Nullable Aggregations are encouraged to extendNullableNumericAggregatorFactory
instead of overriding this method. Default implementation callsAggregatorFactory.makeAggregateCombiner()
for backwards compatibility.- Overrides:
getMaxIntermediateSizeWithNulls
in classAggregatorFactory
- Returns:
- the maximum number of bytes that an aggregator of this type will require for intermediate result storage.
-
selector
protected abstract T selector(ColumnSelectorFactory columnSelectorFactory)
Creates aColumnValueSelector
for the aggregated column.- See Also:
ColumnValueSelector
-
vectorSelector
protected VectorValueSelector vectorSelector(VectorColumnSelectorFactory columnSelectorFactory)
Creates aVectorValueSelector
for the aggregated column.- See Also:
VectorValueSelector
-
factorize
protected abstract Aggregator factorize(ColumnSelectorFactory columnSelectorFactory, T selector)
Creates anAggregator
to aggregate values from several rows, by using the provided selector.- Parameters:
columnSelectorFactory
- metricFactoryselector
-ColumnValueSelector
for the column to aggregate.- See Also:
Aggregator
-
factorizeBuffered
protected abstract BufferAggregator factorizeBuffered(ColumnSelectorFactory columnSelectorFactory, T selector)
Creates anBufferAggregator
to aggregate values from several rows into a ByteBuffer.- Parameters:
columnSelectorFactory
- columnSelectorFactory in case any other columns are needed.selector
-ColumnValueSelector
for the column to aggregate.- See Also:
BufferAggregator
-
factorizeVector
protected VectorAggregator factorizeVector(VectorColumnSelectorFactory columnSelectorFactory, VectorValueSelector selector)
Creates aVectorAggregator
to aggregate values from several rows into a ByteBuffer.- Parameters:
columnSelectorFactory
- columnSelectorFactory in case any other columns are needed.selector
-VectorValueSelector
for the column to aggregate.- See Also:
BufferAggregator
-
getResultType
public ColumnType getResultType()
Description copied from class:AggregatorFactory
Get theColumnType
for the final form of this aggregator, i.e. the type of the value returned byAggregatorFactory.finalizeComputation(java.lang.Object)
. This may be the same as or different than the types expected inAggregatorFactory.deserialize(java.lang.Object)
andAggregatorFactory.combine(java.lang.Object, java.lang.Object)
. Refer to theColumnType
javadocs for details on the implications of choosing a type.- Overrides:
getResultType
in classAggregatorFactory
-
-