Overview | Package | Class | Tree | Index | Help

Oracle® Coherence Java API Reference
v3.5.3
E15583-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.tangosol.util.aggregator
Class GroupAggregator

    java.lang.Object
      com.tangosol.util.Base
          com.tangosol.util.BitHelper
              com.tangosol.util.ExternalizableHelper
                  com.tangosol.util.aggregator.GroupAggregator

All Implemented Interfaces:
  ExternalizableLite, PortableObject, InvocableMap.EntryAggregator, java.io.Serializable

Direct Known Subclasses:
  GroupAggregator.Parallel

    public class GroupAggregator

extends ExternalizableHelper
implements InvocableMap.EntryAggregator, 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

Nested Class Summary
`static class` | `GroupAggregator.Parallel` Parallel implementation of the GroupAggregator.

Field Summary
`protected InvocableMap.EntryAggregator` | `m_aggregator` The underlying EntryAggregator.
`protected ValueExtractor` | `m_extractor` The underlying ValueExtractor.
`protected Filter` | `m_filter` The Filter object representing the "having" clause of this "group by" aggregator.

Constructor Summary
`` | `GroupAggregator()` Default constructor (necessary for the ExternalizableLite interface).
`protected` | `GroupAggregator(ValueExtractor extractor, InvocableMap.EntryAggregator aggregator, Filter filter)` Construct a GroupAggregator based on a specified ValueExtractor and underlying EntryAggregator.

Method Summary
`java.lang.Object` | `aggregate(java.util.Set setEntries)` Process a set of InvocableMap Entry objects using the underlying extractor to split the entries into non-intersecting (distinct) groups and then apply the underlying aggregator separately to each group.
`static GroupAggregator` | `createInstance(java.lang.String sMethod, InvocableMap.EntryAggregator aggregator)` Create an instance of GroupAggregator based on a specified method name(s) and an `EntryAggregator`.
`static GroupAggregator` | `createInstance(java.lang.String sMethod, InvocableMap.EntryAggregator aggregator, Filter filter)` Create an instance of GroupAggregator based on a specified method name(s), an `EntryAggregator` and a result evaluation filter.
`static GroupAggregator` | `createInstance(ValueExtractor extractor, InvocableMap.EntryAggregator aggregator)` Create an instance of GroupAggregator based on a specified extractor and an `EntryAggregator`.
`static GroupAggregator` | `createInstance(ValueExtractor extractor, InvocableMap.EntryAggregator aggregator, Filter filter)` Create an instance of GroupAggregator based on a specified extractor and an `EntryAggregator` and a result evaluation filter.
`boolean` | `equals(java.lang.Object o)` Compare the GroupAggregator with another object to determine equality.
`InvocableMap.EntryAggregator` | `getAggregator()` Obtain the underlying EntryAggregator.
`ValueExtractor` | `getExtractor()` Obtain the underlying ValueExtractor.
`int` | `hashCode()` Determine a hash value for the GroupAggregator object according to the general `Object.hashCode()` contract.
`void` | `readExternal(java.io.DataInput in)` Restore the contents of this object by loading the object's state from the passed DataInput object.
`void` | `readExternal(PofReader in)` Restore the contents of a user type instance by reading its state using the specified PofReader object.
`java.lang.String` | `toString()` Return a human-readable description for this GroupAggregator.
`void` | `writeExternal(java.io.DataOutput out)` Save the contents of this object by storing the object's state into the passed DataOutput object.
`void` | `writeExternal(PofWriter out)` Save the contents of a POF user type instance by writing its state using the specified PofWriter object.

Methods inherited from class com.tangosol.util.BitHelper
`countBits, countBits, countBits, indexOfLSB, indexOfLSB, indexOfLSB, indexOfMSB, indexOfMSB, indexOfMSB, rotateLeft, rotateLeft, rotateLeft, rotateRight, rotateRight, rotateRight, toBitString, toBitString, toBitString`

Field Detail

### m_extractor

    protected ValueExtractor m_extractor

  The underlying ValueExtractor.

### m_aggregator

    protected InvocableMap.EntryAggregator m_aggregator

  The underlying EntryAggregator.

### m_filter

    protected Filter m_filter

  The Filter object representing the "having" clause of this "group by" aggregator.

Constructor Detail

### GroupAggregator

    public GroupAggregator()

  Default constructor (necessary for the ExternalizableLite interface).

