1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
1 |
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
|
2 |
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
|
|
3 |
*
|
|
1999.6.1
by kalebral at gmail
update Copyright strings to a more common format to help with creating the master debian copyright file |
4 |
* Copyright (C) 2008-2009 Sun Microsystems, Inc.
|
1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify
|
|
7 |
* it under the terms of the GNU General Public License as published by
|
|
8 |
* the Free Software Foundation; version 2 of the License.
|
|
9 |
*
|
|
10 |
* This program is distributed in the hope that it will be useful,
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* GNU General Public License for more details.
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License
|
|
16 |
* along with this program; if not, write to the Free Software
|
|
17 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
18 |
*/
|
|
19 |
||
2234
by Brian Aker
Mass removal of ifdef/endif in favor of pragma once. |
20 |
#pragma once
|
1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
21 |
|
2173.2.1
by Monty Taylor
Fixes incorrect usage of include |
22 |
#include <drizzled/optimizer/range.h> |
1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
23 |
|
1237.13.29
by Padraig O'Sullivan
Replaced a DYNAMIC_ARRAY with std::vector in the range optimizer. |
24 |
#include <vector> |
25 |
||
1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
26 |
namespace drizzled |
27 |
{
|
|
28 |
||
29 |
namespace optimizer |
|
30 |
{
|
|
31 |
||
32 |
/**
|
|
33 |
Index scan for GROUP-BY queries with MIN/MAX aggregate functions.
|
|
34 |
||
35 |
This class provides a specialized index access method for GROUP-BY queries
|
|
36 |
of the forms:
|
|
37 |
||
38 |
SELECT A_1,...,A_k, [B_1,...,B_m], [MIN(C)], [MAX(C)]
|
|
39 |
FROM T
|
|
40 |
WHERE [RNG(A_1,...,A_p ; where p <= k)]
|
|
41 |
[AND EQ(B_1,...,B_m)]
|
|
42 |
[AND PC(C)]
|
|
43 |
[AND PA(A_i1,...,A_iq)]
|
|
44 |
GROUP BY A_1,...,A_k;
|
|
45 |
||
46 |
or
|
|
47 |
||
48 |
SELECT DISTINCT A_i1,...,A_ik
|
|
49 |
FROM T
|
|
50 |
WHERE [RNG(A_1,...,A_p ; where p <= k)]
|
|
51 |
[AND PA(A_i1,...,A_iq)];
|
|
52 |
||
53 |
where all selected fields are parts of the same index.
|
|
54 |
The class of queries that can be processed by this quick select is fully
|
|
55 |
specified in the description of get_best_trp_group_min_max() in optimizer/range.cc.
|
|
56 |
||
57 |
The get_next() method directly produces result tuples, thus obviating the
|
|
58 |
need to call end_send_group() because all grouping is already done inside
|
|
59 |
get_next().
|
|
60 |
||
61 |
Since one of the requirements is that all select fields are part of the same
|
|
62 |
index, this class produces only index keys, and not complete records.
|
|
63 |
*/
|
|
1237.13.21
by Padraig O'Sullivan
Corrected some style issues in the QuickGroupMinMaxSelect class. |
64 |
class QuickGroupMinMaxSelect : public QuickSelectInterface |
1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
65 |
{
|
1237.13.21
by Padraig O'Sullivan
Corrected some style issues in the QuickGroupMinMaxSelect class. |
66 |
|
1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
67 |
private: |
1237.13.21
by Padraig O'Sullivan
Corrected some style issues in the QuickGroupMinMaxSelect class. |
68 |
|
1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
69 |
Cursor *cursor; /**< The Cursor used to get data. */ |
1541.1.1
by Brian Aker
JOIN -> Join rename |
70 |
Join *join; /**< Descriptor of the current query */ |
1535
by Brian Aker
Rename of KEY to KeyInfo |
71 |
KeyInfo *index_info; /**< The index chosen for data access */ |
1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
72 |
unsigned char *record; /**< Buffer where the next record is returned. */ |
73 |
unsigned char *tmp_record; /**< Temporary storage for next_min(), next_max(). */ |
|
74 |
unsigned char *group_prefix; /**< Key prefix consisting of the GROUP fields. */ |
|
75 |
uint32_t group_prefix_len; /**< Length of the group prefix. */ |
|
76 |
uint32_t group_key_parts; /**< A number of keyparts in the group prefix */ |
|
77 |
unsigned char *last_prefix; /**< Prefix of the last group for detecting EOF. */ |
|
78 |
bool have_min; /**< Specify whether we are computing */ |
|
79 |
bool have_max; /**< a MIN, a MAX, or both. */ |
|
80 |
bool seen_first_key; /**< Denotes whether the first key was retrieved.*/ |
|
1534
by Brian Aker
Remove of KeyPartInfo |
81 |
KeyPartInfo *min_max_arg_part; /** The keypart of the only argument field of all MIN/MAX functions. */ |
1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
82 |
uint32_t min_max_arg_len; /**< The length of the MIN/MAX argument field */ |
83 |
unsigned char *key_infix; /**< Infix of constants from equality predicates. */ |
|
84 |
uint32_t key_infix_len; |
|
1237.13.29
by Padraig O'Sullivan
Replaced a DYNAMIC_ARRAY with std::vector in the range optimizer. |
85 |
std::vector<QuickRange *> min_max_ranges; /**< Array of range ptrs for the MIN/MAX field. */ |
1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
86 |
uint32_t real_prefix_len; /**< Length of key prefix extended with key_infix. */ |
87 |
uint32_t real_key_parts; /**< A number of keyparts in the above value. */ |
|
88 |
List<Item_sum> *min_functions; |
|
89 |
List<Item_sum> *max_functions; |
|
2179.1.3
by Olaf van der Spek
x |
90 |
List<Item_sum>::iterator *min_functions_it; |
91 |
List<Item_sum>::iterator *max_functions_it; |
|
1237.13.21
by Padraig O'Sullivan
Corrected some style issues in the QuickGroupMinMaxSelect class. |
92 |
|
1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
93 |
public: |
1237.13.21
by Padraig O'Sullivan
Corrected some style issues in the QuickGroupMinMaxSelect class. |
94 |
|
1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
95 |
/*
|
96 |
The following two members are public to allow easy access from
|
|
1237.13.27
by Padraig O'Sullivan
Correcting the case of a number of classes in the optimizer to adhere to the coding standards. Also |
97 |
GroupMinMaxReadPlan::make_quick()
|
1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
98 |
*/
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
99 |
memory::Root alloc; /**< Memory pool for this and quick_prefix_select data. */ |
1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
100 |
QuickRangeSelect *quick_prefix_select; /**< For retrieval of group prefixes. */ |
1237.13.21
by Padraig O'Sullivan
Corrected some style issues in the QuickGroupMinMaxSelect class. |
101 |
|
1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
102 |
private: |
1237.13.21
by Padraig O'Sullivan
Corrected some style issues in the QuickGroupMinMaxSelect class. |
103 |
|
104 |
/**
|
|
105 |
* Determine the prefix of the next group.
|
|
106 |
*
|
|
107 |
* SYNOPSIS
|
|
108 |
* QuickGroupMinMaxSelect::next_prefix()
|
|
109 |
*
|
|
110 |
* DESCRIPTION
|
|
111 |
* Determine the prefix of the next group that satisfies the query conditions.
|
|
112 |
* If there is a range condition referencing the group attributes, use a
|
|
113 |
* QuickRangeSelect object to retrieve the *first* key that satisfies the
|
|
114 |
* condition. If there is a key infix of constants, append this infix
|
|
115 |
* immediately after the group attributes. The possibly extended prefix is
|
|
116 |
* stored in this->group_prefix. The first key of the found group is stored in
|
|
117 |
* this->record, on which relies this->next_min().
|
|
118 |
*
|
|
119 |
* RETURN
|
|
120 |
* @retval 0 on success
|
|
121 |
* @retval HA_ERR_KEY_NOT_FOUND if there is no key with the formed prefix
|
|
122 |
* @retval HA_ERR_END_OF_FILE if there are no more keys
|
|
123 |
* @retval other if some error occurred
|
|
124 |
*/
|
|
1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
125 |
int next_prefix(); |
1237.13.21
by Padraig O'Sullivan
Corrected some style issues in the QuickGroupMinMaxSelect class. |
126 |
|
127 |
/**
|
|
128 |
* Find the minimal key in a group that satisfies some range conditions for the
|
|
129 |
* min/max argument field.
|
|
130 |
*
|
|
131 |
* SYNOPSIS
|
|
132 |
* QuickGroupMinMaxSelect::next_min_in_range()
|
|
133 |
*
|
|
134 |
* DESCRIPTION
|
|
135 |
* Given the sequence of ranges min_max_ranges, find the minimal key that is
|
|
136 |
* in the left-most possible range. If there is no such key, then the current
|
|
137 |
* group does not have a MIN key that satisfies the WHERE clause. If a key is
|
|
138 |
* found, its value is stored in this->record.
|
|
139 |
*
|
|
140 |
* RETURN
|
|
141 |
* @retval 0 on success
|
|
142 |
* @retval HA_ERR_KEY_NOT_FOUND if there is no key with the given prefix in any of the ranges
|
|
143 |
* @retval HA_ERR_END_OF_FILE - "" -
|
|
144 |
* @retval other if some error
|
|
145 |
*/
|
|
1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
146 |
int next_min_in_range(); |
1237.13.21
by Padraig O'Sullivan
Corrected some style issues in the QuickGroupMinMaxSelect class. |
147 |
|
148 |
/**
|
|
149 |
* Find the maximal key in a group that satisfies some range conditions for the
|
|
150 |
* min/max argument field.
|
|
151 |
*
|
|
152 |
* SYNOPSIS
|
|
153 |
* QuickGroupMinMaxSelect::next_max_in_range()
|
|
154 |
*
|
|
155 |
* DESCRIPTION
|
|
156 |
* Given the sequence of ranges min_max_ranges, find the maximal key that is
|
|
157 |
* in the right-most possible range. If there is no such key, then the current
|
|
158 |
* group does not have a MAX key that satisfies the WHERE clause. If a key is
|
|
159 |
* found, its value is stored in this->record.
|
|
160 |
*
|
|
161 |
* RETURN
|
|
162 |
* @retval 0 on success
|
|
163 |
* @retval HA_ERR_KEY_NOT_FOUND if there is no key with the given prefix in any of the ranges
|
|
164 |
* @retval HA_ERR_END_OF_FILE - "" -
|
|
165 |
* @retval other if some error
|
|
166 |
*/
|
|
1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
167 |
int next_max_in_range(); |
1237.13.21
by Padraig O'Sullivan
Corrected some style issues in the QuickGroupMinMaxSelect class. |
168 |
|
169 |
/**
|
|
170 |
* Retrieve the minimal key in the next group.
|
|
171 |
*
|
|
172 |
* SYNOPSIS
|
|
173 |
* QuickGroupMinMaxSelect::next_min()
|
|
174 |
*
|
|
175 |
* DESCRIPTION
|
|
176 |
* Find the minimal key within this group such that the key satisfies the query
|
|
177 |
* conditions and NULL semantics. The found key is loaded into this->record.
|
|
178 |
*
|
|
179 |
* IMPLEMENTATION
|
|
180 |
* Depending on the values of min_max_ranges.elements, key_infix_len, and
|
|
181 |
* whether there is a NULL in the MIN field, this function may directly
|
|
182 |
* return without any data access. In this case we use the key loaded into
|
|
183 |
* this->record by the call to this->next_prefix() just before this call.
|
|
184 |
*
|
|
185 |
* RETURN
|
|
186 |
* @retval 0 on success
|
|
187 |
* @retval HA_ERR_KEY_NOT_FOUND if no MIN key was found that fulfills all conditions.
|
|
188 |
* @retval HA_ERR_END_OF_FILE - "" -
|
|
189 |
* @retval other if some error occurred
|
|
190 |
*/
|
|
1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
191 |
int next_min(); |
1237.13.21
by Padraig O'Sullivan
Corrected some style issues in the QuickGroupMinMaxSelect class. |
192 |
|
193 |
/**
|
|
194 |
* Retrieve the maximal key in the next group.
|
|
195 |
*
|
|
196 |
* SYNOPSIS
|
|
197 |
* QuickGroupMinMaxSelect::next_max()
|
|
198 |
*
|
|
199 |
* DESCRIPTION
|
|
200 |
* Lookup the maximal key of the group, and store it into this->record.
|
|
201 |
*
|
|
202 |
* RETURN
|
|
203 |
* @retval 0 on success
|
|
204 |
* @retval HA_ERR_KEY_NOT_FOUND if no MAX key was found that fulfills all conditions.
|
|
205 |
* @retval HA_ERR_END_OF_FILE - "" -
|
|
206 |
* @retval other if some error occurred
|
|
207 |
*/
|
|
1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
208 |
int next_max(); |
1237.13.21
by Padraig O'Sullivan
Corrected some style issues in the QuickGroupMinMaxSelect class. |
209 |
|
210 |
/**
|
|
211 |
* Update all MIN function results with the newly found value.
|
|
212 |
*
|
|
213 |
* SYNOPSIS
|
|
214 |
* QuickGroupMinMaxSelect::update_min_result()
|
|
215 |
*
|
|
216 |
* DESCRIPTION
|
|
217 |
* The method iterates through all MIN functions and updates the result value
|
|
218 |
* of each function by calling Item_sum::reset(), which in turn picks the new
|
|
1672.3.6
by Brian Aker
First pass in encapsulating row |
219 |
* result value from this->head->getInsertRecord(), previously updated by
|
1237.13.21
by Padraig O'Sullivan
Corrected some style issues in the QuickGroupMinMaxSelect class. |
220 |
* next_min(). The updated value is stored in a member variable of each of the
|
221 |
* Item_sum objects, depending on the value type.
|
|
222 |
*
|
|
223 |
* IMPLEMENTATION
|
|
224 |
* The update must be done separately for MIN and MAX, immediately after
|
|
225 |
* next_min() was called and before next_max() is called, because both MIN and
|
|
1672.3.6
by Brian Aker
First pass in encapsulating row |
226 |
* MAX take their result value from the same buffer this->head->getInsertRecord()
|
1237.13.21
by Padraig O'Sullivan
Corrected some style issues in the QuickGroupMinMaxSelect class. |
227 |
* (i.e. this->record).
|
228 |
*
|
|
229 |
* RETURN
|
|
230 |
* None
|
|
231 |
*/
|
|
1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
232 |
void update_min_result(); |
1237.13.21
by Padraig O'Sullivan
Corrected some style issues in the QuickGroupMinMaxSelect class. |
233 |
|
234 |
/**
|
|
235 |
* Update all MAX function results with the newly found value.
|
|
236 |
*
|
|
237 |
* SYNOPSIS
|
|
238 |
* QuickGroupMinMaxSelect::update_max_result()
|
|
239 |
*
|
|
240 |
* DESCRIPTION
|
|
241 |
* The method iterates through all MAX functions and updates the result value
|
|
242 |
* of each function by calling Item_sum::reset(), which in turn picks the new
|
|
1672.3.6
by Brian Aker
First pass in encapsulating row |
243 |
* result value from this->head->getInsertRecord(), previously updated by
|
1237.13.21
by Padraig O'Sullivan
Corrected some style issues in the QuickGroupMinMaxSelect class. |
244 |
* next_max(). The updated value is stored in a member variable of each of the
|
245 |
* Item_sum objects, depending on the value type.
|
|
246 |
*
|
|
247 |
* IMPLEMENTATION
|
|
248 |
* The update must be done separately for MIN and MAX, immediately after
|
|
249 |
* next_max() was called, because both MIN and MAX take their result value
|
|
1672.3.6
by Brian Aker
First pass in encapsulating row |
250 |
* from the same buffer this->head->getInsertRecord() (i.e. this->record).
|
1237.13.21
by Padraig O'Sullivan
Corrected some style issues in the QuickGroupMinMaxSelect class. |
251 |
*
|
252 |
* RETURN
|
|
253 |
* None
|
|
254 |
*/
|
|
1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
255 |
void update_max_result(); |
1237.13.21
by Padraig O'Sullivan
Corrected some style issues in the QuickGroupMinMaxSelect class. |
256 |
|
1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
257 |
public: |
1237.13.21
by Padraig O'Sullivan
Corrected some style issues in the QuickGroupMinMaxSelect class. |
258 |
|
259 |
/*
|
|
260 |
Construct new quick select for group queries with min/max.
|
|
261 |
||
262 |
SYNOPSIS
|
|
263 |
QuickGroupMinMaxSelect::QuickGroupMinMaxSelect()
|
|
264 |
table The table being accessed
|
|
265 |
join Descriptor of the current query
|
|
266 |
have_min true if the query selects a MIN function
|
|
267 |
have_max true if the query selects a MAX function
|
|
268 |
min_max_arg_part The only argument field of all MIN/MAX functions
|
|
269 |
group_prefix_len Length of all key parts in the group prefix
|
|
270 |
prefix_key_parts All key parts in the group prefix
|
|
271 |
index_info The index chosen for data access
|
|
272 |
use_index The id of index_info
|
|
273 |
read_cost Cost of this access method
|
|
274 |
records Number of records returned
|
|
275 |
key_infix_len Length of the key infix appended to the group prefix
|
|
276 |
key_infix Infix of constants from equality predicates
|
|
277 |
parent_alloc Memory pool for this and quick_prefix_select data
|
|
278 |
||
279 |
RETURN
|
|
280 |
None
|
|
281 |
*/
|
|
282 |
QuickGroupMinMaxSelect(Table *table, |
|
1541.1.1
by Brian Aker
JOIN -> Join rename |
283 |
Join *join, |
1237.13.21
by Padraig O'Sullivan
Corrected some style issues in the QuickGroupMinMaxSelect class. |
284 |
bool have_min, |
285 |
bool have_max, |
|
1534
by Brian Aker
Remove of KeyPartInfo |
286 |
KeyPartInfo *min_max_arg_part, |
1237.13.21
by Padraig O'Sullivan
Corrected some style issues in the QuickGroupMinMaxSelect class. |
287 |
uint32_t group_prefix_len, |
288 |
uint32_t group_key_parts, |
|
289 |
uint32_t used_key_parts, |
|
1535
by Brian Aker
Rename of KEY to KeyInfo |
290 |
KeyInfo *index_info, |
1237.13.21
by Padraig O'Sullivan
Corrected some style issues in the QuickGroupMinMaxSelect class. |
291 |
uint use_index, |
292 |
double read_cost, |
|
293 |
ha_rows records, |
|
294 |
uint key_infix_len, |
|
295 |
unsigned char *key_infix, |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
296 |
memory::Root *parent_alloc); |
1237.13.21
by Padraig O'Sullivan
Corrected some style issues in the QuickGroupMinMaxSelect class. |
297 |
|
298 |
~QuickGroupMinMaxSelect(); |
|
299 |
||
300 |
/**
|
|
301 |
* Eventually create and add a new quick range object.
|
|
302 |
*
|
|
303 |
* SYNOPSIS
|
|
304 |
* QuickGroupMinMaxSelect::add_range()
|
|
305 |
* @param[in] sel_range Range object from which a new object is created
|
|
306 |
*
|
|
307 |
* NOTES
|
|
308 |
* Construct a new QuickRange object from a SEL_ARG object, and
|
|
309 |
* add it to the array min_max_ranges. If sel_arg is an infinite
|
|
310 |
* range, e.g. (x < 5 or x > 4), then skip it and do not construct
|
|
311 |
* a quick range.
|
|
312 |
*
|
|
313 |
* RETURN
|
|
314 |
* @retval false on success
|
|
315 |
* @retval true otherwise
|
|
316 |
*/
|
|
1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
317 |
bool add_range(SEL_ARG *sel_range); |
1237.13.21
by Padraig O'Sullivan
Corrected some style issues in the QuickGroupMinMaxSelect class. |
318 |
|
319 |
/**
|
|
320 |
* Determine the total number and length of the keys that will be used for
|
|
321 |
* index lookup.
|
|
322 |
*
|
|
323 |
* SYNOPSIS
|
|
324 |
* QuickGroupMinMaxSelect::update_key_stat()
|
|
325 |
*
|
|
326 |
* DESCRIPTION
|
|
327 |
* The total length of the keys used for index lookup depends on whether
|
|
328 |
* there are any predicates referencing the min/max argument, and/or if
|
|
329 |
* the min/max argument field can be NULL.
|
|
330 |
* This function does an optimistic analysis whether the search key might
|
|
331 |
* be extended by a constant for the min/max keypart. It is 'optimistic'
|
|
332 |
* because during actual execution it may happen that a particular range
|
|
333 |
* is skipped, and then a shorter key will be used. However this is data
|
|
334 |
* dependent and can't be easily estimated here.
|
|
335 |
*
|
|
336 |
* RETURN
|
|
337 |
* None
|
|
338 |
*/
|
|
1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
339 |
void update_key_stat(); |
1237.13.21
by Padraig O'Sullivan
Corrected some style issues in the QuickGroupMinMaxSelect class. |
340 |
|
341 |
/**
|
|
342 |
* Opens the ranges if there are more conditions in quick_prefix_select than
|
|
343 |
* the ones used for jumping through the prefixes.
|
|
344 |
*
|
|
345 |
* SYNOPSIS
|
|
346 |
* QuickGroupMinMaxSelect::adjust_prefix_ranges()
|
|
347 |
*
|
|
348 |
* NOTES
|
|
349 |
* quick_prefix_select is made over the conditions on the whole key.
|
|
350 |
* It defines a number of ranges of length x.
|
|
351 |
* However when jumping through the prefixes we use only the the first
|
|
352 |
* few most significant keyparts in the range key. However if there
|
|
353 |
* are more keyparts to follow the ones we are using we must make the
|
|
354 |
* condition on the key inclusive (because x < "ab" means
|
|
355 |
* x[0] < 'a' OR (x[0] == 'a' AND x[1] < 'b').
|
|
356 |
* To achive the above we must turn off the NEAR_MIN/NEAR_MAX
|
|
357 |
*/
|
|
1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
358 |
void adjust_prefix_ranges(); |
1237.13.21
by Padraig O'Sullivan
Corrected some style issues in the QuickGroupMinMaxSelect class. |
359 |
|
1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
360 |
bool alloc_buffers(); |
1237.13.21
by Padraig O'Sullivan
Corrected some style issues in the QuickGroupMinMaxSelect class. |
361 |
|
362 |
/**
|
|
363 |
* Do post-constructor initialization.
|
|
364 |
*
|
|
365 |
* SYNOPSIS
|
|
366 |
* QuickGroupMinMaxSelect::init()
|
|
367 |
*
|
|
368 |
* DESCRIPTION
|
|
369 |
* The method performs initialization that cannot be done in the constructor
|
|
370 |
* such as memory allocations that may fail. It allocates memory for the
|
|
371 |
* group prefix and inifix buffers, and for the lists of MIN/MAX item to be
|
|
372 |
* updated during execution.
|
|
373 |
*
|
|
374 |
* RETURN
|
|
375 |
* @retval 0 OK
|
|
376 |
* @retval other Error code
|
|
377 |
*/
|
|
1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
378 |
int init(); |
1237.13.21
by Padraig O'Sullivan
Corrected some style issues in the QuickGroupMinMaxSelect class. |
379 |
|
380 |
/**
|
|
381 |
* Initialize a quick group min/max select for key retrieval.
|
|
382 |
*
|
|
383 |
* SYNOPSIS
|
|
384 |
* QuickGroupMinMaxSelect::reset()
|
|
385 |
*
|
|
386 |
* DESCRIPTION
|
|
387 |
* Initialize the index chosen for access and find and store the prefix
|
|
388 |
* of the last group. The method is expensive since it performs disk access.
|
|
389 |
*
|
|
390 |
* RETURN
|
|
391 |
* @retval 0 OK
|
|
392 |
* @retval other Error code
|
|
393 |
*/
|
|
1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
394 |
int reset(); |
1237.13.21
by Padraig O'Sullivan
Corrected some style issues in the QuickGroupMinMaxSelect class. |
395 |
|
396 |
/**
|
|
397 |
* Get the next key containing the MIN and/or MAX key for the next group.
|
|
398 |
*
|
|
399 |
* SYNOPSIS
|
|
400 |
* QuickGroupMinMaxSelect::get_next()
|
|
401 |
*
|
|
402 |
* DESCRIPTION
|
|
403 |
* The method finds the next subsequent group of records that satisfies the
|
|
404 |
* query conditions and finds the keys that contain the MIN/MAX values for
|
|
405 |
* the key part referenced by the MIN/MAX function(s). Once a group and its
|
|
406 |
* MIN/MAX values are found, store these values in the Item_sum objects for
|
|
407 |
* the MIN/MAX functions. The rest of the values in the result row are stored
|
|
408 |
* in the Item_field::result_field of each select field. If the query does
|
|
409 |
* not contain MIN and/or MAX functions, then the function only finds the
|
|
410 |
* group prefix, which is a query answer itself.
|
|
411 |
*
|
|
412 |
* NOTES
|
|
413 |
* If both MIN and MAX are computed, then we use the fact that if there is
|
|
414 |
* no MIN key, there can't be a MAX key as well, so we can skip looking
|
|
415 |
* for a MAX key in this case.
|
|
416 |
*
|
|
417 |
* RETURN
|
|
418 |
* @retval 0 on success
|
|
419 |
* @retval HA_ERR_END_OF_FILE if returned all keys
|
|
420 |
* @retval other if some error occurred
|
|
421 |
*/
|
|
1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
422 |
int get_next(); |
423 |
||
424 |
bool reverse_sorted() const |
|
425 |
{
|
|
426 |
return false; |
|
427 |
}
|
|
428 |
||
429 |
bool unique_key_range() const |
|
430 |
{
|
|
431 |
return false; |
|
432 |
}
|
|
433 |
||
434 |
int get_type() const |
|
435 |
{
|
|
436 |
return QS_TYPE_GROUP_MIN_MAX; |
|
437 |
}
|
|
438 |
||
1237.13.21
by Padraig O'Sullivan
Corrected some style issues in the QuickGroupMinMaxSelect class. |
439 |
/**
|
440 |
* Append comma-separated list of keys this quick select uses to key_names;
|
|
441 |
* append comma-separated list of corresponding used lengths to used_lengths.
|
|
442 |
*
|
|
443 |
* SYNOPSIS
|
|
444 |
* QuickGroupMinMaxSelect::add_keys_and_lengths()
|
|
445 |
* @param[out] key_names Names of used indexes
|
|
446 |
* @param[out] used_lengths Corresponding lengths of the index names
|
|
447 |
*
|
|
448 |
* DESCRIPTION
|
|
449 |
* This method is used by select_describe to extract the names of the
|
|
450 |
* indexes used by a quick select.
|
|
451 |
*/
|
|
2170.4.4
by Stewart Smith
tmp3 String to std::string in explain_plan (and used_lengths parameter to add_keys_and_lengths |
452 |
void add_keys_and_lengths(std::string *key_names, std::string *used_lengths); |
1237.13.21
by Padraig O'Sullivan
Corrected some style issues in the QuickGroupMinMaxSelect class. |
453 |
|
1237.13.18
by Padraig O'Sullivan
Split the QUICK_GROUP_MIN_MAX_SELECT class out into its own header and implementation files. |
454 |
};
|
455 |
||
456 |
||
457 |
} /* namespace optimizer */ |
|
458 |
||
459 |
} /* namespace drizzled */ |
|
460 |