public class JavaScriptAggregatorFactory extends AggregatorFactory
| Constructor and Description |
|---|
JavaScriptAggregatorFactory(String name,
List<String> fieldNames,
String fnAggregate,
String fnReset,
String fnCombine,
JavaScriptConfig config) |
| Modifier and Type | Method and Description |
|---|---|
Object |
combine(Object lhs,
Object rhs)
A method that knows how to combine the outputs of
Aggregator.get() produced via AggregatorFactory.factorize(org.apache.druid.segment.ColumnSelectorFactory) or BufferAggregator.get(java.nio.ByteBuffer, int) produced via AggregatorFactory.factorizeBuffered(org.apache.druid.segment.ColumnSelectorFactory). |
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) |
Aggregator |
factorize(ColumnSelectorFactory columnFactory) |
BufferAggregator |
factorizeBuffered(ColumnSelectorFactory columnSelectorFactory) |
@Nullable Object |
finalizeComputation(@Nullable Object object)
"Finalizes" the computation of an object.
|
byte[] |
getCacheKey() |
AggregatorFactory |
getCombiningFactory()
Returns an AggregatorFactory that can be used to combine the output of aggregators from this factory.
|
Comparator |
getComparator() |
List<String> |
getFieldNames() |
String |
getFnAggregate() |
String |
getFnCombine() |
String |
getFnReset() |
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() |
List<AggregatorFactory> |
getRequiredColumns()
Used by
GroupByStrategyV1 when running nested groupBys, to
"transfer" values from this aggreagtor to an incremental index that the outer query will run on. |
ColumnType |
getResultType()
Get the
ColumnType for the final form of this aggregator, i.e. |
int |
hashCode() |
AggregateCombiner |
makeAggregateCombiner()
Creates an AggregateCombiner to fold rollup aggregation results from serveral "rows" of different indexes during
index merging.
|
List<String> |
requiredFields()
Get a list of fields that aggregators built by this factory will need to read.
|
String |
toString() |
AggregatorFactory |
withName(String newName)
Used in cases where we want to change the output name of the aggregator to something else.
|
canVectorize, factorizeVector, factorizeWithSize, getComplexTypeName, getFinalizedType, getMaxIntermediateSizeWithNulls, getType, guessAggregatorHeapFootprint, makeNullableAggregateCombiner, mergeAggregators, optimizeForSegmentpublic Aggregator factorize(ColumnSelectorFactory columnFactory)
factorize in class AggregatorFactorypublic BufferAggregator factorizeBuffered(ColumnSelectorFactory columnSelectorFactory)
factorizeBuffered in class AggregatorFactorypublic Comparator getComparator()
getComparator in class AggregatorFactorypublic Object combine(Object lhs, Object rhs)
AggregatorFactoryAggregator.get() produced via AggregatorFactory.factorize(org.apache.druid.segment.ColumnSelectorFactory) or BufferAggregator.get(java.nio.ByteBuffer, int) produced via AggregatorFactory.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.combine in class AggregatorFactorylhs - The left hand side of the combinerhs - The right hand side of the combinepublic AggregateCombiner makeAggregateCombiner()
AggregatorFactoryAggregatorFactory.combine(java.lang.Object, java.lang.Object), with the difference that it uses
ColumnValueSelector and it's subinterfaces to get inputs and implements ColumnValueSelector to provide output.makeAggregateCombiner in class AggregatorFactoryAggregateCombiner,
IndexMergerpublic AggregatorFactory getCombiningFactory()
AggregatorFactoryCountAggregatorFactory getCombiningFactory method will return a
LongSumAggregatorFactory, because counts are combined by summing.
No matter what, `foo.getCombiningFactory()` and `foo.getCombiningFactory().getCombiningFactory()` should return
the same result.getCombiningFactory in class AggregatorFactorypublic AggregatorFactory getMergingFactory(AggregatorFactory other) throws AggregatorFactoryNotMergeableException
AggregatorFactoryAggregatorFactoryNotMergeableException, meaning that "this" and "other" are not
compatible and values from one cannot sensibly be combined with values from the other.getMergingFactory in class AggregatorFactoryAggregatorFactoryNotMergeableExceptionwhich is equivalent to {@code foo.getMergingFactory(foo)} (when "this" and "other"
are the same instance).public List<AggregatorFactory> getRequiredColumns()
AggregatorFactoryGroupByStrategyV1 when running nested groupBys, to
"transfer" values from this aggreagtor to an incremental index that the outer query will run on. This method
only exists due to the design of GroupByStrategyV1, and should probably not be used for anything else. If you are
here because you are looking for a way to get the input fields required by this aggregator, and thought
"getRequiredColumns" sounded right, please use AggregatorFactory.requiredFields() instead.getRequiredColumns in class AggregatorFactorya similarly-named method that is perhaps the one you want instead.public Object deserialize(Object object)
AggregatorFactorydeserialize in class AggregatorFactoryobject - the object to deserializepublic @Nullable Object finalizeComputation(@Nullable Object object)
AggregatorFactoryfinalizeComputation in class AggregatorFactoryobject - the object to be finalizedpublic String getName()
getName in class AggregatorFactorypublic String getFnAggregate()
public String getFnReset()
public String getFnCombine()
public List<String> requiredFields()
AggregatorFactoryrequiredFields in class AggregatorFactorypublic byte[] getCacheKey()
public ColumnType getIntermediateType()
AggregatorFactoryColumnType for this aggregator. This is the same as the type returned by
AggregatorFactory.deserialize(java.lang.Object) and the type accepted by AggregatorFactory.combine(java.lang.Object, java.lang.Object). However, it is *not* necessarily the same type
returned by AggregatorFactory.finalizeComputation(java.lang.Object).
Refer to the ColumnType javadocs for details on the implications of choosing a type.getIntermediateType in class AggregatorFactorypublic ColumnType getResultType()
AggregatorFactoryColumnType for the final form of this aggregator, i.e. the type of the value returned by
AggregatorFactory.finalizeComputation(java.lang.Object). This may be the same as or different than the types expected in AggregatorFactory.deserialize(java.lang.Object)
and AggregatorFactory.combine(java.lang.Object, java.lang.Object).
Refer to the ColumnType javadocs for details on the implications of choosing a type.getResultType in class AggregatorFactorypublic int getMaxIntermediateSize()
AggregatorFactorygetMaxIntermediateSize in class AggregatorFactorypublic AggregatorFactory withName(String newName)
AggregatorFactoryorg.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.
withName in class AggregatorFactorynewName - newName of the output for aggregator factoryCopyright © 2011–2022 The Apache Software Foundation. All rights reserved.