Class AverageAggregator<K, V extends Number>
java.lang.Object
com.loomcache.server.compute.AverageAggregator<K,V>
- Type Parameters:
K- the type of the keyV- the type of the value (should be numeric)
- All Implemented Interfaces:
Aggregator<K,V, Double>
public class AverageAggregator<K, V extends Number>
extends Object
implements Aggregator<K,V,Double>
Built-in aggregator that computes the average of numeric values in the map.
Values must implement Number interface and be convertible to double. Non-numeric values are skipped.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaccumulate(Map.Entry<K, V> entry) Accumulate a single entry into this aggregator.Get the final aggregated result.combine(Aggregator<K, V, Double> other) Combine this aggregator with another from a parallel execution.
-
Constructor Details
-
AverageAggregator
public AverageAggregator()Create a new average aggregator.
-
-
Method Details
-
accumulate
Description copied from interface:AggregatorAccumulate a single entry into this aggregator.This method is called once for each entry in the map during the scan.
- Specified by:
accumulatein interfaceAggregator<K, V extends Number, Double>- Parameters:
entry- the entry to accumulate (may be null if entry was deleted)
-
combine
Description copied from interface:AggregatorCombine 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.
-
aggregate
Description copied from interface:AggregatorGet the final aggregated result.This is called after all entries have been accumulated and all partial results have been combined.
-