#include <coherence/util/aggregator/AbstractAggregator.hpp>
Inherits Object, PortableObject, and InvocableMap::ParallelAwareAggregator.
Inherited by AbstractComparableAggregator, AbstractFloat64Aggregator, AbstractInteger64Aggregator, DistinctValues, and ReducerAggregator.
For aggregators which only run within the Coherence cluster (most common case), the C++ init, process, finalizeResult, aggregate, and aggregateResults methods can be left unimplemented.
Public Types | ||||
typedef spec::Handle | Handle | |||
AbstractAggregator Handle definition. | ||||
typedef spec::View | View | |||
AbstractAggregator View definition. | ||||
typedef spec::Holder | Holder | |||
AbstractAggregator Holder definition. | ||||
Public Member Functions | ||||
virtual Object::Holder | aggregate (Set::View vSetEntries) | |||
Process a set of InvocableMap::Entry objects in order to produce an aggregated result.
| ||||
virtual InvocableMap::EntryAggregator::Handle | getParallelAggregator () | |||
Get an aggregator that can take the place of this aggregator in situations in which the InvocableMap can aggregate in parallel.
| ||||
virtual Object::Holder | aggregateResults (Collection::View vCollResults) | |||
Aggregate the results of the parallel aggregations.
| ||||
virtual void | readExternal (PofReader::Handle hIn) | |||
virtual void | writeExternal (PofWriter::Handle hOut) const | |||
virtual bool | equals (Object::View v) const | |||
virtual size32_t | hashCode () const | |||
Return a hash code value for the Object. This method is supported for the benefit of hash-based containers.
The general contract of
The default implementation is identity based.
| ||||
virtual TypedHandle < const String > | toString () const | |||
Output a human-readable description of this Object to the given stream. Note that when overriding this method the return type must be TypedHandle<const String> rather then String::View. These two types are assignment compatible but not equivalent and declaring the override with String::View will not be a compatible override. coherence::lang::operator<<(std::ostream, Object::View) is defined and will call into the toString method, to output Objects. If a managed String object is desired, the COH_TO_STRING macro can be used to build up a String from streamable contents and is generally how toString() will be implemented.
Object::View vKey = ... Object::View vValue = ... std::cout << vKey << " = " << vValue << std::endl; String::View vs = COH_TO_STRING(vKey << " = " << vValue); The COH_TO_STRING macro is also the most common way to implement the toString method. For example:
virtual TypedHandle<const String> Person::toString() const { return COH_TO_STRING("Name: " << f_sName << " SSN: " << f_nSSN); }
| ||||
virtual ValueExtractor::View | getValueExtractor () const | |||
Determine the ValueExtractor whose values this aggregator is aggregating. | ||||
Protected Member Functions | ||||
AbstractAggregator (String::View vsMethod) | ||||
Construct an AbstractAggregator that will aggregate values extracted from a set of InvocableMap::Entry objects. | ||||
virtual void | init (bool fFinal) | |||
Initialize the aggregation result. | ||||
virtual void | process (Object::View vO, bool fFinal) | |||
Incorporate one aggregatable value into the result. | ||||
virtual Object::Holder | finalizeResult (bool fFinal) | |||
Obtain the result of the aggregation. | ||||
Protected Attributes | ||||
bool | m_fParallel | |||
Set to true if this aggregator realizes that it is going to be used in parallel. | ||||
FinalView < ValueExtractor > | f_vExtractor | |||
The ValueExtractor that obtains the value to aggregate from the value that is stored in the Map. |
AbstractAggregator | ( | String::View | vsMethod | ) | [protected] |
Construct an AbstractAggregator that will aggregate values extracted from a set of InvocableMap::Entry objects.
vsMethod | 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 |
virtual void init | ( | bool | fFinal | ) | [protected, virtual] |
Initialize the aggregation result.
This implementation throws an UnsupportedOperationException.
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 |
Reimplemented in AbstractComparableAggregator, AbstractFloat64Aggregator, AbstractInteger64Aggregator, DistinctValues, Float64Average, Float64Max, Float64Min, Float64Sum, Integer64Max, Integer64Min, Integer64Sum, and ReducerAggregator.
virtual void process | ( | Object::View | vO, | |
bool | fFinal | |||
) | [protected, virtual] |
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 coherence::util::InvocableMap::Entry.
This implementation throws an UnsupportedOperationException.
vO | 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 |
Reimplemented in ComparableMax, ComparableMin, DistinctValues, Float64Average, Float64Max, Float64Min, Float64Sum, Integer64Max, Integer64Min, Integer64Sum, and ReducerAggregator.
virtual Object::Holder finalizeResult | ( | bool | fFinal | ) | [protected, virtual] |
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.
This implementation throws an UnsupportedOperationException.
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 |
Reimplemented in AbstractComparableAggregator, AbstractFloat64Aggregator, AbstractInteger64Aggregator, DistinctValues, Float64Average, and ReducerAggregator.
virtual ValueExtractor::View getValueExtractor | ( | ) | const [virtual] |
Determine the ValueExtractor whose values this aggregator is aggregating.