Skip navigation links

Oracle® Coherence Java API Reference
Release 3.6.0.0

E15725-01


com.tangosol.util.aggregator
Class AbstractComparableAggregator

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

All Implemented Interfaces:
ExternalizableLite, PortableObject, InvocableMap.EntryAggregator, InvocableMap.ParallelAwareAggregator, Serializable
Direct Known Subclasses:
ComparableMax, ComparableMin

public abstract class AbstractComparableAggregator
extends AbstractAggregator

Abstract aggregator that processes values extracted from a set of entries in a Map, with knowledge of how to compare those values. There are two way to use the AbstractComparableAggregator:

If the set of entries passed to AbstractAggregator.aggregate(java.util.Set) is empty, a null result is returned.

Since:
Coherence 3.2
Author:
gg 2006.02.13

Field Summary
protected  Comparator m_comparator
          The comparator to use for comparing extracted values.
protected  int m_count
          The count of processed entries.
protected  Object m_oResult
          The running result value.

 

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

 

Constructor Summary
AbstractComparableAggregator()
          Default constructor (necessary for the ExternalizableLite interface).
AbstractComparableAggregator(String sMethod)
          Construct an AbstractComparableAggregator object.
AbstractComparableAggregator(ValueExtractor extractor)
          Construct an AbstractComparableAggregator object.
AbstractComparableAggregator(ValueExtractor extractor, Comparator comparator)
          Construct an AbstractComparableAggregator object.

 

Method Summary
protected  Object finalizeResult(boolean fFinal)
          Obtain the result of the aggregation.
protected  void init(boolean fFinal)
          Initialize the aggregation result.
 void readExternal(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.
 void writeExternal(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.aggregator.AbstractAggregator
aggregate, aggregateResults, equals, getParallelAggregator, getValueExtractor, hashCode, process, processEntry, toString

 

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_count

protected transient int m_count
The count of processed entries.

m_oResult

protected transient Object m_oResult
The running result value.

m_comparator

protected Comparator m_comparator
The comparator to use for comparing extracted values.

Constructor Detail

AbstractComparableAggregator

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

AbstractComparableAggregator

public AbstractComparableAggregator(ValueExtractor extractor)
Construct an AbstractComparableAggregator object.
Parameters:
extractor - the extractor that provides a value in the form of any object that implements the Comparable interface

AbstractComparableAggregator

public AbstractComparableAggregator(ValueExtractor extractor,
                                    Comparator comparator)
Construct an AbstractComparableAggregator object.
Parameters:
extractor - the extractor that provides an object to be compared
comparator - the comparator used to compare the extracted object

AbstractComparableAggregator

public AbstractComparableAggregator(String sMethod)
Construct an AbstractComparableAggregator object.
Parameters:
sMethod - the name of the method that returns a value in the form of any object that implements the Comparable interface

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

finalizeResult

protected Object finalizeResult(boolean fFinal)
Obtain the result of the aggregation. <p/> 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

readExternal

public void readExternal(DataInput in)
                  throws IOException
Restore the contents of this object by loading the object's state from the passed DataInput object.
Specified by:
readExternal in interface ExternalizableLite
Overrides:
readExternal in class AbstractAggregator
Parameters:
in - the DataInput stream to read data from in order to restore the state of this object
Throws:
IOException - if an I/O exception occurs
NotActiveException - if the object is not in its initial state, and therefore cannot be deserialized into

writeExternal

public void writeExternal(DataOutput out)
                   throws IOException
Save the contents of this object by storing the object's state into the passed DataOutput object.
Specified by:
writeExternal in interface ExternalizableLite
Overrides:
writeExternal in class AbstractAggregator
Parameters:
out - the DataOutput stream to write the state of this object to
Throws:
IOException - if an I/O exception occurs

readExternal

public void readExternal(PofReader in)
                  throws IOException
Restore the contents of a user type instance by reading its state using the specified PofReader object.
Specified by:
readExternal in interface PortableObject
Overrides:
readExternal in class AbstractAggregator
Parameters:
in - the PofReader from which to read the object's state
Throws:
IOException - if an I/O error occurs

writeExternal

public void writeExternal(PofWriter out)
                   throws 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
Overrides:
writeExternal in class AbstractAggregator
Parameters:
out - the PofWriter to which to write the object's state
Throws:
IOException - if an I/O error occurs

Skip navigation links

Oracle® Coherence Java API Reference
Release 3.6.0.0

E15725-01


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