Oracle Coherence for C++ API
Release 3.6.0.0

E15728-01

coherence/util/aggregator/DistinctValues.hpp

00001 /*
00002 * DistinctValues.hpp
00003 *
00004 * Copyright (c) 2000, 2010, 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_DISTINCT_VALUES_HPP
00017 #define COH_DISTINCT_VALUES_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 * Return the set of unique values extracted from a set of entries in a Map.
00029 * If the set of entries is empty, an empty set is returned.
00030 *
00031 * This aggregator could be used in combination with
00032 * coherence::util::extractor::MultiExtractor allowing
00033 * to collect all unique combinations (tuples) of a given set of attributes.
00034 *
00035 * The DistinctValues aggregator covers a simple case of a more generic
00036 * aggregation pattern implemented by the GroupAggregator, which in
00037 * addition to collecting all distinct values or tuples, runs an aggregation
00038 * against each distinct entry set (group).
00039 *
00040 * @author djl  2008.05.12
00041 */
00042 class COH_EXPORT DistinctValues
00043     : public class_spec<DistinctValues,
00044         extends<AbstractAggregator> >
00045     {
00046     friend class factory<DistinctValues>;
00047 
00048     // ----- constructors ---------------------------------------------------
00049 
00050     protected:
00051         /**
00052         * Default constructor (necessary for the PortableObject interface).
00053         */
00054         DistinctValues();
00055 
00056         /**
00057         * Construct a DistinceValues aggregator.
00058         *
00059         * @param vExtractor  the extractor that provides a value in the form
00060         *                    of any object
00061         */
00062         DistinctValues(ValueExtractor::View vExtractor);
00063 
00064 
00065     // ----- AbstractAggregator Interface  ----------------------------------
00066 
00067     protected:
00068         /**
00069         * {@inheritDoc}
00070         */
00071         virtual void init(bool fFinal);
00072 
00073         /**
00074         * {@inheritDoc}
00075         */
00076         virtual void process(Object::View vO, bool fFinal);
00077 
00078         /**
00079         * {@inheritDoc}
00080         */
00081         virtual Object::Holder finalizeResult(bool fFinal);
00082 
00083 
00084     // ----- internal helpers -----------------------------------------------
00085 
00086     protected:
00087         /**
00088         * Return a set that can be used to store distinct values, creating it
00089         * if one has not already been created.
00090         *
00091         * @return a set that can be used to store distinct values
00092         */
00093         virtual Set::Handle ensureSet();
00094 
00095 
00096     // ----- data members ---------------------------------------------------
00097 
00098     protected:
00099         /**
00100         * The resulting set of distinct values.
00101         */
00102         MemberHandle<Set> m_hSet;
00103     };
00104 
00105 COH_CLOSE_NAMESPACE3
00106 
00107 #endif // COH_DISTINCT_VALUES_HPP
Copyright © 2000, 2010, Oracle and/or its affiliates. All rights reserved.