Oracle Coherence for C++ API


GroupAggregator Class Reference

#include <coherence/util/aggregator/GroupAggregator.hpp>

Inherits Object, PortableObject, and InvocableMap::EntryAggregator.

Inherited by ParallelGroupAggregator.

List of all members.

Detailed Description

The GroupAggregator provides an ability to split a subset of entries in an InvocableMap into a collection of non-intersecting subsets and then aggregate them separately and independently.

The splitting (grouping) is performed using the results of the underlying ValueExtractor in such a way that two entries will belong to the same group if and only if the result of the corresponding ValueExtractor::extract extract call produces the same value or tuple (list of values). After the entries are split into the groups, the underlying aggregator is applied separately to each group. The result of the aggregation by the GroupAggregator is a Map that has distinct values (or tuples) as keys and results of the individual aggregation as values. Additionally, those results could be further reduced using an optional Filter object.

Informally speaking, this aggregator is analogous to the SQL "group by" and "having" clauses. Note that the "having" Filter is applied independently on each server against the partial aggregation results; this generally implies that data affinity is required to ensure that all required data used to generate a given result exists within a single cache partition. In other words, the "group by" predicate should not span multiple partitions if the "having" clause is used.

The GroupAggregator is somewhat similar to the DistinctValues aggregator, which returns back a list of distinct values (tuples) without performing any additional aggregation work.

Unlike many other concrete EntryAggregator implementations that are constructed directly, instances of GroupAggregator should only be created using one of the factory methods: create(ValueExtractor, InvocableMap::EntryAggregator) create(vExtractor, hAggregator), create(ValueExtractor, InvocableMap::EntryAggregator, Filter),

djl 2008.05.16

Public Types

typedef spec::Handle Handle
 GroupAggregator Handle definition.
typedef spec::View View
 GroupAggregator View definition.
typedef spec::Holder Holder
 GroupAggregator 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.

vSetEntries a Set of read-only InvocableMap::Entry objects to aggregate
the aggregated result from processing the entries

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 hashCode is:

  • Whenever it is invoked on the same Object more than once during an execution of an application, the hashCode method must consistently return the same value, provided no information used in equals comparisons on the object is modified. This value need not remain consistent from one execution of an application to another execution of the same application.
  • If two Objects are equal according to the equals method, then calling the hashCode method on each of the two Objects must produce the same value.
  • It is not required that if two Objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct results. However, the programmer should be aware that producing distinct results for unequal objects may improve the performance of hash-based containers.

The default implementation is identity based.

a hash code value for this Object

virtual void toStream (std::ostream &out) const
 Output a human-readable description of this Object to the given stream.

coherence::lang::operator<<(std::ostream, Object::View) is defined and will call into the toStream 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.

 Object::View vKey   = ...
 Object::View vValue = ...
 std::cout << vKey << " = " << vValue << std::endl;

 String::Handle hs = COH_TO_STRING(vKey << " = " << vValue);

out the stream used to output the description

getExtractor () const
 Obtain the underlying ValueExtractor.
getAggregator ()
 Obtain the underlying EntryAggregator.
getAggregator () const
 Obtain the underlying EntryAggregator.

Static Public Member Functions

create ()
 Default constructor (necessary for the PortableObject interface).
create (ValueExtractor::View vExtractor, InvocableMap::EntryAggregator::Handle hAggregator, Filter::View vFilter=NULL)
 Create an instance of GroupAggregator based on a specified extractor and an coherence::util::InvocableMap::EntryAggregator and a result evaluation filter.

Protected Attributes

< ValueExtractor
 The underlying ValueExtractor.
< InvocableMap::EntryAggregator
 The underlying EntryAggregator.
MemberView< Filterm_vFilter
 The underlying Filter.

Member Function Documentation

static GroupAggregator::Handle create ( ValueExtractor::View  vExtractor,
InvocableMap::EntryAggregator::Handle  hAggregator,
Filter::View  vFilter = NULL 
) [static]

Create an instance of GroupAggregator based on a specified extractor and an coherence::util::InvocableMap::EntryAggregator and a result evaluation filter.

If the specified aggregator is an instance of coherence::util::InvocableMap::ParallelAwareAggregator, then a parallel-aware instance of the GroupAggregator will be created. Otherwise, the resulting GroupAggregator will not be parallel-aware and could be ill-suited for aggregations run against large partitioned caches.

vExtractor a ValueExtractor that will be used to split a set of InvocableMap entries into distinct groups
hAggregator an underlying EntryAggregator
vFilter an optional Filter object used to filter out results of individual group aggregation results

virtual ValueExtractor::View getExtractor (  )  const [virtual]

Obtain the underlying ValueExtractor.

the underlying ValueExtractor

virtual InvocableMap::EntryAggregator::Handle getAggregator (  )  [virtual]

Obtain the underlying EntryAggregator.

the underlying EntryAggregator

virtual InvocableMap::EntryAggregator::View getAggregator (  )  const [virtual]

Obtain the underlying EntryAggregator.

the underlying EntryAggregator

The documentation for this class was generated from the following file:
Copyright © 2000, 2010, Oracle and/or its affiliates. All rights reserved.