Class GroupAggregator
The GroupAggregator provides an ability to split a subset of entries in an IInvocableCache into a collection of non-intersecting subsets and then aggregate them separately and independently.
Inherited Members
Namespace: Tangosol.Util.Aggregator
Assembly: Coherence.dll
Syntax
public class GroupAggregator : IEntryAggregator, IPortableObject
Remarks
The splitting (grouping) is performed using the results of the underlying IValueExtractor in such a way that two entries will belong to the same group if and only if the result of the corresponding Extract(object) 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 dictionary 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 IFilter object.
Informally speaking, this aggregator is analogous to the SQL "group by" and "having" clauses. Note that the "having" IFilter 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 IEntryAggregator implementations that are constructed directly, instances of GroupAggregator should only be created using one of the factory methods:
CreateInstance(IValueExtractor, IEntryAggregator) CreateInstance(IValueExtractor, IEntryAggregator, IFilter) CreateInstance(string, IEntryAggregator) CreateInstance(string, IEntryAggregator, IFilter)Constructors
GroupAggregator()
Default constructor.
Declaration
public GroupAggregator()
GroupAggregator(IValueExtractor, IEntryAggregator, IFilter)
Construct a GroupAggregator based on a specified IValueExtractor and underlying IEntryAggregator.
Declaration
protected GroupAggregator(IValueExtractor extractor, IEntryAggregator aggregator, IFilter filter)
Parameters
| Type | Name | Description |
|---|---|---|
| IValueExtractor | extractor | An IValueExtractor object that is used to split
IInvocableCache entries into
non-intersecting subsets; may not be |
| IEntryAggregator | aggregator | An IEntryAggregator object; may not be |
| IFilter | filter | An optional IFilter object used to filter out results of individual group aggregation results. |
Fields
m_aggregator
The underlying IEntryAggregator.
Declaration
protected IEntryAggregator m_aggregator
Field Value
| Type | Description |
|---|---|
| IEntryAggregator |
m_extractor
The underlying IValueExtractor.
Declaration
protected IValueExtractor m_extractor
Field Value
| Type | Description |
|---|---|
| IValueExtractor |
m_filter
The IFilter object representing the "having" clause of this "group by" aggregator.
Declaration
protected IFilter m_filter
Field Value
| Type | Description |
|---|---|
| IFilter |
Properties
Aggregator
Obtain the underlying IEntryAggregator.
Declaration
public virtual IEntryAggregator Aggregator { get; }
Property Value
| Type | Description |
|---|---|
| IEntryAggregator | The underlying IEntryAggregator. |
Extractor
Obtain the underlying IValueExtractor.
Declaration
public virtual IValueExtractor Extractor { get; }
Property Value
| Type | Description |
|---|---|
| IValueExtractor | The underlying IValueExtractor. |
Methods
Aggregate(ICollection)
Process a collection of IInvocableCacheEntry objects using the underlying extractor to split the entries into non-intersecting (distinct) groups and then apply the underlying aggregator separately to each group.
Declaration
public virtual object Aggregate(ICollection entries)
Parameters
| Type | Name | Description |
|---|---|---|
| ICollection | entries | A collection of read-only IInvocableCacheEntry objects to aggregate. |
Returns
| Type | Description |
|---|---|
| object | A dictionary that has the unique tuples as keys and results of the corresponding subset aggregation as values. |
CreateInstance(string, IEntryAggregator)
Create an instance of GroupAggregator based on a specified member name(s) and an IEntryAggregator.
Declaration
public static GroupAggregator CreateInstance(string member, IEntryAggregator aggregator)
Parameters
| Type | Name | Description |
|---|---|---|
| string | member | A member name or a comma-delimited sequence of names that results in a ReflectionExtractor or a MultiExtractor that will be used to split IInvocableCache entries into distinct groups. |
| IEntryAggregator | aggregator | An underlying IEntryAggregator. |
Returns
| Type | Description |
|---|---|
| GroupAggregator | An instance of GroupAggregator based on a specified member name(s) and an IEntryAggregator. |
Remarks
If the specified underlying aggregator is an instance of IParallelAwareAggregator, 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.
CreateInstance(string, IEntryAggregator, IFilter)
Create an instance of GroupAggregator based on a specified member name(s), an IEntryAggregator and a result evaluation filter.
Declaration
public static GroupAggregator CreateInstance(string member, IEntryAggregator aggregator, IFilter filter)
Parameters
| Type | Name | Description |
|---|---|---|
| string | member | A member name or a comma-delimited sequence of names that results in a ReflectionExtractor or a MultiExtractor that will be used to split IInvocableCache entries into distinct groups. |
| IEntryAggregator | aggregator | An underlying IEntryAggregator. |
| IFilter | filter | An optional IFilter object that will be used to evaluate results of each individual group aggregation. |
Returns
| Type | Description |
|---|---|
| GroupAggregator | An instance of GroupAggregator based on a specified member name(s), an IEntryAggregator and a result evaluation filter. |
Remarks
If the specified underlying aggregator is an instance of IParallelAwareAggregator, 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.
CreateInstance(IValueExtractor, IEntryAggregator)
Create an instance of GroupAggregator based on a specified extractor and an IEntryAggregator.
Declaration
public static GroupAggregator CreateInstance(IValueExtractor extractor, IEntryAggregator aggregator)
Parameters
| Type | Name | Description |
|---|---|---|
| IValueExtractor | extractor | An IValueExtractor that will be used to split a set of IInvocableDictionary entries into distinct groups. |
| IEntryAggregator | aggregator | An underlying IEntryAggregator. |
Returns
| Type | Description |
|---|---|
| GroupAggregator | An instance of GroupAggregator based on a specified extractor and an IEntryAggregator. |
Remarks
If the specified aggregator is an instance of IParallelAwareAggregator, 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.
CreateInstance(IValueExtractor, IEntryAggregator, IFilter)
Create an instance of GroupAggregator based on a specified extractor and an IEntryAggregator and a result evaluation filter.
Declaration
public static GroupAggregator CreateInstance(IValueExtractor extractor, IEntryAggregator aggregator, IFilter filter)
Parameters
| Type | Name | Description |
|---|---|---|
| IValueExtractor | extractor | An IValueExtractor that will be used to split a set of IInvocableDictionary entries into distinct groups. |
| IEntryAggregator | aggregator | An underlying IEntryAggregator. |
| IFilter | filter | An optional IFilter object used to filter out results of individual group aggregation results. |
Returns
| Type | Description |
|---|---|
| GroupAggregator | An instance of GroupAggregator based on a specified extractor and an IEntryAggregator and a result evaluation filter. |
Remarks
If the specified aggregator is an instance of IParallelAwareAggregator, 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.
Equals(object)
Compare the GroupAggregator with another object to determine equality.
Declaration
public override bool Equals(object o)
Parameters
| Type | Name | Description |
|---|---|---|
| object | o | The GroupAggregator to compare to. |
Returns
| Type | Description |
|---|---|
| bool | true if this GroupAggregator and the passed object are equivalent. |
Overrides
GetHashCode()
Determine a hash value for the GroupAggregator object according to the general object.GetHashCode() contract.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int | An integer hash value for this GroupAggregator object. |
Overrides
ReadExternal(IPofReader)
Restore the contents of a user type instance by reading its state using the specified IPofReader object.
Declaration
public virtual void ReadExternal(IPofReader reader)
Parameters
| Type | Name | Description |
|---|---|---|
| IPofReader | reader | The IPofReader from which to read the object's state. |
Exceptions
| Type | Condition |
|---|---|
| IOException | If an I/O error occurs. |
ToString()
Return a human-readable description for this GroupAggregator.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | A string description of the GroupAggregator. |
Overrides
WriteExternal(IPofWriter)
Save the contents of a POF user type instance by writing its state using the specified IPofWriter object.
Declaration
public virtual void WriteExternal(IPofWriter writer)
Parameters
| Type | Name | Description |
|---|---|---|
| IPofWriter | writer | The IPofWriter to which to write the object's state. |
Exceptions
| Type | Condition |
|---|---|
| IOException | If an I/O error occurs. |