K
- the type of the Map entry keysV
- the type of the Map entry valuesP
- the type of the partial resultR
- the type of the final resultpublic static interface InvocableMap.StreamingAggregator<K,V,P,R> extends InvocableMap.EntryAggregator<K,V,R>
InvocableMap.EntryAggregator
that
processes entries in a streaming fashion and provides better control
over execution characteristics
.
It is strongly recommended that all new custom aggregator implementations
implement this interface directly and override default implementation of
the characteristics()
method which intentionally errs on a
conservative side.
InvocableMap.EntryAggregator
Modifier and Type | Field and Description |
---|---|
static int |
ALLOW_INCONSISTENCIES
|
static int |
BY_MEMBER
A flag specifying that it might be beneficial to execute this aggregator
member-by-member.
|
static int |
BY_PARTITION
A flag specifying that it might be beneficial to execute this aggregator
partition-by-partition.
|
static int |
PARALLEL
A flag specifying that this aggregator should be executed in parallel.
|
static int |
PRESENT_ONLY
A flag specifying that this aggregator is only interested in entries
that are present in the cache and that the entries which are not present
should never be passed to the
StreamingAggregator#accumulate(Entry) method. |
static int |
RETAINS_ENTRIES
A flag specifying that this aggregator retains
InvocableMap.Entry instances
passed to StreamingAggregator#accumulate(Entry) method, which will force creation
of a separate InvocableMap.Entry instance for each cache entry. |
static int |
SERIAL
A flag specifying that this aggregator should be executed serially.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accumulate(InvocableMap.Entry<? extends K,? extends V> entry)
Accumulate one entry into the result.
|
default boolean |
accumulate(Streamer<? extends InvocableMap.Entry<? extends K,? extends V>> streamer)
Accumulate multiple entries into the result.
|
default R |
aggregate(Set<? extends InvocableMap.Entry<? extends K,? extends V>> setEntries)
Process a set of InvocableMap.Entry objects in order to produce an
aggregated result.
|
default int |
characteristics()
A bit mask representing the set of characteristics of this aggregator.
|
boolean |
combine(P partialResult)
Merge another partial result into the result.
|
R |
finalizeResult()
Return the final result of the aggregation.
|
P |
getPartialResult()
Return the partial result of the aggregation.
|
default boolean |
isAllowInconsistencies()
A convenience accessor to check if this streamer is
ALLOW_INCONSISTENCIES . |
default boolean |
isByMember()
A convenience accessor to check if this streamer is
BY_MEMBER . |
default boolean |
isByPartition()
A convenience accessor to check if this streamer is
BY_PARTITION . |
default boolean |
isParallel()
A convenience accessor to check if this streamer is
PARALLEL . |
default boolean |
isPresentOnly()
A convenience accessor to check if this streamer is
PRESENT_ONLY . |
default boolean |
isRetainsEntries()
A convenience accessor to check if this streamer is
RETAINS_ENTRIES . |
default boolean |
isSerial()
A convenience accessor to check if this streamer is
SERIAL . |
InvocableMap.StreamingAggregator<K,V,P,R> |
supply()
Create a new instance of this aggregator.
|
static final int PARALLEL
An additional hint can be provided by combining this flag with BY_PARTITION
flag, which would suggest to further parallelize the
server side aggregation by splitting it per-partitions. In the absence
of this flag, Coherence is free to decide which strategy to use based
on the internal metrics.
static final int SERIAL
An additional hint can be provided by combining this flag with either
BY_MEMBER
or BY_PARTITION
flag, which are mutually
exclusive. In the absence of either, Coherence is free to decide which
strategy to use based on the internal metrics.
static final int BY_MEMBER
This can be beneficial when there is a high chance for the aggregation to compute the result based solely on the one member worth set of entries.
Note: this flag is meaningful only for serial execution
.
static final int BY_PARTITION
This can be beneficial when accumulation of individual entries is computationally intensive and would benefit from additional parallelization within each storage-enabled member. In this case, the partial results for all the partitions on a given member will be combined into a single partial result, which will then be sent back to the client for further aggregation.
static final int RETAINS_ENTRIES
InvocableMap.Entry
instances
passed to StreamingAggregator#accumulate(Entry)
method, which will force creation
of a separate InvocableMap.Entry
instance for each cache entry.
Please note that this flag is specified by default for backwards
compatibility reasons, but if the aggregator does not retain entries
it should be "unset" by overriding characteristics()
method
in order to reduce the amount of garbage that is created during the
aggregation.
static final int PRESENT_ONLY
StreamingAggregator#accumulate(Entry)
method.static final int ALLOW_INCONSISTENCIES
entries
that are not consistent with the provided Filter
.
Note: Coherence will ensure only entries that match the provided
Filter
are passed to the aggregator, which can result in
repeat query evaluations if targetted partitions are concurrently
modified during query evaluation. This option allows Coherence to
relax this contract.
InvocableMap.StreamingAggregator<K,V,P,R> supply()
default boolean accumulate(Streamer<? extends InvocableMap.Entry<? extends K,? extends V>> streamer)
Important note: The default implementation of this method provides necessary logic for aggregation short-circuiting and should rarely (if ever) be overridden by the custom aggregator implementation.
streamer
- a Streamer
that can be used to iterate over
entries to addtrue
to continue the aggregation, and false
to
signal to the caller that the result is ready and the
aggregation can be short-circuitedboolean accumulate(InvocableMap.Entry<? extends K,? extends V> entry)
entry
- the entry to accumulate into the aggregation resulttrue
to continue the aggregation, and false
to
signal to the caller that the result is ready and the
aggregation can be short-circuitedboolean combine(P partialResult)
partialResult
- the partial result to mergetrue
to continue the aggregation, and false
to
signal to the caller that the result is ready and the
aggregation can be short-circuitedP getPartialResult()
R finalizeResult()
default int characteristics()
Be default, characteristics are a combination of PARALLEL
and RETAINS_ENTRIES
, which is sub-optimal and should be
overridden by the aggregator implementation if the aggregator does not
need to retain entries (which is often the case).
PARALLEL
,
SERIAL
,
BY_MEMBER
,
BY_PARTITION
,
RETAINS_ENTRIES
,
PRESENT_ONLY
default boolean isParallel()
PARALLEL
.true
if this streamer is PARALLEL
, false otherwisedefault boolean isSerial()
SERIAL
.true
if this streamer is SERIAL
, false otherwisedefault boolean isByMember()
BY_MEMBER
.true
if this streamer is BY_MEMBER
, false otherwisedefault boolean isByPartition()
BY_PARTITION
.true
if this streamer is BY_PARTITION
, false otherwisedefault boolean isRetainsEntries()
RETAINS_ENTRIES
.true
if this streamer is RETAINS_ENTRIES
, false otherwisedefault boolean isPresentOnly()
PRESENT_ONLY
.true
if this streamer is PRESENT_ONLY
, false otherwisedefault boolean isAllowInconsistencies()
ALLOW_INCONSISTENCIES
.true
if this streamer is ALLOW_INCONSISTENCIES
, false otherwisedefault R aggregate(Set<? extends InvocableMap.Entry<? extends K,? extends V>> setEntries)
InvocableMap.EntryAggregator
aggregate
in interface InvocableMap.EntryAggregator<K,V,R>
setEntries
- a Set of read-only InvocableMap.Entry objects to
aggregate