Skip navigation links

Oracle® Fusion Middleware Java API Reference for Oracle Coherence
12c (12.1.3.0.0)

E47890-01


com.tangosol.util.aggregator
Class TopNAggregator

java.lang.Object
  extended by com.tangosol.util.aggregator.TopNAggregator

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

public class TopNAggregator
extends java.lang.Object
implements InvocableMap.ParallelAwareAggregator, InvocableMap.ParallelAwareAggregator.PartialResultAggregator, ExternalizableLite, PortableObject

TopNAggregator is a ParallelAwareAggregator that aggregates the top N extracted values into an array. The extracted values must not be null, but do not need to be unique.

Author:
rhl 2013.04.24

Nested Class Summary
static class TopNAggregator.PartialResult
          The sorted partial result.

 

Nested classes/interfaces inherited from interface com.tangosol.util.InvocableMap.ParallelAwareAggregator
InvocableMap.ParallelAwareAggregator.PartialResultAggregator

 

Field Summary
protected  java.util.Comparator m_comparator
          The Comparator used to order the extracted values.
protected  int m_cResults
          The maximum number of results to include in the aggregation result.
protected  ValueExtractor m_extractor
          The ValueExtractor used by this aggregator.
protected  boolean m_fParallel
          True iff this aggregator is to be used in parallel.

 

Constructor Summary
TopNAggregator()
          Default constructor.
TopNAggregator(ValueExtractor extractor, java.util.Comparator comparator, int cResults)
          Construct a TopNAggregator that will aggregate the top extracted values, as determined by the specified comparator.

 

Method Summary
protected  void addToResult(java.util.Iterator iterValues, TopNAggregator.PartialResult result)
          Add the specified values to the result if they are within the top-N.
 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 aggregatePartialResults(java.util.Collection colPartialResults)
          Aggregate the results of the parallel aggregations, producing a partial result logically representing the partial aggregation.
 java.lang.Object aggregateResults(java.util.Collection colResults)
          Aggregate the partial results of the parallel aggregations into a final result.
protected  java.lang.Object[] finalizeResult(TopNAggregator.PartialResult result)
          Finalize the partial aggregation result.
 InvocableMap.EntryAggregator getParallelAggregator()
          Get an aggregator that can take the place of this aggregator in situations in which the InvocableMap can aggregate in parallel.
 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.
 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.

 

Field Detail

m_fParallel

protected boolean m_fParallel
True iff this aggregator is to be used in parallel.

m_extractor

protected ValueExtractor m_extractor
The ValueExtractor used by this aggregator.

m_comparator

protected java.util.Comparator m_comparator
The Comparator used to order the extracted values.

m_cResults

protected int m_cResults
The maximum number of results to include in the aggregation result.

Constructor Detail

TopNAggregator

public TopNAggregator()
Default constructor.

TopNAggregator

public TopNAggregator(ValueExtractor extractor,
                      java.util.Comparator comparator,
                      int cResults)
Construct a TopNAggregator that will aggregate the top extracted values, as determined by the specified comparator.
Parameters:
extractor - the extractor
comparator - the comparator for extracted values
cResults - the maximum number of results to return

Method Detail

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.

If the returned aggregator is a InvocableMap.ParallelAwareAggregator.PartialResultAggregator, the partial results of the parallel aggregation may be further aggregated where optimal.

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 colResults)
Aggregate the partial results of the parallel aggregations into a final result.
Specified by:
aggregateResults in interface InvocableMap.ParallelAwareAggregator
Parameters:
colResults - the parallel aggregation results
Returns:
the aggregation of the parallel aggregation results

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

aggregatePartialResults

public java.lang.Object aggregatePartialResults(java.util.Collection colPartialResults)
Aggregate the results of the parallel aggregations, producing a partial result logically representing the partial aggregation. The returned partial result will be further aggregated to produce the final result.
Specified by:
aggregatePartialResults in interface InvocableMap.ParallelAwareAggregator.PartialResultAggregator
Parameters:
colPartialResults - the partial results
Returns:
an aggregation of the collection of partial results

addToResult

protected void addToResult(java.util.Iterator iterValues,
                           TopNAggregator.PartialResult result)
Add the specified values to the result if they are within the top-N.
Parameters:
iterValues - the iterator of values to add
result - the result

finalizeResult

protected java.lang.Object[] finalizeResult(TopNAggregator.PartialResult result)
Finalize the partial aggregation result.
Parameters:
result - the partial result
Returns:
the final aggregation result

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® Fusion Middleware Java API Reference for Oracle Coherence
12c (12.1.3.0.0)

E47890-01


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