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
#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
object, but its update operations are tracked. 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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description AggregateResult
aggregateStream(java.util.stream.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)
Accumulator
createNeutral()
AggregateResult
getAggregate(Accumulator result)
java.lang.String
getName()
A name or identifier of the operator.java.lang.String
getShortDescription()
A textual description of the operator.boolean
isNeutral(Accumulator result)
default java.lang.String
prettyPrint(Accumulator accumulator)
Pretty prints the contents of the given accumulator.Accumulator
update(Accumulator oldResult, Domain updateValue, boolean isInsertion)
-
-
-
Method Detail
-
getShortDescription
java.lang.String getShortDescription()
A textual description of the operator.
-
getName
java.lang.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
boolean isNeutral(Accumulator result)
- 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
Accumulator update(Accumulator oldResult, Domain updateValue, boolean isInsertion)
- 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
AggregateResult getAggregate(Accumulator result)
- 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
AggregateResult aggregateStream(java.util.stream.Stream<Domain> stream)
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
default Accumulator clone(Accumulator original)
Clones the given accumulator (with all its internal contents).
-
combine
default AggregateResult combine(AggregateResult left, Accumulator right)
Combines the given aggregate result and accumulator into a single aggregate result.
-
contains
default boolean contains(Domain value, Accumulator accumulator)
-
prettyPrint
default java.lang.String prettyPrint(Accumulator accumulator)
Pretty prints the contents of the given accumulator.
-
-