Interface Aggregator<K,V,R>
- Type Parameters:
K- the type of the keyV- the type of the valueR- the type of the aggregated result
- All Known Implementing Classes:
AverageAggregator, BigDecimalAverageAggregator, BigDecimalSumAggregator, BigIntegerSumAggregator, ComparableMaxAggregator, ComparableMinAggregator, CountAggregator, DistinctValuesAggregator, MaxAggregator, MinAggregator, SumAggregator
public interface Aggregator<K,V,R>
Generic aggregation interface for map-reduce style operations.
Aggregators allow scanning all entries in a map and combining results using a standard pattern:
- accumulate() is called for each entry in the map
- combine() merges results from two-stage map-reduce executions
- aggregate() returns the final aggregated result
Implementations should be stateful (accumulating state as entries are processed)
and support combine for merging partial results from parallel scans. Use the
factory-based aggregate overloads on EntryProcessorExecutor or
DistributedMap when an aggregation
must fan out into independent partial aggregators.
Example usage:
Aggregatorinvalid input: '<'String, Integer, Long> sumAgg = new SumAggregatorinvalid input: '<'>(); Long total = executor.aggregate(sumAgg);
-
Method Summary
Modifier and TypeMethodDescriptionvoidaccumulate(Map.Entry<K, V> entry) Accumulate a single entry into this aggregator.Get the final aggregated result.Aggregator<K, V, R> combine(Aggregator<K, V, R> other) Combine this aggregator with another from a parallel execution.
-
Method Details
-
accumulate
-
combine
Combine this aggregator with another from a parallel execution.This method is used to merge results from multiple parallel aggregations into a single result. Implementations should combine the internal state of both aggregators.
- Parameters:
other- the other aggregator to combine with (must not be null)- Returns:
- a new aggregator combining both results (may be this or other)
- Throws:
IllegalArgumentException- if other is not compatible with this aggregator
-
aggregate
R aggregate()Get the final aggregated result.This is called after all entries have been accumulated and all partial results have been combined.
- Returns:
- the aggregated result
-