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

E90870-01

coherence/util/filter/ArrayFilter.hpp

00001 /*
00002 * ArrayFilter.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_ARRAY_FILTER_HPP
00017 #define COH_ARRAY_FILTER_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/filter/EntryFilter.hpp"
00025 #include "coherence/util/filter/IndexAwareFilter.hpp"
00026 
00027 COH_OPEN_NAMESPACE3(coherence,util,filter)
00028 
00029 using coherence::io::pof::PofReader;
00030 using coherence::io::pof::PofWriter;
00031 using coherence::io::pof::PortableObject;
00032 
00033 
00034 /**
00035 * Filter which is a logical operator of a filter array.
00036 *
00037 * @author djl  2008.03.23
00038 */
00039 class COH_EXPORT ArrayFilter
00040     : public abstract_spec<ArrayFilter,
00041         extends<Object>,
00042         implements<IndexAwareFilter, PortableObject> >
00043     {
00044     // ----- constructors ---------------------------------------------------
00045 
00046     protected:
00047         /**
00048         * Default constructor (necessary for the PortableObject interface).
00049         */
00050         ArrayFilter();
00051 
00052         /**
00053         * Construct a logical filter that applies a binary operator to a
00054         * filter array. The result is defined as:
00055         *   vaFilter[0] &lt;op&gt; vaFilter[1] ... &lt;op&gt; vaFilter[n]
00056         *
00057         * @param vaFilter  the filter array
00058         */
00059         ArrayFilter(ObjectArray::View vaFilter);
00060 
00061     private:
00062         /**
00063         * Blocked copy constructor.
00064         */
00065         ArrayFilter(const ArrayFilter&);
00066 
00067 
00068     // ----- PortableObject interface ---------------------------------------
00069 
00070      public:
00071         /**
00072         * {@inheritDoc}
00073         */
00074         virtual void readExternal(PofReader::Handle hIn);
00075 
00076         /**
00077         * {@inheritDoc}
00078         */
00079         virtual void writeExternal(PofWriter::Handle hOut) const;
00080 
00081 
00082     // ----- Object interface -----------------------------------------------
00083 
00084     public:
00085         /**
00086         * Compare the ArrayFilter with another object to determine
00087         * equality. Two ArrayFilter objects are considered equal
00088         * iff they belong to the same class and their underlying Filter
00089         * arrays are deep-equal.
00090         *
00091         * @return true iff this ArrayFilter and the passed object
00092         *         are equivalent
00093         */
00094         virtual bool equals(Object::View v) const;
00095 
00096         /**
00097         * {@inheritDoc}
00098         */
00099         virtual size32_t hashCode() const;
00100 
00101         /**
00102         * {@inheritDoc}
00103         */
00104         virtual TypedHandle<const String> toString() const;
00105 
00106 
00107     // ----- data member accessors ------------------------------------------
00108 
00109     public:
00110         /**
00111         * Obtain the Filter array.
00112         *
00113         * @return the Filter array
00114         */
00115         virtual ObjectArray::View getFilters() const;
00116 
00117         /**
00118         * Ensure that the order of underlying filters is preserved by the
00119         * applyIndex() and evaluateEntry() implementations.
00120         *
00121         * @since 12.2.1
00122         */
00123         virtual void honorOrder();
00124 
00125 
00126     // ----- internal helpers -----------------------------------------------
00127 
00128     protected:
00129         /**
00130         * Apply the specified IndexAwareFilter to the specified keySet.
00131         *
00132         * @param vFilter      the IndexAwareFilter to apply an index to
00133         * @param vMapIndexes  the available MapIndex objects keyed by
00134         *                     the related ValueExtractor; read-only
00135         * @param hSetKeys     the mutable set of keys that remain to be
00136         *                     filtered
00137         *
00138         * @return a Filter object that can be used to process the remaining
00139         *         keys, or null if no additional filter processing is
00140         *         necessary
00141         */
00142         virtual Filter::View applyFilter(IndexAwareFilter::View vFilter,
00143                 Map::View vMapIndexes, Set::Handle hSetKeys) const;
00144 
00145         /**
00146         * Sort all the participating filters according to their effectiveness.
00147         *
00148         * @param vMapIndexes  the available MapIndex objects keyed by
00149         *                     the related ValueExtractor; read-only
00150         * @param vSetKeys     the set of keys that will be filtered; read-only
00151         *
00152         * @since 12.2.1
00153         */
00154         virtual void optimizeFilterOrder(Map::View vMapIndexes,
00155                 Set::View vSetKeys) const;
00156 
00157 
00158     // ----- inner class: WeightedFilter ------------------------------------
00159 
00160     public:
00161         /**
00162         * A thin wrapper around a Filter allowing for sorting the filters
00163         * according to their effectiveness.
00164         *
00165         * @author tb  2009.02.09
00166         */
00167         class COH_EXPORT WeightedFilter
00168             : public class_spec<WeightedFilter,
00169                     extends<Object>,
00170                     implements<Comparable> >
00171             {
00172             friend class factory<WeightedFilter>;
00173 
00174             // ----- constructors ---------------------------------------
00175 
00176             protected:
00177                 /**
00178                 * Construct the WeightedFilter.
00179                 *
00180                 * @param vFilter  the wrapped filter
00181                 * @param nEffect  the filter's effectiveness
00182                 */
00183                 WeightedFilter(Filter::View vFilter, int32_t nEffect);
00184 
00185             // ----- Comparable interface -------------------------------
00186 
00187             public:
00188                 /**
00189                 * Compares this WeightedFilter with the specified
00190                 * WeightedFilter for order.  Returns a negative integer, zero,
00191                 * or a positive integer as this WeightedFilter's effectiveness
00192                 * is less than, equal to, or greater than the effectiveness of
00193                 * the specified WeightedFilter object.
00194                 *
00195                 * @param v  the Object to be compared
00196                 *
00197                 * @return a negative integer, zero, or a positive integer as
00198                 *         this object is less than, equal to, or greater than
00199                 *         the specified object
00200                 *
00201                 * @throws ClassCastException if the specified object's type
00202                 *         prevents it from being compared to this
00203                 *         WeightedFilter
00204                 */
00205                 int32_t compareTo(Object::View v) const;
00206 
00207             // ----- accessors ------------------------------------------
00208 
00209             public:
00210                 /**
00211                 * Get the wrapped filter.
00212                 *
00213                 * @return the wrapped filter
00214                 */
00215                 Filter::View getFilter() const;
00216 
00217             // ----- data members ---------------------------------------
00218 
00219             protected:
00220                 /**
00221                 * The wrapped filter.
00222                 */
00223                 FinalView<Filter> f_vFilter;
00224 
00225                 /**
00226                 * The effectiveness of the wrapped filter.
00227                 */
00228                 int32_t m_nEffect;
00229             };
00230 
00231 
00232     // ----- data members ---------------------------------------------------
00233 
00234     protected:
00235         /**
00236         * The Filter array.
00237         */
00238         mutable MemberView<ObjectArray> m_vaFilter;
00239 
00240         /**
00241         * Flag indicating whether or not the filter order should be preserved.
00242         *
00243         * @since Coherence 12.2.1
00244         */
00245         mutable bool m_fPreserveOrder;
00246     };
00247 
00248 COH_CLOSE_NAMESPACE3
00249 
00250 #endif // COH_EXTRACTOR_FILTER_HPP
Copyright © 2000, 2019, Oracle and/or its affiliates. All rights reserved.