Class CountAggregator<K,V>

java.lang.Object
com.loomcache.server.compute.CountAggregator<K,V>
Type Parameters:
K - the type of the key
V - the type of the value
All Implemented Interfaces:
Aggregator<K,V,Long>

public class CountAggregator<K,V> extends Object implements Aggregator<K,V,Long>
Built-in aggregator that counts entries in the map.
  • Constructor Details

    • CountAggregator

      public CountAggregator()
      Create a new count aggregator.
  • Method Details

    • accumulate

      public void accumulate(Map.Entry<K,V> entry)
      Description copied from interface: Aggregator
      Accumulate a single entry into this aggregator.

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

      Specified by:
      accumulate in interface Aggregator<K,V,Long>
      Parameters:
      entry - the entry to accumulate (may be null if entry was deleted)
    • combine

      public Aggregator<K,V,Long> combine(Aggregator<K,V,Long> other)
      Description copied from interface: Aggregator
      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.

      Specified by:
      combine in interface Aggregator<K,V,Long>
      Parameters:
      other - the other aggregator to combine with (must not be null)
      Returns:
      a new aggregator combining both results (may be this or other)
    • aggregate

      public Long aggregate()
      Description copied from interface: Aggregator
      Get the final aggregated result.

      This is called after all entries have been accumulated and all partial results have been combined.

      Specified by:
      aggregate in interface Aggregator<K,V,Long>
      Returns:
      the aggregated result