Class SimpleDoubleAggregatorFactory
java.lang.Object
org.apache.druid.query.aggregation.AggregatorFactory
org.apache.druid.query.aggregation.NullableNumericAggregatorFactory<ColumnValueSelector>
org.apache.druid.query.aggregation.SimpleDoubleAggregatorFactory
- All Implemented Interfaces:
Cacheable
- Direct Known Subclasses:
DoubleMaxAggregatorFactory,DoubleMinAggregatorFactory,DoubleSumAggregatorFactory
public abstract class SimpleDoubleAggregatorFactory
extends NullableNumericAggregatorFactory<ColumnValueSelector>
This is an abstract class inherited by various " instead of "NullableAggregatorFactory"
to additionally support aggregation on single/multi value string column types.
AggregatorFactory implementations that consume double input
and produce double output on aggregation.
It extends "NullableAggregatorFactory-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Stringprotected final com.google.common.base.Supplier<Expr>protected final Stringprotected final ExprMacroTableprotected final Stringprotected final boolean -
Constructor Summary
ConstructorsConstructorDescriptionSimpleDoubleAggregatorFactory(ExprMacroTable macroTable, String name, String fieldName, String expression) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract AggregatorbuildAggregator(BaseDoubleColumnValueSelector selector) protected abstract BufferAggregatorbooleancanVectorize(ColumnInspector columnInspector) Returns whether or not this aggregation class supports vectorization.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.booleanprotected 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.finalizeComputation(Object object) "Finalizes" the computation of an object.Get the "intermediate"ColumnTypefor this aggregator.intReturns the maximum size that this aggregator will require in bytes for intermediate storage of results.Returns an AggregatorFactory that can be used to combine the output of aggregators from this factory and another factory.getName()inthashCode()protected abstract doubleGet 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, forceNotNullable, getMaxIntermediateSizeWithNulls, getResultType, makeNullableAggregateCombinerMethods inherited from class org.apache.druid.query.aggregation.AggregatorFactory
combine, factorizeWithSize, getCombiningFactory, getComplexTypeName, getFinalizedType, getRequiredColumns, getType, guessAggregatorHeapFootprint, makeAggregateCombiner, mergeAggregators, optimizeForSegment, substituteCombiningFactory, withNameMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.druid.java.util.common.Cacheable
getCacheKey
-
Field Details
-
name
-
fieldName
-
expression
-
macroTable
-
storeDoubleAsFloat
protected final boolean storeDoubleAsFloat -
fieldExpression
-
-
Constructor Details
-
SimpleDoubleAggregatorFactory
public SimpleDoubleAggregatorFactory(ExprMacroTable macroTable, String name, @Nullable String fieldName, @Nullable String expression)
-
-
Method Details
-
factorize
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:
-
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:
-
selector
Description copied from class:NullableNumericAggregatorFactoryCreates aColumnValueSelectorfor the aggregated column.- Specified by:
selectorin classNullableNumericAggregatorFactory<ColumnValueSelector>- See Also:
-
vectorSelector
Description copied from class:NullableNumericAggregatorFactoryCreates aVectorValueSelectorfor the aggregated column.- Overrides:
vectorSelectorin classNullableNumericAggregatorFactory<ColumnValueSelector>- See Also:
-
useGetObject
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
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
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
- Specified by:
getComparatorin classAggregatorFactory
-
finalizeComputation
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
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:
-
hashCode
public int hashCode() -
equals
-
getName
- Specified by:
getNamein classAggregatorFactory- Returns:
- output name of the aggregator column.
-
getFieldName
-
getExpression
-
canVectorize
Description copied from class:AggregatorFactoryReturns whether or not this aggregation class supports vectorization. The default implementation returns false.- Overrides:
canVectorizein classAggregatorFactory
-
nullValue
protected abstract double nullValue() -
buildAggregator
-
buildBufferAggregator
-