Class DoubleSumAggregatorFactory
- java.lang.Object
-
- org.apache.druid.query.aggregation.AggregatorFactory
-
- org.apache.druid.query.aggregation.NullableNumericAggregatorFactory<ColumnValueSelector>
-
- org.apache.druid.query.aggregation.SimpleDoubleAggregatorFactory
-
- org.apache.druid.query.aggregation.DoubleSumAggregatorFactory
-
- All Implemented Interfaces:
Cacheable
public class DoubleSumAggregatorFactory extends SimpleDoubleAggregatorFactory
-
-
Field Summary
-
Fields inherited from class org.apache.druid.query.aggregation.SimpleDoubleAggregatorFactory
expression, fieldExpression, fieldName, macroTable, name, storeDoubleAsFloat
-
-
Constructor Summary
Constructors Constructor Description DoubleSumAggregatorFactory(String name, String fieldName)
DoubleSumAggregatorFactory(String name, String fieldName, String expression, ExprMacroTable macroTable)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Aggregator
buildAggregator(BaseDoubleColumnValueSelector selector)
protected BufferAggregator
buildBufferAggregator(BaseDoubleColumnValueSelector selector)
Object
combine(Object lhs, Object rhs)
A method that knows how to combine the outputs ofAggregator.get()
produced viaAggregatorFactory.factorize(org.apache.druid.segment.ColumnSelectorFactory)
orBufferAggregator.get(java.nio.ByteBuffer, int)
produced viaAggregatorFactory.factorizeBuffered(org.apache.druid.segment.ColumnSelectorFactory)
.protected VectorAggregator
factorizeVector(VectorColumnSelectorFactory columnSelectorFactory, VectorValueSelector selector)
Creates aVectorAggregator
to aggregate values from several rows into a ByteBuffer.byte[]
getCacheKey()
Get a byte array used as a cache key.AggregatorFactory
getCombiningFactory()
Returns an AggregatorFactory that can be used to combine the output of aggregators from this factory.AggregateCombiner
makeAggregateCombiner()
Creates an AggregateCombiner to fold rollup aggregation results from serveral "rows" of different indexes during index merging.protected double
nullValue()
String
toString()
AggregatorFactory
withName(String newName)
Used in cases where we want to change the output name of the aggregator to something else.-
Methods inherited from class org.apache.druid.query.aggregation.SimpleDoubleAggregatorFactory
canVectorize, deserialize, equals, factorize, factorizeBuffered, finalizeComputation, getComparator, getExpression, getFieldName, getIntermediateType, getMaxIntermediateSize, getMergingFactory, getName, hashCode, requiredFields, selector, useGetObject, vectorSelector
-
Methods inherited from class org.apache.druid.query.aggregation.NullableNumericAggregatorFactory
factorize, factorizeBuffered, factorizeVector, getMaxIntermediateSizeWithNulls, getResultType, makeNullableAggregateCombiner
-
Methods inherited from class org.apache.druid.query.aggregation.AggregatorFactory
factorizeWithSize, getComplexTypeName, getFinalizedType, getRequiredColumns, getType, guessAggregatorHeapFootprint, mergeAggregators, optimizeForSegment, substituteCombiningFactory
-
-
-
-
Method Detail
-
nullValue
protected double nullValue()
- Specified by:
nullValue
in classSimpleDoubleAggregatorFactory
-
buildAggregator
protected Aggregator buildAggregator(BaseDoubleColumnValueSelector selector)
- Specified by:
buildAggregator
in classSimpleDoubleAggregatorFactory
-
buildBufferAggregator
protected BufferAggregator buildBufferAggregator(BaseDoubleColumnValueSelector selector)
- Specified by:
buildBufferAggregator
in classSimpleDoubleAggregatorFactory
-
factorizeVector
protected VectorAggregator factorizeVector(VectorColumnSelectorFactory columnSelectorFactory, VectorValueSelector selector)
Description copied from class:NullableNumericAggregatorFactory
Creates aVectorAggregator
to aggregate values from several rows into a ByteBuffer.- Overrides:
factorizeVector
in classNullableNumericAggregatorFactory<ColumnValueSelector>
- Parameters:
columnSelectorFactory
- columnSelectorFactory in case any other columns are needed.selector
-VectorValueSelector
for the column to aggregate.- See Also:
BufferAggregator
-
combine
@Nullable public Object combine(@Nullable Object lhs, @Nullable Object rhs)
Description copied from class:AggregatorFactory
A method that knows how to combine the outputs ofAggregator.get()
produced viaAggregatorFactory.factorize(org.apache.druid.segment.ColumnSelectorFactory)
orBufferAggregator.get(java.nio.ByteBuffer, int)
produced viaAggregatorFactory.factorizeBuffered(org.apache.druid.segment.ColumnSelectorFactory)
. Note, even though this method is called "combine", this method's contract *does* allow for mutation of the input objects. Thus, any use of lhs or rhs after calling this method is highly discouraged.- Specified by:
combine
in classAggregatorFactory
- Parameters:
lhs
- The left hand side of the combinerhs
- The right hand side of the combine- Returns:
- an object representing the combination of lhs and rhs, this can be a new object or a mutation of the inputs
-
makeAggregateCombiner
public AggregateCombiner makeAggregateCombiner()
Description copied from class:AggregatorFactory
Creates an AggregateCombiner to fold rollup aggregation results from serveral "rows" of different indexes during index merging. AggregateCombiner implements the same logic asAggregatorFactory.combine(java.lang.Object, java.lang.Object)
, with the difference that it usesColumnValueSelector
and it's subinterfaces to get inputs and implementsColumnValueSelector
to provide output.- Overrides:
makeAggregateCombiner
in classAggregatorFactory
- See Also:
AggregateCombiner
,IndexMerger
-
getCombiningFactory
public AggregatorFactory getCombiningFactory()
Description copied from class:AggregatorFactory
Returns an AggregatorFactory that can be used to combine the output of aggregators from this factory. It is used when we know we have some values that were produced with this aggregator factory, and want to do some additional combining of them. This happens, for example, when merging query results from two different segments, or two different servers. For simple aggregators, the combining factory may be computed by simply creating a new factory that is the same as the current, except with its input column renamed to the same as the output column. For example, this aggregator: {"type": "longSum", "fieldName": "foo", "name": "bar"} Would become: {"type": "longSum", "fieldName": "bar", "name": "bar"} Sometimes, the type or other parameters of the combining aggregator will be different from the original aggregator. For example, theCountAggregatorFactory
getCombiningFactory method will return aLongSumAggregatorFactory
, because counts are combined by summing. No matter what, `foo.getCombiningFactory()` and `foo.getCombiningFactory().getCombiningFactory()` should return the same result.- Specified by:
getCombiningFactory
in classAggregatorFactory
- Returns:
- a new Factory that can be used for operations on top of data output from the current factory.
-
withName
public AggregatorFactory withName(String newName)
Description copied from class:AggregatorFactory
Used in cases where we want to change the output name of the aggregator to something else. For eg: if we have a query `select a, sum(b) as total group by a from table` the aggregator returned from the native group by query is "a0" set inorg.apache.druid.sql.calcite.rel.DruidQuery#computeAggregations
. We can use withName("total") to set the output name of the aggregator to "total".As all implementations of this interface method may not exist, callers of this method are advised to handle such a case.
- Overrides:
withName
in classAggregatorFactory
- Parameters:
newName
- newName of the output for aggregator factory- Returns:
- AggregatorFactory with the output name set as the input param.
-
getCacheKey
public byte[] getCacheKey()
Description copied from interface:Cacheable
Get a byte array used as a cache key.- Returns:
- a cache key
-
-