|
Oracle® Coherence Java API Reference Release 3.7.1.0 E22843-01 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
com.tangosol.util.Base
com.tangosol.util.BitHelper
com.tangosol.util.ExternalizableHelper
com.tangosol.util.aggregator.GroupAggregator
public class GroupAggregator
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)
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 |
---|
protected ValueExtractor m_extractor
protected InvocableMap.EntryAggregator m_aggregator
protected Filter m_filter
Constructor Detail |
---|
public GroupAggregator()
protected GroupAggregator(ValueExtractor extractor, InvocableMap.EntryAggregator aggregator, Filter filter)
extractor
- a ValueExtractor object that is used to split InvocableMap entries into non-itersecting subsets; may not be nullaggregator
- an EntryAggregator object; may not be nullfilter
- an optional Filter object used to filter out results of individual group aggregation resultsMethod Detail |
---|
public java.lang.Object aggregate(java.util.Set setEntries)
aggregate
in interface InvocableMap.EntryAggregator
setEntries
- a Set of read-only InvocableMap Entry objects to aggregatepublic void readExternal(java.io.DataInput in) throws java.io.IOException
readExternal
in interface ExternalizableLite
in
- the DataInput stream to read data from in order to restore the state of this objectjava.io.IOException
- if an I/O exception occursjava.io.NotActiveException
- if the object is not in its initial state, and therefore cannot be deserialized intopublic void writeExternal(java.io.DataOutput out) throws java.io.IOException
writeExternal
in interface ExternalizableLite
out
- the DataOutput stream to write the state of this object tojava.io.IOException
- if an I/O exception occurspublic void readExternal(PofReader in) throws java.io.IOException
readExternal
in interface PortableObject
in
- the PofReader from which to read the object's statejava.io.IOException
- if an I/O error occurspublic void writeExternal(PofWriter out) throws java.io.IOException
writeExternal
in interface PortableObject
out
- the PofWriter to which to write the object's statejava.io.IOException
- if an I/O error occurspublic ValueExtractor getExtractor()
public InvocableMap.EntryAggregator getAggregator()
public boolean equals(java.lang.Object o)
public int hashCode()
Object.hashCode()
contract.public java.lang.String toString()
public static GroupAggregator createInstance(java.lang.String sMethod, InvocableMap.EntryAggregator aggregator)
EntryAggregator
.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.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 groupsaggregator
- an underlying EntryAggregatorpublic static GroupAggregator createInstance(java.lang.String sMethod, InvocableMap.EntryAggregator aggregator, Filter filter)
EntryAggregator
and a result evaluation filter.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.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 groupsaggregator
- an underlying EntryAggregatorfilter
- an optional Filter object that will be used to evaluate results of each individual group aggregationpublic static GroupAggregator createInstance(ValueExtractor extractor, InvocableMap.EntryAggregator aggregator)
EntryAggregator
.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.extractor
- a ValueExtractor that will be used to split a set of InvocableMap entries into distinct groupsaggregator
- an underlying EntryAggregatorpublic static GroupAggregator createInstance(ValueExtractor extractor, InvocableMap.EntryAggregator aggregator, Filter filter)
EntryAggregator
and a result evaluation filter.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.extractor
- a ValueExtractor that will be used to split a set of InvocableMap entries into distinct groupsaggregator
- an underlying EntryAggregatorfilter
- an optional Filter object used to filter out results of individual group aggregation results
|
Oracle® Coherence Java API Reference Release 3.7.1.0 E22843-01 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |