Oracle® Fusion Middleware C++ API Reference for Oracle Coherence
14c (14.1.1.0.0)

F23533-01

coherence/util/SimpleQueryRecord.hpp

00001 /*
00002 * SimpleQueryRecord.hpp
00003 *
00004 * Copyright (c) 2000, 2020, 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     protected:
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 TypedHandle<const String> toString() 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                     friend class Step;
00378 
00379                     // ----- handle definitions (needed for nested classes)
00380 
00381                      public:
00382                          typedef this_spec::Handle Handle;
00383                          typedef this_spec::View   View;
00384                          typedef this_spec::Holder Holder;
00385 
00386                     // ----- constructors -------------------------------
00387 
00388                     protected:
00389                         /**
00390                         * Construct an IndexLookupRecord.
00391                         */
00392                         IndexLookupRecord();
00393 
00394                         /**
00395                         * Copy constructor for an IndexLookupRecord.
00396                         *
00397                         * @param vThat  the IndexLookupRecord to copy
00398                         */
00399                         IndexLookupRecord(
00400                                 QueryRecord::PartialResult::IndexLookupRecord::View
00401                                 vThat);
00402 
00403                         /**
00404                         * Construct an IndexLookupRecord.
00405                         *
00406                         * @param vsExtractor  the extractor description
00407                         * @param vsIndex      the index description
00408                         * @param fOrdered     indicates whether or not the
00409                         *                     associated index is ordered
00410                         */
00411                         IndexLookupRecord(String::View vsExtractor,
00412                                 String::View vsIndex,
00413                                 bool fOrdered,
00414                                 int64_t cBytes,
00415                                 int32_t cDistinctValues,
00416                                 String::View vsIndexDef);
00417 
00418                     // ----- IndexLookupRecord interface ----------------
00419 
00420                     public:
00421                         /**
00422                         * {@inheritDoc}
00423                         */
00424                         virtual String::View getExtractorDescription() const;
00425 
00426                         /**
00427                         * {@inheritDoc}
00428                         */
00429                         virtual String::View getIndexDescription() const;
00430 
00431                         /**
00432                         * {@inheritDoc}
00433                         */
00434                         virtual bool isOrdered() const;
00435 
00436                         /**
00437                         * Returns index memory usage in bytes.
00438                         *
00439                         * @return index memory usage in bytes; -1 if there is no index
00440                         */
00441                         int64_t getMemoryUsage() const;
00442 
00443                         /**
00444                         * Return index content map size.
00445                         *
00446                         * @return index content map size; -1 if there is no index
00447                         */
00448                         int32_t getSize() const;
00449 
00450                         /**
00451                         * Returns the index definition.
00452                         *
00453                         * @return the index definition; null if there is no index
00454                         */
00455                         virtual String::View getIndexDef() const;
00456 
00457                     // ----- PortableObject interface -------------------
00458 
00459                     public:
00460                         /**
00461                         * {@inheritDoc}
00462                         */
00463                         virtual void readExternal(PofReader::Handle hIn);
00464 
00465                         /**
00466                         * {@inheritDoc}
00467                         */
00468                         virtual void writeExternal(PofWriter::Handle hOut)
00469                                 const;
00470 
00471                     // ----- Object interface ---------------------------
00472 
00473                     public:
00474                         /**
00475                         * {@inheritDoc}
00476                         */
00477                         virtual bool equals(Object::View v) const;
00478 
00479                         /**
00480                         * {@inheritDoc}
00481                         */
00482                         virtual size32_t hashCode() const;
00483 
00484                     // ----- helper methods ------------------------------
00485 
00486                     protected:
00487                         /**
00488                         * Build an index description for this index.
00489                         *
00490                         * @return an index description for this index if there is an index definition;
00491                         *         null otherwise
00492                         */
00493                         virtual String::View buildIndexDescription();
00494 
00495                         /**
00496                         * Parses an index description into it's definition, footprint,
00497                         * and map size.
00498                         *
00499                         * @param vsIndex  the index description
00500                         */
00501                         virtual void parseIndexDescription(String::View vsIndex);
00502 
00503                     // ----- data members --------------------------------
00504 
00505                     protected:
00506                         /**
00507                         * The extractor description.
00508                         */
00509                         FinalView<String> f_vsExtractor;
00510 
00511                         /**
00512                         * The index description.
00513                         */
00514                         MemberView<String> m_vsIndex;
00515 
00516                         /**
00517                         * Indicates whether or not the associated index is
00518                         * ordered.
00519                         */
00520                         bool m_fOrdered;
00521 
00522                         /**
00523                         * The index footprint in bytes.
00524                         */
00525                         int64_t m_cBytes;
00526 
00527                         /**
00528                         * The index content map size.
00529                         */
00530                         int32_t m_cDistinctValues;
00531 
00532                         /**
00533                         * The index type description.
00534                         */
00535                         MemberView<String> m_vsIndexDef;
00536                     };
00537 
00538                 // ----- data members ----------------------------------------
00539 
00540                 protected:
00541                     /**
00542                     * The map of steps.
00543                     */
00544                     FinalHandle<List> f_hListSteps;
00545 
00546                     /**
00547                     * The partitions.
00548                     */
00549                     FinalHandle<PartitionSet> f_hPartMask;
00550             };
00551 
00552 
00553     // ----- data members ----------------------------------------------------
00554 
00555     protected:
00556         /**
00557         * This record type.
00558         */
00559         enum QueryRecorder::RecordType m_type;
00560 
00561         /**
00562         * The list of partial results.
00563         */
00564         FinalHandle<List> f_hListResults;
00565     };
00566 
00567 COH_CLOSE_NAMESPACE2
00568 
00569 #endif // COH_SIMPLE_QUERY_RECORD_HPP
Copyright © 2000, 2020, Oracle and/or its affiliates. All rights reserved.