Interface IMultisetAggregationOperator<Domain,Accumulator,AggregateResult>
- Type Parameters:
Domain
- the type of elements to be aggregated.Accumulator
- the type used to store the interim results of the aggregate computation, that may be incrementally refreshed upon updates to the multiset, and that can easily yield the final result.AggregateResult
- the type of the final result of the aggregation to be output.
- All Known Implementing Classes:
AbstractMemorylessAggregationOperator
,DoubleAverageOperator
,DoubleSumOperator
,ExtremumOperator
,IntegerAverageOperator
,IntegerSumOperator
,LongAverageOperator
,LongSumOperator
public interface IMultisetAggregationOperator<Domain,Accumulator,AggregateResult>
A single column aggregator is used to incrementally compute the aggregate of a multiset of values according to an aggregator operator.
The operator provides two methods of computation:
- Stateless aggregation of an explicit multiset, provided by
invalid reference
#aggregateStatelessly(Collection)
- Incremental aggregation, provided by
createNeutral()
,update(Object, Object, boolean)
,isNeutral(Object)
,getAggregate(Object)
.
In case of incremental computation, the aggregable multiset is conceptual; it is not represented by an explicit Collection In case of incremental computation, internal results, potentially distinct from the final aggregate result, may be stored in a helper data structure called accumulator.
The goal of this distinction is that the final result may not be sufficient for incremental updates (see e.g. ExtremumOperator
).
- Since:
- 1.4
-
Method Summary
Modifier and TypeMethodDescriptionaggregateStream
(Stream<Domain> stream) Calculates the aggregate results from a given stream of values; all values are considered as inserteddefault Accumulator
clone
(Accumulator original) Clones the given accumulator (with all its internal contents).default AggregateResult
combine
(AggregateResult left, Accumulator right) Combines the given aggregate result and accumulator into a single aggregate result.default boolean
contains
(Domain value, Accumulator accumulator) getAggregate
(Accumulator result) getName()
A name or identifier of the operator.A textual description of the operator.boolean
isNeutral
(Accumulator result) default String
prettyPrint
(Accumulator accumulator) Pretty prints the contents of the given accumulator.update
(Accumulator oldResult, Domain updateValue, boolean isInsertion)
-
Method Details
-
getShortDescription
String getShortDescription()A textual description of the operator. -
getName
String getName()A name or identifier of the operator. -
createNeutral
Accumulator createNeutral()- Returns:
- the neutral element, i.e. the interim result of aggregating an empty multiset.
-
isNeutral
- Returns:
- true if the interim result is equivalent to the neutral element, as if there are no values in the multiset. Must return true if the multiset is empty.
-
update
- Returns:
- an updated intermediate result, changed to reflect that a given object was added to / removed from the multiset (as indicated by the parameter isInsertion)
-
getAggregate
- Returns:
- the aggregate result obtained from the given intermediate result. May be null to indicate that the current multiset cannot be aggregated (e.g. 0 elements have no minimum).
-
aggregateStream
Calculates the aggregate results from a given stream of values; all values are considered as inserted- Returns:
- the aggregate result, or null if no result can be calculated (e.g. because of an empty stream)
- Since:
- 2.0
-
clone
Clones the given accumulator (with all its internal contents). -
combine
Combines the given aggregate result and accumulator into a single aggregate result. -
contains
-
prettyPrint
Pretty prints the contents of the given accumulator.
-