Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.1.0

E22843-01


com.tangosol.util.aggregator
Class AbstractAggregator

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

All Implemented Interfaces:
ExternalizableLite, PortableObject, InvocableMap.EntryAggregator, InvocableMap.ParallelAwareAggregator, java.io.Serializable
Direct Known Subclasses:
AbstractBigDecimalAggregator, AbstractComparableAggregator, AbstractDoubleAggregator, AbstractLongAggregator, DistinctValues, ReducerAggregator

public abstract class AbstractAggregator
extends ExternalizableHelper
implements InvocableMap.ParallelAwareAggregator, ExternalizableLite, PortableObject

Abstract base class implementation of InvocableMap.EntryAggregator that supports parallel aggregation.

Since:
Coherence 3.1
Author:
cp/gg/jh 2005.07.19

Field Summary
protected  boolean m_fParallel
          Set to true if this aggregator realizes that it is going to be used in parallel.

 

Constructor Summary
AbstractAggregator()
          Default constructor (necessary for the ExternalizableLite interface).
AbstractAggregator(java.lang.String sMethod)
          Construct an AbstractAggregator that will aggregate values extracted from a set of InvocableMap.Entry objects.
AbstractAggregator(ValueExtractor extractor)
          Construct an AbstractAggregator that will aggregate values extracted from a set of InvocableMap.Entry objects.

 

Method Summary
 java.lang.Object aggregate(java.util.Set setEntries)
          Process a set of InvocableMap.Entry objects in order to produce an aggregated result.
 java.lang.Object aggregateResults(java.util.Collection collResults)
          Aggregate the results of the parallel aggregations.
 boolean equals(java.lang.Object o)
          Compares this object with another object for equality.
protected abstract  java.lang.Object finalizeResult(boolean fFinal)
          Obtain the result of the aggregation.
 InvocableMap.EntryAggregator getParallelAggregator()
          Get an aggregator that can take the place of this aggregator in situations in which the InvocableMap can aggregate in parallel.
 ValueExtractor getValueExtractor()
          Determine the ValueExtractor whose values this aggregator is aggregating.
 int hashCode()
          Returns a hash code value for this object.
protected abstract  void init(boolean fFinal)
          Initialize the aggregation result.
protected abstract  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.
 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()
          Provide a human-readable representation of this object.
 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_fParallel

protected boolean m_fParallel
Set to true if this aggregator realizes that it is going to be used in parallel.

Constructor Detail

AbstractAggregator

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

AbstractAggregator

public AbstractAggregator(ValueExtractor extractor)
Construct an AbstractAggregator that will aggregate values extracted from a set of InvocableMap.Entry objects.
Parameters:
extractor - the extractor that provides values to aggregate

AbstractAggregator

public AbstractAggregator(java.lang.String sMethod)
Construct an AbstractAggregator that will aggregate values extracted from a set of InvocableMap.Entry objects.
Parameters:
sMethod - the name of the method that could be invoked via reflection and that returns values to aggregate; this parameter can also be a dot-delimited sequence of method names which would result in an aggregator based on the ChainedExtractor that is based on an array of corresponding ReflectionExtractor objects

Method Detail

aggregate

public java.lang.Object aggregate(java.util.Set setEntries)
Process a set of InvocableMap.Entry objects in order to produce an aggregated result.
Specified by:
aggregate in interface InvocableMap.EntryAggregator
Parameters:
setEntries - a Set of read-only InvocableMap.Entry objects to aggregate
Returns:
the aggregated result from processing the entries

processEntry

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

getParallelAggregator

public InvocableMap.EntryAggregator getParallelAggregator()
Get an aggregator that can take the place of this aggregator in situations in which the InvocableMap can aggregate in parallel.
Specified by:
getParallelAggregator in interface InvocableMap.ParallelAwareAggregator
Returns:
the aggregator that will be run in parallel

aggregateResults

public java.lang.Object aggregateResults(java.util.Collection collResults)
Aggregate the results of the parallel aggregations.
Specified by:
aggregateResults in interface InvocableMap.ParallelAwareAggregator
Parameters:
collResults - the parallel aggregation results
Returns:
the aggregation of the parallel aggregation results

getValueExtractor

public ValueExtractor getValueExtractor()
Determine the ValueExtractor whose values this aggregator is aggregating.
Returns:
the ValueExtractor used by this aggregator

init

protected abstract void init(boolean fFinal)
Initialize the aggregation result.
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

process

protected abstract 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.

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 abstract 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.

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

toString

public java.lang.String toString()
Provide a human-readable representation of this object.
Returns:
a String whose contents represent the value of this object

hashCode

public int hashCode()
Returns a hash code value for this object.
Returns:
a hash code value for this object

equals

public boolean equals(java.lang.Object o)
Compares this object with another object for equality.
Parameters:
o - an object reference or null
Returns:
true iff the passed object reference is of the same class and has the same state as this object

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

Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.1.0

E22843-01


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