Class GroupAggregator<K,V,T,E,R>

Type Parameters:
K - the type of the Map entry keys
V - the type of the Map entry values
T - the type of the value to extract from
E - the type of the extracted value
R - the type of the group aggregator result
All Implemented Interfaces:
ExternalizableLite, PortableObject, InvocableMap.EntryAggregator<K,V,Map<E,R>>, InvocableMap.StreamingAggregator<K,V,Map<E,Object>,Map<E,R>>, Serializable
Direct Known Subclasses:
GroupAggregator.Parallel

public class GroupAggregator<K,V,T,E,R> extends ExternalizableHelper implements InvocableMap.StreamingAggregator<K,V,Map<E,Object>,Map<E,R>>, ExternalizableLite, PortableObject
The GroupAggregator provides an ability to split a subset of entries in an InvocableMap into a collection of non-intersecting subsets and then aggregate them separately and independently. The splitting (grouping) is performed using the results of the underlying ValueExtractor in such a way that two entries will belong to the same group if and only if the result of the corresponding extract call produces the same value or tuple (list of values). After the entries are split into the groups, the underlying aggregator is applied separately to each group. The result of the aggregation by the GroupAggregator is a Map that has distinct values (or tuples) as keys and results of the individual aggregation as values. Additionally, those results could be further reduced using an optional Filter object.

Informally speaking, this aggregator is analogous to the SQL "group by" and "having" clauses. Note that the "having" Filter is applied independently on each server against the partial aggregation results; this generally implies that data affinity is required to ensure that all required data used to generate a given result exists within a single cache partition. In other words, the "group by" predicate should not span multiple partitions if the "having" clause is used.

The GroupAggregator is somewhat similar to the DistinctValues aggregator, which returns back a list of distinct values (tuples) without performing any additional aggregation work.

Unlike many other concrete EntryAggregator implementations that are constructed directly, instances of GroupAggregator should only be created using one of the factory methods: createInstance(extractor, aggregator), createInstance(extractor, aggregator, filter), createInstance(sMethod, aggregator) createInstance(sMethod, aggregator, filter)

Since:
Coherence 3.2
Author:
gg 2006.02.15, as 2014.11.09
See Also:
  • Field Details

    • m_extractor

      protected ValueExtractor<? super T,? extends E> m_extractor
      The underlying ValueExtractor.
    • m_aggregator

      protected InvocableMap.EntryAggregator<? super K,? super V,R> m_aggregator
      The underlying EntryAggregator.
    • m_filter

      protected Filter m_filter
      The Filter object representing the "having" clause of this "group by" aggregator.
    • m_fInit

      protected transient boolean m_fInit
      Flag specifying whether this aggregator has been initialized.
    • m_fStreaming

      protected transient boolean m_fStreaming
      Flag specifying whether streaming optimizations can be used.
    • m_fParallel

      protected transient boolean m_fParallel
      Flag specifying whether parallel optimizations can be used.
    • m_mapResults

      protected transient Map<E,Object> m_mapResults
      A map of partial results to aggregate.
  • Constructor Details

    • GroupAggregator

      public GroupAggregator()
      Default constructor (necessary for the ExternalizableLite interface).
    • GroupAggregator

      protected GroupAggregator(ValueExtractor<? super T,? extends E> extractor, InvocableMap.EntryAggregator<? super K,? super V,R> aggregator, Filter filter)
      Construct a GroupAggregator based on a specified ValueExtractor and underlying EntryAggregator.
      Parameters:
      extractor - a ValueExtractor object that is used to split InvocableMap entries into non-intersecting subsets; may not be null
      aggregator - an EntryAggregator object; may not be null
      filter - an optional Filter object used to filter out results of individual group aggregation results
  • Method Details