Interface Aggregator<K,V,R>

Type Parameters:
K - the type of the key
V - the type of the value
R - 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:

  1. accumulate() is called for each entry in the map
  2. combine() merges results from two-stage map-reduce executions
  3. 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 Type
    Method
    Description
    void
    Accumulate a single entry into this aggregator.
    Get the final aggregated result.
    Combine this aggregator with another from a parallel execution.
  • Method Details

    • accumulate

      void accumulate(Map.Entry<K,V> entry)
      Accumulate a single entry into this aggregator.

      This method is called once for each entry in the map during the scan.

      Parameters:
      entry - the entry to accumulate (may be null if entry was deleted)
    • combine

      Aggregator<K,V,R> combine(Aggregator<K,V,R> other)
      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