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 variousAggregatorFactoryimplementations 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 Stringexpressionprotected com.google.common.base.Supplier<Expr>fieldExpressionprotected StringfieldNameprotected ExprMacroTablemacroTableprotected Stringname
-
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 AggregatorbuildAggregator(BaseLongColumnValueSelector selector)protected abstract BufferAggregatorbuildBufferAggregator(BaseLongColumnValueSelector selector)booleancanVectorize(ColumnInspector columnInspector)Returns whether or not this aggregation class supports vectorization.Objectdeserialize(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.booleanequals(Object o)protected Aggregatorfactorize(ColumnSelectorFactory metricFactory, ColumnValueSelector selector)Creates anAggregatorto aggregate values from several rows, by using the provided selector.protected BufferAggregatorfactorizeBuffered(ColumnSelectorFactory metricFactory, ColumnValueSelector selector)Creates anBufferAggregatorto aggregate values from several rows into a ByteBuffer.ObjectfinalizeComputation(Object object)"Finalizes" the computation of an object.ComparatorgetComparator()StringgetExpression()StringgetFieldName()ColumnTypegetIntermediateType()Get the "intermediate"ColumnTypefor this aggregator.intgetMaxIntermediateSize()Returns the maximum size that this aggregator will require in bytes for intermediate storage of results.AggregatorFactorygetMergingFactory(AggregatorFactory other)Returns an AggregatorFactory that can be used to combine the output of aggregators from this factory and another factory.StringgetName()inthashCode()protected abstract longnullValue()List<String>requiredFields()Get a list of fields that aggregators built by this factory will need to read.protected ColumnValueSelectorselector(ColumnSelectorFactory metricFactory)Creates aColumnValueSelectorfor the aggregated column.protected booleanuseGetObject(ColumnSelectorFactory columnSelectorFactory)Returns whether the selector created byNullableNumericAggregatorFactory.selector(ColumnSelectorFactory)for the givenColumnSelectorFactoryprefersBaseObjectColumnValueSelector.getObject().protected VectorValueSelectorvectorSelector(VectorColumnSelectorFactory columnSelectorFactory)Creates aVectorValueSelectorfor 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, substituteCombiningFactory, 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:NullableNumericAggregatorFactoryCreates anAggregatorto aggregate values from several rows, by using the provided selector.- Specified by:
factorizein classNullableNumericAggregatorFactory<ColumnValueSelector>- Parameters:
metricFactory- metricFactoryselector-ColumnValueSelectorfor the column to aggregate.- See Also:
Aggregator
-
factorizeBuffered
protected BufferAggregator factorizeBuffered(ColumnSelectorFactory metricFactory, ColumnValueSelector selector)
Description copied from class:NullableNumericAggregatorFactoryCreates anBufferAggregatorto aggregate values from several rows into a ByteBuffer.- Specified by:
factorizeBufferedin classNullableNumericAggregatorFactory<ColumnValueSelector>- Parameters:
metricFactory- columnSelectorFactory in case any other columns are needed.selector-ColumnValueSelectorfor the column to aggregate.- See Also:
BufferAggregator
-
selector
protected ColumnValueSelector selector(ColumnSelectorFactory metricFactory)
Description copied from class:NullableNumericAggregatorFactoryCreates aColumnValueSelectorfor the aggregated column.- Specified by:
selectorin classNullableNumericAggregatorFactory<ColumnValueSelector>- See Also:
ColumnValueSelector
-
vectorSelector
protected VectorValueSelector vectorSelector(VectorColumnSelectorFactory columnSelectorFactory)
Description copied from class:NullableNumericAggregatorFactoryCreates aVectorValueSelectorfor the aggregated column.- Overrides:
vectorSelectorin classNullableNumericAggregatorFactory<ColumnValueSelector>- See Also:
VectorValueSelector
-
useGetObject
protected boolean useGetObject(ColumnSelectorFactory columnSelectorFactory)
Description copied from class:NullableNumericAggregatorFactoryReturns whether the selector created byNullableNumericAggregatorFactory.selector(ColumnSelectorFactory)for the givenColumnSelectorFactoryprefersBaseObjectColumnValueSelector.getObject(). For backwards compatibilty with older extensions, this is a non-abstract method.- Overrides:
useGetObjectin classNullableNumericAggregatorFactory<ColumnValueSelector>
-
deserialize
public Object deserialize(Object object)
Description copied from class:AggregatorFactoryA 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:
deserializein classAggregatorFactory- Parameters:
object- the object to deserialize- Returns:
- the deserialized object
-
getIntermediateType
public ColumnType getIntermediateType()
Description copied from class:AggregatorFactoryGet the "intermediate"ColumnTypefor 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 theColumnTypejavadocs for details on the implications of choosing a type.- Overrides:
getIntermediateTypein classAggregatorFactory
-
getMaxIntermediateSize
public int getMaxIntermediateSize()
Description copied from class:AggregatorFactoryReturns the maximum size that this aggregator will require in bytes for intermediate storage of results.- Specified by:
getMaxIntermediateSizein 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:
getComparatorin 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:
finalizeComputationin 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:AggregatorFactoryGet a list of fields that aggregators built by this factory will need to read.- Specified by:
requiredFieldsin classAggregatorFactory
-
getMergingFactory
public AggregatorFactory getMergingFactory(AggregatorFactory other) throws AggregatorFactoryNotMergeableException
Description copied from class:AggregatorFactoryReturns 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:
getMergingFactoryin 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:
getNamein classAggregatorFactory- Returns:
- output name of the aggregator column.
-
canVectorize
public boolean canVectorize(ColumnInspector columnInspector)
Description copied from class:AggregatorFactoryReturns whether or not this aggregation class supports vectorization. The default implementation returns false.- Overrides:
canVectorizein classAggregatorFactory
-
nullValue
protected abstract long nullValue()
-
buildAggregator
protected abstract Aggregator buildAggregator(BaseLongColumnValueSelector selector)
-
buildBufferAggregator
protected abstract BufferAggregator buildBufferAggregator(BaseLongColumnValueSelector selector)
-
-