C++ Client API Reference for Oracle Coherence
14c (14.1.2.0.0)

F79659-03

coherence/util/aggregator/AbstractAggregator.hpp

00001 /*
00002  * Copyright (c) 2000, 2020, Oracle and/or its affiliates.
00003  *
00004  * Licensed under the Universal Permissive License v 1.0 as shown at
00005  * http://oss.oracle.com/licenses/upl.
00006  */
00007 #ifndef COH_ABSTRACT_AGGREGATOR_HPP
00008 #define COH_ABSTRACT_AGGREGATOR_HPP
00009 
00010 #include "coherence/lang.ns"
00011 
00012 #include "coherence/io/pof/PofReader.hpp"
00013 #include "coherence/io/pof/PofWriter.hpp"
00014 #include "coherence/io/pof/PortableObject.hpp"
00015 #include "coherence/util/InvocableMap.hpp"
00016 #include "coherence/util/ValueExtractor.hpp"
00017 
00018 COH_OPEN_NAMESPACE3(coherence,util,aggregator)
00019 
00020 using coherence::io::pof::PofReader;
00021 using coherence::io::pof::PofWriter;
00022 using coherence::io::pof::PortableObject;
00023 
00024 
00025 /**
00026 * Abstract base class implementation of
00027 * coherence::util::InvocableMap::EntryAggregator that supports
00028 * parallel aggregation.
00029 *
00030 * For aggregators which only run within the Coherence cluster
00031 * (most common case), the C++ init, process, finalizeResult, aggregate,
00032 * and aggregateResults methods can be left unimplemented.
00033 *
00034 * @author djl  2008.05.09
00035 */
00036 class COH_EXPORT AbstractAggregator
00037     : public abstract_spec<AbstractAggregator,
00038         extends<Object>,
00039         implements<PortableObject, InvocableMap::ParallelAwareAggregator> >
00040     {
00041     // ----- constructors ---------------------------------------------------
00042 
00043     protected:
00044         /**
00045         * @internal
00046         */
00047         AbstractAggregator();
00048 
00049         /**
00050         * @internal
00051         */
00052         AbstractAggregator(ValueExtractor::View vExtractor);
00053 
00054         /**
00055         * Construct an AbstractAggregator that will aggregate values 
00056         * extracted from a set of InvocableMap::Entry objects.
00057         *
00058         * @param vsMethod  the name of the method that could be invoked
00059         *                  via reflection and that returns values to 
00060         *                  aggregate; this parameter can also be a 
00061         *                  dot-delimited sequence of method names which 
00062         *                  would result in an aggregator based
00063         *                  on the ChainedExtractor that is based on an
00064         *                  array of corresponding ReflectionExtractor
00065         *                  objects
00066         *
00067         * @since Coherence 12.1.2
00068         */
00069         AbstractAggregator(String::View vsMethod);
00070 
00071     private:
00072         /**
00073         * Blocked copy constructor.
00074         */
00075         AbstractAggregator(const AbstractAggregator&);
00076 
00077 
00078     // ----- AbstractAggregator Interface  ----------------------------------
00079 
00080     protected:
00081         /**
00082         * Initialize the aggregation result.
00083         *
00084         * This implementation throws an UnsupportedOperationException.
00085         *
00086         * @param fFinal  true is passed if the aggregation process that is
00087         *                being initialized must produce a final aggregation
00088         *                result; this will only be false if a parallel
00089         *                approach is being used and the initial (partial)
00090         *                aggregation process is being initialized
00091         */
00092         virtual void init(bool fFinal);
00093 
00094         /**
00095         * Incorporate one aggregatable value into the result.
00096         *
00097         * If the <tt>fFinal</tt> parameter is true, the given object is a
00098         * partial result (returned by an individual parallel aggregator) that
00099         * should be incorporated into the final result; otherwise, the object
00100         * is a value extracted from an
00101         * coherence::util::InvocableMap::Entry.
00102         *
00103         * This implementation throws an UnsupportedOperationException.
00104         *
00105         * @param vO      the value to incorporate into the aggregated result
00106         * @param fFinal  true to indicate that the given object is a partial
00107         *                result returned by a parallel aggregator
00108         */
00109         virtual void process(Object::View vO, bool fFinal);
00110 
00111         /**
00112         * Obtain the result of the aggregation.
00113         *
00114         * If the <tt>fFinal</tt> parameter is true, the returned object must
00115         * be the final result of the aggregation; otherwise, the returned
00116         * object will be treated as a partial result that should be
00117         * incorporated into the final result.
00118         *
00119         * This implementation throws an UnsupportedOperationException.
00120         *
00121         * @param  fFinal  true to indicate that the final result of the
00122         *                 aggregation process should be returned; this will
00123         *                 only be false if a parallel approach is being used
00124         *
00125         * @return the result of the aggregation process
00126         */
00127         virtual Object::Holder finalizeResult(bool fFinal);
00128 
00129 
00130     // ----- InvocableMap::EntryAggregator interface ------------------------
00131 
00132     public:
00133         /**
00134         * {@inheritDoc}
00135         */
00136         virtual Object::Holder aggregate(Set::View vSetEntries);
00137 
00138 
00139     // ----- InvocableMap::ParallelAwareAggregator interface ----------------
00140 
00141     public:
00142         /**
00143         * {@inheritDoc}
00144         */
00145         virtual InvocableMap::EntryAggregator::Handle
00146                 getParallelAggregator();
00147 
00148         /**
00149         * {@inheritDoc}
00150         */
00151         virtual Object::Holder aggregateResults(
00152                 Collection::View vCollResults);
00153 
00154 
00155     // ----- PortableObject interface ---------------------------------------
00156 
00157     public:
00158         /**
00159         * {@inheritDoc}
00160         */
00161         virtual void readExternal(PofReader::Handle hIn);
00162 
00163         /**
00164         * {@inheritDoc}
00165         */
00166         virtual void writeExternal(PofWriter::Handle hOut) const;
00167 
00168 
00169     // ----- Object interface -----------------------------------------------
00170 
00171     public:
00172         /**
00173         * {@inheritDoc}
00174         */
00175         virtual bool equals(Object::View v) const;
00176 
00177         /**
00178         * {@inheritDoc}
00179         */
00180         virtual size32_t hashCode() const;
00181 
00182         /**
00183         * {@inheritDoc}
00184         */
00185         virtual TypedHandle<const String> toString() const;
00186 
00187 
00188     // ----- data member accessors ------------------------------------------
00189 
00190     public:
00191         /**
00192         * Determine the ValueExtractor whose values this aggregator is
00193         * aggregating.
00194         *
00195         * @return the ValueExtractor used by this aggregator
00196         */
00197         virtual ValueExtractor::View getValueExtractor() const;
00198 
00199 
00200     // ----- data members ---------------------------------------------------
00201 
00202     protected:
00203         /**
00204         * Set to true if this aggregator realizes that it is going to be used
00205         * in parallel.
00206         */
00207         bool m_fParallel;
00208 
00209         /**
00210         * The ValueExtractor that obtains the value to aggregate from the
00211         * value that is stored in the Map.
00212         */
00213         FinalView<ValueExtractor> f_vExtractor;
00214     };
00215 
00216 COH_CLOSE_NAMESPACE3
00217 
00218 #endif // COH_ABSTRACT_AGGREGATOR_HPP
Copyright © 2000, 2025, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.