Oracle® Fusion Middleware C++ API Reference for Oracle Coherence
12c (12.2.1.4.0)

E90870-01

coherence/util/aggregator/AbstractAggregator.hpp

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