Class SingleValueAggregatorFactory
java.lang.Object
org.apache.druid.query.aggregation.AggregatorFactory
org.apache.druid.query.aggregation.SingleValueAggregatorFactory
- All Implemented Interfaces:
Cacheable
This AggregatorFactory is meant to wrap the subquery used as an expression into a single value
and is expected to throw an exception when the subquery results in more than one row
This consumes columnType as well along with name and fieldName to pass it on to underlying
SingleValueBufferAggregator to work with different ColumnTypes
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSingleValueAggregatorFactory(String name, String fieldName, ColumnType columnType) -
Method Summary
Modifier and TypeMethodDescriptionCombine method would never be invoked as the broker sends the subquery to multiple segments and gather the results to a single value on which the single value aggregator is applied.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.booleanfactorize(ColumnSelectorFactory metricFactory) factorizeBuffered(ColumnSelectorFactory metricFactory) finalizeComputation(Object object) "Finalizes" the computation of an object.byte[]Get a byte array used as a cache key.Returns an AggregatorFactory that can be used to combine the output of aggregators from this factory.Get the "intermediate"ColumnTypefor this aggregator.intReturns the maximum size that this aggregator will require in bytes for intermediate storage of results.getName()Get theColumnTypefor the final form of this aggregator, i.e.inthashCode()Get a list of fields that aggregators built by this factory will need to read.toString()Methods inherited from class org.apache.druid.query.aggregation.AggregatorFactory
canVectorize, factorizeVector, factorizeWithSize, getComplexTypeName, getFinalizedType, getMaxIntermediateSizeWithNulls, getMergingFactory, getRequiredColumns, getType, guessAggregatorHeapFootprint, makeAggregateCombiner, makeNullableAggregateCombiner, mergeAggregators, optimizeForSegment, substituteCombiningFactory, withName
-
Field Details
-
DEFAULT_MAX_VALUE_SIZE
public static final int DEFAULT_MAX_VALUE_SIZE- See Also:
-
-
Constructor Details
-
SingleValueAggregatorFactory
-
-
Method Details
-
factorize
- Specified by:
factorizein classAggregatorFactory
-
factorizeBuffered
- Specified by:
factorizeBufferedin classAggregatorFactory
-
getComparator
- Specified by:
getComparatorin classAggregatorFactory
-
combine
Combine method would never be invoked as the broker sends the subquery to multiple segments and gather the results to a single value on which the single value aggregator is applied. Though getCombiningFactory would be invoked for understanding the fieldname.- Specified by:
combinein 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
-
getCombiningFactory
Description copied from class:AggregatorFactoryReturns 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, theCountAggregatorFactorygetCombiningFactory 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:
getCombiningFactoryin classAggregatorFactory- Returns:
- a new Factory that can be used for operations on top of data output from the current factory.
-
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
-
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
-
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
-
getResultType
Description copied from class:AggregatorFactoryGet theColumnTypefor 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 theColumnTypejavadocs for details on the implications of choosing a type.- Overrides:
getResultTypein classAggregatorFactory
-
getName
- Specified by:
getNamein classAggregatorFactory- Returns:
- output name of the aggregator column.
-
getFieldName
-
requiredFields
Description copied from class:AggregatorFactoryGet a list of fields that aggregators built by this factory will need to read.- Specified by:
requiredFieldsin 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.
-
getCacheKey
public byte[] getCacheKey()Description copied from interface:CacheableGet a byte array used as a cache key.- Returns:
- bytes to be used as cache key - or null if this object should not be cached.
-
equals
-
hashCode
public int hashCode() -
toString
-