00001 /* 00002 * QueryRecord.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_QUERY_RECORD_HPP 00017 #define COH_QUERY_RECORD_HPP 00018 00019 #include "coherence/lang.ns" 00020 00021 #include "coherence/net/partition/PartitionSet.hpp" 00022 #include "coherence/util/List.hpp" 00023 #include "coherence/util/Map.hpp" 00024 #include "coherence/util/Set.hpp" 00025 #include "coherence/util/aggregator/QueryRecorder.hpp" 00026 00027 COH_OPEN_NAMESPACE2(coherence,util) 00028 00029 using coherence::net::partition::PartitionSet; 00030 using coherence::util::aggregator::QueryRecorder; 00031 00032 /** 00033 * The QueryRecord object carries a record of the estimated or actual 00034 * execution cost for a query operation. 00035 * 00036 * @since Coherence 3.7.1 00037 * 00038 * @author tb 2011.05.26 00039 */ 00040 class COH_EXPORT QueryRecord 00041 : public interface_spec<QueryRecord> 00042 { 00043 // ----- QueryRecord interface ------------------------------------------ 00044 00045 public: 00046 /** 00047 * Get the {@link RecordType type} that was specified when this query 00048 * record was created. 00049 * 00050 * @return the record type 00051 */ 00052 virtual QueryRecorder::RecordType getType() const = 0; 00053 00054 /** 00055 * Get the list of partial results for this query record. 00056 * 00057 * @return the list of results 00058 */ 00059 virtual List::View getResults() const = 0; 00060 00061 // ----- inner interface: PartialResult ------------------------- 00062 00063 /** 00064 * A QueryPlan.PartialResult is a partial query record that contains 00065 * recorded costs for a query operation. Partial results are collected 00066 * in a query record by a {@link QueryRecorder}. 00067 */ 00068 class COH_EXPORT PartialResult 00069 : public interface_spec<PartialResult> 00070 { 00071 public: 00072 00073 /** 00074 * Get the list of steps for this query record partial result in the 00075 * order that they occurred. 00076 * 00077 * @return the list of steps 00078 */ 00079 virtual List::View getSteps() const = 0; 00080 00081 /** 00082 * Get the set of partitions associated with this partial result. 00083 * 00084 * @return the partition set 00085 */ 00086 virtual PartitionSet::Handle getPartitions() = 0; 00087 00088 /** 00089 * Get the set of partitions associated with this partial result. 00090 * 00091 * @return the partition set 00092 */ 00093 virtual PartitionSet::View getPartitions() const = 0; 00094 00095 // -----inner interface: Step --------------------------- 00096 00097 /** 00098 * A QueryPlan.Step carries the recorded cost of evaluating a filter 00099 * as part of a query operation. This cost may be the estimated or 00100 * actual execution cost depending on the 00101 * {@link QueryRecorder.RecordType type} of the 00102 * {@link QueryRecorder recorder} in use when the step was created. 00103 */ 00104 class COH_EXPORT Step 00105 : public interface_spec<Step> 00106 { 00107 public: 00108 00109 /** 00110 * Get a description of the filter that was associated with this 00111 * step during its creation. 00112 * 00113 * @return the description of the filter 00114 */ 00115 virtual String::View getFilterDescription() const = 0; 00116 00117 /** 00118 * Get the recorded information about the index lookups performed 00119 * during filter evaluation as part of a query record. 00120 * 00121 * @return a set of {@link IndexLookupRecord} 00122 */ 00123 virtual Set::View getIndexLookupRecords() const = 0; 00124 00125 /** 00126 * Get the calculated cost of applying the filter as defined by 00127 * {@link IndexAwareFilter#calculateEffectiveness(Map, Set) 00128 * calculateEffectiveness} 00129 * 00130 * @return an effectiveness estimate of how well the associated 00131 * filter can use any applicable index 00132 */ 00133 virtual size32_t getEfficiency() const = 0; 00134 00135 /** 00136 * Get the size of the key set prior to evaluating the filter or 00137 * applying an index. This value can be used together with 00138 * {@link #getPostFilterKeySetSize()} to calculate an actual 00139 * effectiveness (reduction of the key set) for this filter step. 00140 * 00141 * @return the size of the key set prior to evaluating the filter 00142 * or applying an index 00143 */ 00144 virtual size32_t getPreFilterKeySetSize() const = 0; 00145 00146 /** 00147 * Get the size of the key set remaining after evaluating the 00148 * filter or applying an index. This value can be used together 00149 * with {@link #getPreFilterKeySetSize()} to calculate an actual 00150 * effectiveness (reduction of the key set) for this filter step. 00151 * 00152 * @return the size of the key set after evaluating the filter 00153 * or applying an index 00154 */ 00155 virtual size32_t getPostFilterKeySetSize() const = 0; 00156 00157 /** 00158 * Get the amount of time (in ms) spent evaluating the filter or 00159 * applying an index for this query plan step. 00160 * 00161 * @return the number of milliseconds spent evaluating the filter 00162 */ 00163 virtual int64_t getDuration() const = 0; 00164 00165 /** 00166 * Return inner nested steps, may be null if not nested. 00167 * 00168 * @return the inner nested steps in the order they are applied 00169 */ 00170 virtual List::View getSteps() const = 0; 00171 }; 00172 00173 // ----- inner interface: IndexLookupRecord ------------- 00174 00175 /** 00176 * An IndexLookupRecord holds the recorded information about an index 00177 * lookup performed during filter evaluation as part of a query 00178 * record. 00179 * 00180 * An IndexLookupRecord is created each time that 00181 * {@link RecordableStep#recordExtractor(ValueExtractor)} is called on 00182 * a query record step. 00183 */ 00184 class COH_EXPORT IndexLookupRecord 00185 : public interface_spec<IndexLookupRecord> 00186 { 00187 public: 00188 /** 00189 * Get a description of the extractor that was used for the index 00190 * lookup. 00191 * 00192 * @return the extractor description 00193 */ 00194 virtual String::View getExtractorDescription() const = 0; 00195 00196 /** 00197 * Get a description of the associated index. 00198 * 00199 * @return the index description; null if no index was found 00200 * for the associated extractor 00201 */ 00202 virtual String::View getIndexDescription() const = 0; 00203 00204 /** 00205 * Indicates whether or not the associated index is ordered. 00206 * 00207 * @return true if the associated index is ordered; false if the 00208 * index is not ordered or if no index was found for the 00209 * associated extractor 00210 */ 00211 virtual bool isOrdered() const = 0; 00212 }; 00213 }; 00214 }; 00215 00216 COH_CLOSE_NAMESPACE2 00217 00218 #endif // COH_QUERY_RECORD_HPP