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

E80355-01

coherence/util/aggregator/ReducerAggregator.hpp

00001 /*
00002 * ReducerAggregator.hpp
00003 *
00004 * Copyright (c) 2000, 2017, 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_REDUCER_AGGREGATOR_HPP
00017 #define COH_REDUCER_AGGREGATOR_HPP
00018 
00019 #include "coherence/lang.ns"
00020 
00021 #include "coherence/util/aggregator/AbstractAggregator.hpp"
00022 #include "coherence/util/ValueExtractor.hpp"
00023 
00024 COH_OPEN_NAMESPACE3(coherence,util,aggregator)
00025 
00026 
00027 /**
00028 * The ReducerAggregator is used to implement functionality similar to
00029 * <tt>CacheMap::getAll(Collection)</tt> API.  Instead of returning the complete
00030 * set of values, it will return a portion of value attributes based on the
00031 * provided <tt>ValueExtractor</tt>.
00032 *
00033 * This aggregator could be used in combination with
00034 * <tt>coherence.util.extractor.MultiExtractor</tt> allowing one to collect
00035 * tuples that are a subset of the attributes of each object stored in the cache.
00036 *
00037 * @author par 04.25.13
00038 */
00039 class COH_EXPORT ReducerAggregator
00040     : public class_spec<ReducerAggregator,
00041         extends<AbstractAggregator> >
00042     {
00043     friend class factory<ReducerAggregator>;
00044 
00045 
00046     // ----- constructors ---------------------------------------------------
00047 
00048     protected:
00049         /**
00050         * Default constructor.
00051         */
00052         ReducerAggregator();
00053 
00054         /**
00055         * Construct a ReducerAggregator based on the specified extractor.
00056         *
00057         * @param vExtractor  the extractor that is used to extract the portion
00058         *                    of the cached value
00059         */
00060         ReducerAggregator(ValueExtractor::View vExtractor);
00061 
00062         /**
00063          * Construct a ReducerAggregator based on the specified method name.
00064          *
00065          * @param vsMethod  the name of the method that is used to extract the
00066          *                  portion of the cached value
00067          */
00068         ReducerAggregator(String::View vsMethod);
00069 
00070     private:
00071         /**
00072         * Blocked copy constructor.
00073         */
00074         ReducerAggregator(const ReducerAggregator&);
00075 
00076 
00077     // ----- AbstractAggregator methods -------------------------------------
00078 
00079     protected:
00080         /**
00081         * {@inheritDoc}
00082         */
00083         virtual void init(bool fFinal);
00084 
00085         /**
00086         * {@inheritDoc}
00087         */
00088         virtual void process(Object::View vO, bool fFinal);
00089 
00090         /**
00091         * {@inheritDoc}
00092         */
00093         virtual Object::Holder finalizeResult(bool fFinal);
00094 
00095 
00096     // ----- internal helpers -----------------------------------------------
00097 
00098     protected:
00099         /**
00100         * Return a map that can be used to store reduced values, creating it if
00101         * one has not already been created.
00102         *
00103         * @return a set that can be used to store distinct values
00104         */
00105         virtual Map::Handle ensureMap();
00106 
00107 
00108     // ----- data members ---------------------------------------------------
00109 
00110     private:
00111         /**
00112         * The resulting map of reduced values.
00113         */
00114         MemberHandle<Map> m_hMap;
00115     };
00116 
00117 COH_CLOSE_NAMESPACE3
00118 
00119 #endif //COH_REDUCER_AGGREGATOR_HPP
Copyright © 2000, 2017, Oracle and/or its affiliates. All rights reserved.