Class SimpleLongAggregatorFactory
- java.lang.Object
-
- org.apache.druid.query.aggregation.AggregatorFactory
-
- org.apache.druid.query.aggregation.NullableNumericAggregatorFactory<ColumnValueSelector>
-
- org.apache.druid.query.aggregation.SimpleLongAggregatorFactory
-
- All Implemented Interfaces:
Cacheable
- Direct Known Subclasses:
LongMaxAggregatorFactory
,LongMinAggregatorFactory
,LongSumAggregatorFactory
public abstract class SimpleLongAggregatorFactory extends NullableNumericAggregatorFactory<ColumnValueSelector>
This is an abstract class inherited by variousAggregatorFactory
implementations that consume long input and produce long output on aggregation. It extends "NullableAggregatorFactory" instead of "NullableAggregatorFactory " to additionally support aggregation on single/multi value string column types.
-
-
Field Summary
Fields Modifier and Type Field Description protected String
expression
protected com.google.common.base.Supplier<Expr>
fieldExpression
protected String
fieldName
protected ExprMacroTable
macroTable
protected String
name
-
Constructor Summary
Constructors Constructor Description SimpleLongAggregatorFactory(ExprMacroTable macroTable, String name, String fieldName, String expression)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract Aggregator
buildAggregator(BaseLongColumnValueSelector selector)
protected abstract BufferAggregator
buildBufferAggregator(BaseLongColumnValueSelector selector)
boolean
canVectorize(ColumnInspector columnInspector)
Returns whether or not this aggregation class supports vectorization.Object
deserialize(Object object)
A method that knows how to "deserialize" the object from whatever form it might have been put into in order to transfer via JSON.boolean
equals(Object o)
protected Aggregator
factorize(ColumnSelectorFactory metricFactory, ColumnValueSelector selector)
Creates anAggregator
to aggregate values from several rows, by using the provided selector.protected BufferAggregator
factorizeBuffered(ColumnSelectorFactory metricFactory, ColumnValueSelector selector)
Creates anBufferAggregator
to aggregate values from several rows into a ByteBuffer.Object
finalizeComputation(Object object)
"Finalizes" the computation of an object.Comparator
getComparator()
String
getExpression()
String
getFieldName()
ColumnType
getIntermediateType()
Get the "intermediate"ColumnType
for this aggregator.int
getMaxIntermediateSize()
Returns the maximum size that this aggregator will require in bytes for intermediate storage of results.AggregatorFactory
getMergingFactory(AggregatorFactory other)
Returns an AggregatorFactory that can be used to combine the output of aggregators from this factory and another factory.String
getName()
int
hashCode()
protected abstract long
nullValue()
List<String>
requiredFields()
Get a list of fields that aggregators built by this factory will need to read.protected ColumnValueSelector
selector(ColumnSelectorFactory metricFactory)
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.NullableNumericAggregatorFactory
factorize, factorizeBuffered, factorizeVector, factorizeVector, getMaxIntermediateSizeWithNulls, getResultType, makeNullableAggregateCombiner
-
Methods inherited from class org.apache.druid.query.aggregation.AggregatorFactory
combine, factorizeWithSize, getCombiningFactory, getComplexTypeName, getFinalizedType, getRequiredColumns, getType, guessAggregatorHeapFootprint, makeAggregateCombiner, mergeAggregators, optimizeForSegment, withName
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.druid.java.util.common.Cacheable
getCacheKey
-
-
-
-
Method Detail
-
factorize
protected Aggregator factorize(ColumnSelectorFactory metricFactory, ColumnValueSelector selector)
Description copied from class:NullableNumericAggregatorFactory
Creates anAggregator
to aggregate values from several rows, by using the provided selector.- Specified by:
factorize
in classNullableNumericAggregatorFactory<ColumnValueSelector>
- Parameters:
metricFactory
- metricFactoryselector
-ColumnValueSelector
for the column to aggregate.- See Also:
Aggregator
-
factorizeBuffered
protected BufferAggregator factorizeBuffered(ColumnSelectorFactory metricFactory, ColumnValueSelector selector)
Description copied from class:NullableNumericAggregatorFactory
Creates anBufferAggregator
to aggregate values from several rows into a ByteBuffer.- Specified by:
factorizeBuffered
in classNullableNumericAggregatorFactory<ColumnValueSelector>
- Parameters:
metricFactory
- columnSelectorFactory in case any other columns are needed.selector
-ColumnValueSelector
for the column to aggregate.- See Also:
BufferAggregator
-
selector
protected ColumnValueSelector selector(ColumnSelectorFactory metricFactory)
Description copied from class:NullableNumericAggregatorFactory
Creates aColumnValueSelector
for the aggregated column.- Specified by:
selector
in classNullableNumericAggregatorFactory<ColumnValueSelector>
- See Also:
ColumnValueSelector
-
vectorSelector
protected VectorValueSelector vectorSelector(VectorColumnSelectorFactory columnSelectorFactory)
Description copied from class:NullableNumericAggregatorFactory
Creates aVectorValueSelector
for the aggregated column.- Overrides:
vectorSelector
in classNullableNumericAggregatorFactory<ColumnValueSelector>
- See Also:
VectorValueSelector
-
deserialize
public Object deserialize(Object object)
Description copied from class:AggregatorFactory
A method that knows how to "deserialize" the object from whatever form it might have been put into in order to transfer via JSON.- Specified by:
deserialize
in classAggregatorFactory
- Parameters:
object
- the object to deserialize- Returns:
- the deserialized object
-
getIntermediateType
public ColumnType getIntermediateType()
Description copied from class:AggregatorFactory
Get the "intermediate"ColumnType
for this aggregator. This is the same as the type returned byAggregatorFactory.deserialize(java.lang.Object)
and the type accepted byAggregatorFactory.combine(java.lang.Object, java.lang.Object)
. However, it is *not* necessarily the same type returned byAggregatorFactory.finalizeComputation(java.lang.Object)
. Refer to theColumnType
javadocs for details on the implications of choosing a type.- Overrides:
getIntermediateType
in classAggregatorFactory
-
getMaxIntermediateSize
public int getMaxIntermediateSize()
Description copied from class:AggregatorFactory
Returns the maximum size that this aggregator will require in bytes for intermediate storage of results.- Specified by:
getMaxIntermediateSize
in classAggregatorFactory
- Returns:
- the maximum number of bytes that an aggregator of this type will require for intermediate result storage.
-
getComparator
public Comparator getComparator()
- Specified by:
getComparator
in classAggregatorFactory
-
finalizeComputation
@Nullable public Object finalizeComputation(@Nullable Object object)
Description copied from class:AggregatorFactory
"Finalizes" the computation of an object. Primarily useful for complex types that have a different mergeable intermediate format than their final resultant output.- Specified by:
finalizeComputation
in classAggregatorFactory
- Parameters:
object
- the object to be finalized- Returns:
- the finalized value that should be returned for the initial query
-
requiredFields
public List<String> requiredFields()
Description copied from class:AggregatorFactory
Get a list of fields that aggregators built by this factory will need to read.- Specified by:
requiredFields
in classAggregatorFactory
-
getMergingFactory
public AggregatorFactory getMergingFactory(AggregatorFactory other) throws AggregatorFactoryNotMergeableException
Description copied from class:AggregatorFactory
Returns an AggregatorFactory that can be used to combine the output of aggregators from this factory and another factory. It is used when we have some values produced by this aggregator factory, and some values produced by the "other" aggregator factory, and we want to do some additional combining of them. This happens, for example, when compacting two segments together that both have a metric column with the same name. (Even though the name of the column is the same, the aggregator factory used to create it may be different from segment to segment.) This method may throwAggregatorFactoryNotMergeableException
, meaning that "this" and "other" are not compatible and values from one cannot sensibly be combined with values from the other.- Overrides:
getMergingFactory
in classAggregatorFactory
- Returns:
- a new Factory that can be used for merging the output of aggregators from this factory and other.
- Throws:
AggregatorFactoryNotMergeableException
- See Also:
which is equivalent to (when "this" and "other" are the same instance).
-
getName
public String getName()
- Specified by:
getName
in classAggregatorFactory
- Returns:
- output name of the aggregator column.
-
canVectorize
public boolean canVectorize(ColumnInspector columnInspector)
Description copied from class:AggregatorFactory
Returns whether or not this aggregation class supports vectorization. The default implementation returns false.- Overrides:
canVectorize
in classAggregatorFactory
-
nullValue
protected abstract long nullValue()
-
buildAggregator
protected abstract Aggregator buildAggregator(BaseLongColumnValueSelector selector)
-
buildBufferAggregator
protected abstract BufferAggregator buildBufferAggregator(BaseLongColumnValueSelector selector)
-
-