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

E26041-01

coherence/util/SimpleQueryRecord.hpp

00001 /*
00002 * SimpleQueryRecord.hpp
00003 *
00004 * Copyright (c) 2000, 2013, 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_SIMPLE_QUERY_RECORD_HPP
00017 #define COH_SIMPLE_QUERY_RECORD_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/Collection.hpp"
00025 #include "coherence/util/List.hpp"
00026 #include "coherence/util/Map.hpp"
00027 #include "coherence/util/QueryRecord.hpp"
00028 #include "coherence/util/Set.hpp"
00029 
00030 COH_OPEN_NAMESPACE2(coherence,util)
00031 
00032 using coherence::io::pof::PofReader;
00033 using coherence::io::pof::PofWriter;
00034 using coherence::io::pof::PortableObject;
00035 
00036 
00037 /**
00038 * Simple QueryRecord implementation.
00039 *
00040 * @since Coherence 3.7.1
00041 *
00042 * @author tb 2011.05.26
00043 */
00044 class COH_EXPORT SimpleQueryRecord
00045     : public class_spec<SimpleQueryRecord,
00046         extends<Object>,
00047         implements<PortableObject, QueryRecord> >
00048     {
00049     friend class factory<SimpleQueryRecord>;
00050 
00051     // ----- Constructors ---------------------------------------------------
00052 
00053     public:
00054         /**
00055         * Construct a SimpleQueryRecord.
00056         */
00057         SimpleQueryRecord();
00058 
00059         /**
00060         * Construct a SimpleQueryRecord from the given collection of partial
00061         * results.
00062         *
00063         * @param type         the record type
00064         * @param vColResults  the collection of partial results
00065         */
00066         SimpleQueryRecord(QueryRecorder::RecordType type,
00067                 Collection::View vColResults);
00068 
00069 
00070     // ----- QueryRecord interface ------------------------------------------
00071 
00072     public:
00073         /**
00074         * {@inheritDoc}
00075         */
00076         virtual QueryRecorder::RecordType getType() const;
00077 
00078         /**
00079         * {@inheritDoc}
00080         */
00081         virtual List::View getResults() const;
00082 
00083 
00084     // ----- helper methods -------------------------------------------------
00085 
00086     public:
00087         /**
00088         * Merge the partial results from the associated record.  Matching
00089         * partial results are merged into a single result for the report.
00090         *
00091         * @param vColResults  the collection of partial results
00092         */
00093         virtual void mergeResults(Collection::View vColResults);
00094 
00095 
00096     // ----- PortableObject interface ---------------------------------------
00097 
00098     public:
00099         /**
00100         * {@inheritDoc}
00101         */
00102         virtual void readExternal(PofReader::Handle hIn);
00103 
00104         /**
00105         * {@inheritDoc}
00106         */
00107         virtual void writeExternal(PofWriter::Handle hOut) const;
00108 
00109 
00110     // ----- Object interface -----------------------------------------------
00111 
00112     public:
00113         /**
00114         * {@inheritDoc}
00115         */
00116         virtual void toStream(std::ostream& out) const;
00117 
00118 
00119     // ----- inner class: PartialResult -------------------------------------
00120 
00121     public:
00122         /**
00123         * Simple QueryRecord::PartialResult implementation.
00124         */
00125         class COH_EXPORT PartialResult
00126             : public class_spec<PartialResult,
00127                 extends<Object>,
00128                 implements<PortableObject, QueryRecord::PartialResult> >
00129             {
00130             friend class factory<PartialResult>;
00131 
00132             // ----- handle definitions (needed for nested classes) -----
00133 
00134              public:
00135                  typedef this_spec::Handle Handle;
00136                  typedef this_spec::View   View;
00137                  typedef this_spec::Holder Holder;
00138 
00139             // ----- constructors ---------------------------------------
00140 
00141             protected:
00142                 /**
00143                 * Construct a PartialResult
00144                 */
00145                 PartialResult();
00146 
00147                 /**
00148                 * Copy constructor for a Result.
00149                 *
00150                 * @param vThat  the result to copy
00151                 */
00152                 PartialResult(QueryRecord::PartialResult::View vThat);
00153 
00154             // ----- PartialResult interface ----------------------------
00155 
00156             public:
00157 
00158                 /**
00159                 * {@inheritDoc}
00160                 */
00161                 virtual List::View getSteps() const;
00162 
00163                 /**
00164                 * {@inheritDoc}
00165                 */
00166                 virtual PartitionSet::Handle getPartitions();
00167 
00168                 /**
00169                 * {@inheritDoc}
00170                 */
00171                 virtual PartitionSet::View getPartitions() const;
00172 
00173 
00174             // ----- helper methods -------------------------------------
00175 
00176             public:
00177                 /**
00178                 * Merge the given result with this one.
00179                 *
00180                 * @param vResult  the result to merge
00181                 */
00182                 virtual void merge(QueryRecord::PartialResult::View vResult);
00183 
00184                 /**
00185                 * Determine whether or not the given result is capable of
00186                 * being placed in one-to-one correspondence with this result.
00187                 * Results are matching if their owned lists of steps have the
00188                 * same size, and all pairs of steps in the two lists are
00189                 * matching.
00190                 *
00191                 * @param vResult  the result to be checked
00192                 *
00193                 * @return true iff the given result matches with this result
00194                 */
00195                 virtual bool isMatching(
00196                         QueryRecord::PartialResult::View vResult) const;
00197 
00198             // ----- PortableObject interface ---------------------------
00199 
00200             public:
00201                 /**
00202                 * {@inheritDoc}
00203                 */
00204                 virtual void readExternal(PofReader::Handle hIn);
00205 
00206                 /**
00207                 * {@inheritDoc}
00208                 */
00209                 virtual void writeExternal(PofWriter::Handle hOut) const;
00210 
00211                 // ----- inner class: Step ------------------------------
00212 
00213                 /**
00214                 * Simple QueryRecord::PartialResult::Step implementation.
00215                 */
00216                 class COH_EXPORT Step
00217                     : public class_spec<Step,
00218                         extends<Object>,
00219                         implements<PortableObject,
00220                                 QueryRecord::PartialResult::Step> >
00221                     {
00222                     friend class factory<Step>;
00223 
00224                     // ----- handle definitions (needed for nested classes)
00225 
00226                      public:
00227                          typedef this_spec::Handle Handle;
00228                          typedef this_spec::View   View;
00229                          typedef this_spec::Holder Holder;
00230 
00231                     // ----- constructors -------------------------------
00232 
00233                     protected:
00234                         /**
00235                         * Constructor for a Step.
00236                         */
00237                         Step();
00238 
00239                         /**
00240                         * Copy constructor for a Step.
00241                         *
00242                         * @param vThat  the step to copy
00243                         */
00244                         Step(QueryRecord::PartialResult::Step::View vThat);
00245 
00246                     // ----- Step interface -----------------------------
00247 
00248                     public:
00249                         /**
00250                         * {@inheritDoc}
00251                         */
00252                         virtual String::View getFilterDescription() const;
00253 
00254                         /**
00255                         * {@inheritDoc}
00256                         */
00257                         virtual Set::View getIndexLookupRecords() const;
00258 
00259                         /**
00260                         * {@inheritDoc}
00261                         */
00262                         virtual size32_t getEfficiency() const;
00263 
00264                         /**
00265                         * {@inheritDoc}
00266                         */
00267                         virtual size32_t getPreFilterKeySetSize() const;
00268 
00269                         /**
00270                         * {@inheritDoc}
00271                         */
00272                         virtual size32_t getPostFilterKeySetSize() const;
00273 
00274                         /**
00275                         * {@inheritDoc}
00276                         */
00277                         virtual int64_t getDuration() const;
00278 
00279                         /**
00280                         * {@inheritDoc}
00281                         */
00282                         virtual List::View getSteps() const;
00283 
00284                     // ----- helper methods -----------------------------
00285 
00286                     public:
00287                         /**
00288                         * Merge the given step with this one.  This method
00289                         * assumes that the given step matches with this one.
00290                         *
00291                         * @param vStep  the step to merge
00292                         */
00293                         void merge(QueryRecord::PartialResult::Step::View
00294                                 vStep);
00295 
00296                         /**
00297                         * Determine whether or not the given step is capable
00298                         * of being placed in one-to-one correspondence with
00299                         * this step.  Steps are defined to be matching if both
00300                         * steps have equivalent name, index lookup records and
00301                         * owned lists of sub-steps.
00302                         *
00303                         * @param vStep  the step to check
00304                         *
00305                         * @return true iff the given step matches with this
00306                         *         step
00307                         */
00308                         bool isMatching(QueryRecord::PartialResult::Step::View
00309                                 vStep) const;
00310 
00311                     // ----- PortableObject interface -------------------
00312 
00313                     public:
00314                         /**
00315                         * {@inheritDoc}
00316                         */
00317                         virtual void readExternal(PofReader::Handle hIn);
00318 
00319                         /**
00320                         * {@inheritDoc}
00321                         */
00322                         virtual void writeExternal(PofWriter::Handle hOut)
00323                                 const;
00324 
00325                     // ----- data members -------------------------------
00326 
00327                     protected:
00328                         /**
00329                         * The filter description.
00330                         */
00331                         FinalView<String> f_vsFilter;
00332 
00333                         /**
00334                         * The estimated cost.
00335                         */
00336                         size32_t m_nEfficiency;
00337 
00338                         /**
00339                         * The pre-execution key set size.
00340                         */
00341                         size32_t m_nSizeIn;
00342 
00343                         /**
00344                         * The post-execution key set size.
00345                         */
00346                         size32_t m_nSizeOut;
00347 
00348                         /**
00349                         * The execution time in milliseconds.
00350                         */
00351                         int64_t m_cMillis;
00352 
00353                         /**
00354                         * The set of index lookup records.
00355                         */
00356                         FinalHandle<Set> f_hSetIndexLookupRecords;
00357 
00358                         /**
00359                         * The list of child steps.
00360                         */
00361                         FinalHandle<List> f_hListSubSteps;
00362                     };
00363 
00364                 // ----- inner class: IndexLookupRecord -----------------
00365 
00366                 /**
00367                 * Simple QueryRecord::PartialResult::IndexLookupRecord
00368                 * implementation.
00369                 */
00370                 class COH_EXPORT IndexLookupRecord
00371                     : public class_spec<IndexLookupRecord,
00372                         extends<Object>,
00373                         implements<PortableObject,
00374                                 QueryRecord::PartialResult::IndexLookupRecord> >
00375                     {
00376                     friend class factory<IndexLookupRecord>;
00377 
00378                     // ----- handle definitions (needed for nested classes)
00379 
00380                      public:
00381                          typedef this_spec::Handle Handle;
00382                          typedef this_spec::View   View;
00383                          typedef this_spec::Holder Holder;
00384 
00385                     // ----- constructors -------------------------------
00386 
00387                     protected:
00388                         /**
00389                         * Construct an IndexLookupRecord.
00390                         */
00391                         IndexLookupRecord();
00392 
00393                         /**
00394                         * Copy constructor for an IndexLookupRecord.
00395                         *
00396                         * @param vThat  the IndexLookupRecord to copy
00397                         */
00398                         IndexLookupRecord(
00399                                 QueryRecord::PartialResult::IndexLookupRecord::View
00400                                 vThat);
00401 
00402                         /**
00403                         * Construct an IndexLookupRecord.
00404                         *
00405                         * @param vsExtractor  the extractor description
00406                         * @param vsIndex      the index description
00407                         * @param fOrdered     indicates whether or not the
00408                         *                     associated index is ordered
00409                         */
00410                         IndexLookupRecord(String::View vsExtractor,
00411                                 String::View vsIndex,
00412                                 bool fOrdered);
00413 
00414                     // ----- IndexLookupRecord interface ----------------
00415 
00416                     public:
00417                         /**
00418                         * {@inheritDoc}
00419                         */
00420                         virtual String::View getExtractorDescription() const;
00421 
00422                         /**
00423                         * {@inheritDoc}
00424                         */
00425                         virtual String::View getIndexDescription() const;
00426 
00427                         /**
00428                         * {@inheritDoc}
00429                         */
00430                         virtual bool isOrdered() const;
00431 
00432                     // ----- PortableObject interface -------------------
00433 
00434                     public:
00435                         /**
00436                         * {@inheritDoc}
00437                         */
00438                         virtual void readExternal(PofReader::Handle hIn);
00439 
00440                         /**
00441                         * {@inheritDoc}
00442                         */
00443                         virtual void writeExternal(PofWriter::Handle hOut)
00444                                 const;
00445 
00446                     // ----- Object interface ---------------------------
00447 
00448                     public:
00449                         /**
00450                         * {@inheritDoc}
00451                         */
00452                         virtual bool equals(Object::View v) const;
00453 
00454                         /**
00455                         * {@inheritDoc}
00456                         */
00457                         virtual size32_t hashCode() const;
00458 
00459                     // ----- data members --------------------------------
00460 
00461                     protected:
00462                         /**
00463                         * The extractor description.
00464                         */
00465                         FinalView<String> f_vsExtractor;
00466 
00467                         /**
00468                         * The index description.
00469                         */
00470                         FinalView<String> f_vsIndex;
00471 
00472                         /**
00473                         * Indicates whether or not the associated index is
00474                         * ordered.
00475                         */
00476                         bool m_fOrdered;
00477                     };
00478 
00479             // ----- data members ----------------------------------------
00480 
00481             protected:
00482                     /**
00483                     * The map of steps.
00484                     */
00485                     FinalHandle<List> f_hListSteps;
00486 
00487                     /**
00488                     * The partitions.
00489                     */
00490                     FinalHandle<PartitionSet> f_hPartMask;
00491             };
00492 
00493 
00494     // ----- data members ----------------------------------------------------
00495 
00496     protected:
00497         /**
00498         * This record type.
00499         */
00500         enum QueryRecorder::RecordType m_type;
00501 
00502         /**
00503         * The list of partial results.
00504         */
00505         FinalHandle<List> f_hListResults;
00506     };
00507 
00508 COH_CLOSE_NAMESPACE2
00509 
00510 #endif // COH_SIMPLE_QUERY_RECORD_HPP
Copyright © 2000, 2013, Oracle and/or its affiliates. All rights reserved.