### GroupAggregator

    protected GroupAggregator(ValueExtractor extractor,
                              InvocableMap.EntryAggregator 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-itersecting 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 Detail

### aggregate

    public java.lang.Object aggregate(java.util.Set setEntries)

  Process a set of InvocableMap Entry objects using the underlying extractor to split the entries into non-intersecting (distinct) groups and then apply the underlying aggregator separately to each group.

  Specified by:
    `aggregate` in interface `InvocableMap.EntryAggregator`
  Parameters:
    `setEntries` - a Set of read-only InvocableMap Entry objects to aggregate
  Returns:
    a Map that has the unique tuples as keys and results of the corresponding subset aggregation as values

### readExternal

    public void readExternal(java.io.DataInput in)
                      throws java.io.IOException

  Restore the contents of this object by loading the object's state from the passed DataInput object.

  Specified by:
    `readExternal` in interface `ExternalizableLite`
  Parameters:
    `in` - the DataInput stream to read data from in order to restore the state of this object
  Throws:
    `java.io.IOException` - if an I/O exception occurs
    `java.io.NotActiveException` - if the object is not in its initial state, and therefore cannot be deserialized into

### writeExternal

    public void writeExternal(java.io.DataOutput out)
                       throws java.io.IOException

  Save the contents of this object by storing the object's state into the passed DataOutput object.

  Specified by:
    `writeExternal` in interface `ExternalizableLite`
  Parameters:
    `out` - the DataOutput stream to write the state of this object to
  Throws:
    `java.io.IOException` - if an I/O exception occurs

### readExternal

    public void readExternal(PofReader in)
                      throws java.io.IOException

  Restore the contents of a user type instance by reading its state using the specified PofReader object.

  Specified by:
    `readExternal` in interface `PortableObject`
  Parameters:
    `in` - the PofReader from which to read the object's state
  Throws:
    `java.io.IOException` - if an I/O error occurs

### writeExternal

    public void writeExternal(PofWriter out)
                       throws java.io.IOException

  Save the contents of a POF user type instance by writing its state using the specified PofWriter object.

  Specified by:
    `writeExternal` in interface `PortableObject`
  Parameters:
    `out` - the PofWriter to which to write the object's state
  Throws:
    `java.io.IOException` - if an I/O error occurs

### getExtractor

    public ValueExtractor getExtractor()

  Obtain the underlying ValueExtractor.

  Returns:
    the underlying ValueExtractor

### getAggregator

    public InvocableMap.EntryAggregator getAggregator()

  Obtain the underlying EntryAggregator.

  Returns:
    the underlying EntryAggregator

### equals

    public boolean equals(java.lang.Object o)

  Compare the GroupAggregator with another object to determine equality.

  Returns:
    true iff this GroupAggregator and the passed object are equivalent

### hashCode

    public int hashCode()

  Determine a hash value for the GroupAggregator object according to the general `Object.hashCode()` contract.

  Returns:
    an integer hash value for this GroupAggregator object

### toString

    public java.lang.String toString()

  Return a human-readable description for this GroupAggregator.

  Returns:
    a String description of the GroupAggregator

### createInstance

    public static GroupAggregator createInstance(java.lang.String sMethod,
                                                 InvocableMap.EntryAggregator aggregator)

  Create an instance of GroupAggregator based on a specified method name(s) and an `EntryAggregator`.
  If the specified underlying aggregator is an instance of `ParallelAwareAggregator`, then a parallel-aware instance of the GroupAggregator will be created. Otherwise, the resulting GroupAggregator will not be parallel-aware and could be ill-suited for aggregations run against large partitioned caches.

  Parameters:
    `sMethod` - a method name or a comma-delimited sequence of names that results in a `ReflectionExtractor` or a `MultiExtractor` that will be used to split InvocableMap entries into distinct groups
    `aggregator` - an underlying EntryAggregator

### createInstance

    public static GroupAggregator createInstance(java.lang.String sMethod,
                                                 InvocableMap.EntryAggregator aggregator,
                                                 Filter filter)

  Create an instance of GroupAggregator based on a specified method name(s), an `EntryAggregator` and a result evaluation filter.
  If the specified underlying aggregator is an instance of `ParallelAwareAggregator`, then a parallel-aware instance of the GroupAggregator will be created. Otherwise, the resulting GroupAggregator will not be parallel-aware and could be ill-suited for aggregations run against large partitioned caches.

  Parameters:
    `sMethod` - a method name or a comma-delimited sequence of names that results in a `ReflectionExtractor` or a `MultiExtractor` that will be used to split InvocableMap entries into distinct groups
    `aggregator` - an underlying EntryAggregator
    `filter` - an optional Filter object that will be used to evaluate results of each individual group aggregation

### createInstance

    public static GroupAggregator createInstance(ValueExtractor extractor,
                                                 InvocableMap.EntryAggregator aggregator)

  Create an instance of GroupAggregator based on a specified extractor and an `EntryAggregator`.
  If the specified aggregator is an instance of `ParallelAwareAggregator`, then a parallel-aware instance of the GroupAggregator will be created. Otherwise, the resulting GroupAggregator will not be parallel-aware and could be ill-suited for aggregations run against large partitioned caches.

  Parameters:
    `extractor` - a ValueExtractor that will be used to split a set of InvocableMap entries into distinct groups
    `aggregator` - an underlying EntryAggregator

### createInstance

    public static GroupAggregator createInstance(ValueExtractor extractor,
                                                 InvocableMap.EntryAggregator aggregator,
                                                 Filter filter)

  Create an instance of GroupAggregator based on a specified extractor and an `EntryAggregator` and a result evaluation filter.
  If the specified aggregator is an instance of `ParallelAwareAggregator`, then a parallel-aware instance of the GroupAggregator will be created. Otherwise, the resulting GroupAggregator will not be parallel-aware and could be ill-suited for aggregations run against large partitioned caches.

  Parameters:
    `extractor` - a ValueExtractor that will be used to split a set of InvocableMap entries into distinct groups
    `aggregator` - an underlying EntryAggregator
    `filter` - an optional Filter object used to filter out results of individual group aggregation results

Overview | Package | Class | Tree | Index | Help

Oracle® Coherence Java API Reference
v3.5.3
E15583-01
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000, 2010, Oracle. All rights reserved.