Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.0.0

E18683-01


com.tangosol.util.aggregator
Class ReducerAggregator

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.util.BitHelper
          extended by com.tangosol.util.ExternalizableHelper
              extended by com.tangosol.util.aggregator.AbstractAggregator
                  extended by com.tangosol.util.aggregator.ReducerAggregator

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

public class ReducerAggregator
extends AbstractAggregator

The ReducerAggregator is used to implement functionality similar to CacheMap.getAll(Collection) API. Instead of returning the complete set of values, it will return a portion of value attributes based on the provided ValueExtractor.

This aggregator could be used in combination with MultiExtractor allowing one to collect tuples that are a subset of the attributes of each object stored in the cache.

Author:
djl 2009.03.02

Field Summary
protected  java.util.Map m_map
          The resulting map of reduced values.

 

Fields inherited from class com.tangosol.util.aggregator.AbstractAggregator
m_fParallel

 

Constructor Summary
ReducerAggregator()
          Default constructor (necessary for the ExternalizableLite interface).
ReducerAggregator(java.lang.String sMethod)
          Construct a ReducerAggregator based on the specified method name.
ReducerAggregator(ValueExtractor extractor)
          Construct a ReducerAggregator based on the specified extractor.

 

Method Summary
protected  java.util.Map ensureMap()
          Return a map that can be used to store reduced values, creating it if one has not already been created.
protected  java.lang.Object finalizeResult(boolean fFinal)
          Obtain the result of the aggregation.
protected  void init(boolean fFinal)
          Initialize the aggregation result.
protected  void process(java.lang.Object o, boolean fFinal)
          Incorporate one aggregatable value into the result.
protected  void processEntry(InvocableMap.Entry entry)
          Incorporate one aggregatable entry into the result.

 

Methods inherited from class com.tangosol.util.aggregator.AbstractAggregator
aggregate, aggregateResults, equals, getParallelAggregator, getValueExtractor, hashCode, readExternal, readExternal, toString, writeExternal, writeExternal

 

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_map

protected transient java.util.Map m_map
The resulting map of reduced values.

Constructor Detail

ReducerAggregator

public ReducerAggregator()
Default constructor (necessary for the ExternalizableLite interface).

ReducerAggregator

public ReducerAggregator(java.lang.String sMethod)
Construct a ReducerAggregator based on the specified method name.
Parameters:
sMethod - the name of the method that is used to extract the portion of the cached value

ReducerAggregator

public ReducerAggregator(ValueExtractor extractor)
Construct a ReducerAggregator based on the specified extractor.
Parameters:
extractor - the extractor that is used to extract the portion of the cached value

Method Detail

init

protected void init(boolean fFinal)
Initialize the aggregation result.
Specified by:
init in class AbstractAggregator
Parameters:
fFinal - true is passed if the aggregation process that is being initialized must produce a final aggregation result; this will only be false if a parallel approach is being used and the initial (partial) aggregation process is being initialized

processEntry

protected void processEntry(InvocableMap.Entry entry)
Incorporate one aggregatable entry into the result.
Overrides:
processEntry in class AbstractAggregator
Parameters:
entry - the entry to incorporate into the aggregation result

process

protected void process(java.lang.Object o,
                       boolean fFinal)
Incorporate one aggregatable value into the result.

If the fFinal parameter is true, the given object is a partial result (returned by an individual parallel aggregator) that should be incorporated into the final result; otherwise, the object is a value extracted from an InvocableMap.Entry.

Specified by:
process in class AbstractAggregator
Parameters:
o - the value to incorporate into the aggregated result
fFinal - true to indicate that the given object is a partial result returned by a parallel aggregator

finalizeResult

protected java.lang.Object finalizeResult(boolean fFinal)
Obtain the result of the aggregation.

If the fFinal parameter is true, the returned object must be the final result of the aggregation; otherwise, the returned object will be treated as a partial result that should be incorporated into the final result.

Specified by:
finalizeResult in class AbstractAggregator
Parameters:
fFinal - true to indicate that the final result of the aggregation process should be returned; this will only be false if a parallel approach is being used
Returns:
the result of the aggregation process

ensureMap

protected java.util.Map ensureMap()
Return a map that can be used to store reduced values, creating it if one has not already been created.
Returns:
a set that can be used to store distinct values

Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.0.0

E18683-01


Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.