Oracle Coherence for C++ API
Release 3.7.0.0

E18684-01

coherence/util/aggregator/ParallelGroupAggregator.hpp

00001 /*
00002 * ParallelGroupAggregator.hpp
00003 *
00004 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
00005 *
00006 * Oracle is a registered trademarks of Oracle Corporation and/or its
00007 * affiliates.
00008 *
00009 * This software is the confidential and proprietary information of Oracle
00010 * Corporation. You shall not disclose such confidential and proprietary
00011 * information and shall use it only in accordance with the terms of the
00012 * license agreement you entered into with Oracle.
00013 *
00014 * This notice may not be removed or altered.
00015 */
00016 #ifndef COH_PARALLEL_GROUP_AGGREGATOR_HPP
00017 #define COH_PARALLEL_GROUP_AGGREGATOR_HPP
00018 
00019 #include "coherence/lang.ns"
00020 
00021 #include "coherence/util/aggregator/GroupAggregator.hpp"
00022 #include "coherence/util/InvocableMap.hpp"
00023 
00024 COH_OPEN_NAMESPACE3(coherence,util,aggregator)
00025 
00026 
00027 /**
00028 * The ParallelGroupAggregator provides an ability to split a subset of
00029 * entries in an InvocableMap into a collection of non-intersecting subsets
00030 * and then aggregate them separately and independently. The splitting
00031 * (grouping) is performed using the results of the underlying ValueExtractor
00032 * in such a way that two entries will belong to the same group if and only if
00033 * the result of the corresponding ValueExtractor#extract extract call
00034 * produces the same value or tuple (list of values). After the entries are
00035 * split into the groups, the underlying aggregator is applied separately to
00036 * each group. The result of the aggregation by the GroupAggregator is a Map
00037 * that has distinct values (or tuples) as keys and results of the individual
00038 * aggregation as values. Additionally, those results could be further reduced
00039 * using an optional Filter object.
00040 *
00041 * Informally speaking, this aggregator is analogous to the SQL "group by" and
00042 * "having" clauses. Note that the "having" Filter is applied independently on
00043 * each server against the partial aggregation results; this generally implies
00044 * that data affinity is required to ensure that all required data used to
00045 * generate a given result exists within a single cache partition.
00046 * In other words, the "group by" predicate should not span multiple
00047 * partitions if the "having" clause is used.
00048 *
00049 * The ParallelGroupAggregator is somewhat similar to the DistinctValues
00050 * aggregator, which returns back a list of distinct values (tuples) without
00051 * performing any additional aggregation work.
00052 *
00053 * Unlike many other concrete EntryAggregator implementations that are
00054 * constructed directly, instances of ParallelGroupAggregator should only be
00055 * created indirectly by using the factory method of GroupAggregator.
00056 *
00057 * @author djl  2008.05.16
00058 */
00059 
00060 class COH_EXPORT ParallelGroupAggregator
00061     : public class_spec<ParallelGroupAggregator,
00062         extends<GroupAggregator>,
00063         implements<InvocableMap::ParallelAwareAggregator> >
00064     {
00065     friend class factory<ParallelGroupAggregator>;
00066 
00067     // ----- constructors ---------------------------------------------------
00068 
00069     protected:
00070         /**
00071         * Default constructor (necessary for the PortableObject
00072         * interface).
00073         */
00074         ParallelGroupAggregator();
00075 
00076         /**
00077         * Create an instance of GroupAggregator based on a specified
00078         * extractor and anInvocableMap::EntryAggregator
00079         * and a result evaluation filter.
00080         * <br>
00081         * If the specified aggregator is an instance of
00082         * coherence::util::InvocableMap::ParallelAwareAggregator, then a
00083         * parallel-aware instance of the GroupAggregator will be created.
00084         * Otherwise, the resulting GroupAggregator will not be
00085         * parallel-aware and could be ill-suited for aggregations run
00086         * against large partitioned caches.
00087         *
00088         * @param vExtractor   a ValueExtractor that will be used to
00089         *                     split a set of InvocableMap entries into
00090         *                     distinct
00091         *                     groups
00092         * @param hAggregator  an underlying EntryAggregator
00093         * @param vFilter      an optional Filter object used to filter
00094         *                     out results of individual group
00095         *                     aggregation results
00096         */
00097         ParallelGroupAggregator(ValueExtractor::View vExtractor,
00098                 InvocableMap::ParallelAwareAggregator::Handle hAggregator,
00099                 Filter::View vFilter);
00100 
00101 
00102     // ----- InvocableMap::ParallelAwareAggregator interface ----------------
00103 
00104     public:
00105         /**
00106         * {@inheritDoc}
00107         */
00108         virtual InvocableMap::EntryAggregator::Handle
00109                 getParallelAggregator();
00110 
00111         /**
00112         * {@inheritDoc}
00113         */
00114         virtual Object::Holder aggregateResults(
00115                 Collection::View vCollResults);
00116     };
00117 
00118 COH_CLOSE_NAMESPACE3
00119 
00120 #endif // COH_PARALLEL_GROUP_AGGREGATOR_HPP
Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.