1237.13.6
by Padraig O'Sullivan
Moved the SEL_ARG class into its own header and implementation files. Cleaned up a bunch of style |
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.6
by Padraig O'Sullivan
Moved the SEL_ARG class into its own header and implementation files. Cleaned up a bunch of style |
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 |
||
1237.13.9
by Padraig O'Sullivan
Updated another include guard that was caught by make check. |
20 |
#ifndef DRIZZLED_OPTIMIZER_RANGE_PARAM_H
|
21 |
#define DRIZZLED_OPTIMIZER_RANGE_PARAM_H
|
|
1237.13.6
by Padraig O'Sullivan
Moved the SEL_ARG class into its own header and implementation files. Cleaned up a bunch of style |
22 |
|
1802.16.4
by Padraig O'Sullivan
Removal of another MyBitmap in the range optimizer. |
23 |
#include <boost/dynamic_bitset.hpp> |
24 |
||
1237.13.6
by Padraig O'Sullivan
Moved the SEL_ARG class into its own header and implementation files. Cleaned up a bunch of style |
25 |
#include "drizzled/field.h" |
26 |
||
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
27 |
namespace drizzled |
28 |
{
|
|
29 |
||
1237.13.6
by Padraig O'Sullivan
Moved the SEL_ARG class into its own header and implementation files. Cleaned up a bunch of style |
30 |
typedef class Item COND; |
31 |
typedef struct st_key_part KEY_PART; |
|
32 |
||
33 |
namespace optimizer |
|
34 |
{
|
|
35 |
||
1802.16.16
by Padraig O'Sullivan
Convert struct to class and move it into optimizer namespace. |
36 |
class RorScanInfo |
37 |
{
|
|
38 |
public: |
|
39 |
RorScanInfo() |
|
40 |
:
|
|
41 |
idx(0), |
|
42 |
keynr(0), |
|
43 |
records(0), |
|
44 |
sel_arg(NULL), |
|
1802.16.17
by Padraig O'Sullivan
Hack to fix memory leak. This is horrible but lets us get rid of MyBitmap. This hack is needed for now to prevent a memory leak that occurs because mem_root does not always call desctructors of the objects it allocates memory for. The long term solution to this is to remove the use of mem_root from the optimizer. Once that is done, this hack can be taken back out again which I will very gladly do... |
45 |
covered_fields(0), |
46 |
covered_fields_size(0), |
|
1802.16.16
by Padraig O'Sullivan
Convert struct to class and move it into optimizer namespace. |
47 |
used_fields_covered(0), |
48 |
key_rec_length(0), |
|
49 |
index_read_cost(0.0), |
|
50 |
first_uncovered_field(0), |
|
51 |
key_components(0) |
|
52 |
{}
|
|
53 |
||
1802.16.17
by Padraig O'Sullivan
Hack to fix memory leak. This is horrible but lets us get rid of MyBitmap. This hack is needed for now to prevent a memory leak that occurs because mem_root does not always call desctructors of the objects it allocates memory for. The long term solution to this is to remove the use of mem_root from the optimizer. Once that is done, this hack can be taken back out again which I will very gladly do... |
54 |
boost::dynamic_bitset<> bitsToBitset() const; |
55 |
||
56 |
void subtractBitset(const boost::dynamic_bitset<>& in_bitset); |
|
57 |
||
58 |
uint32_t findFirstNotSet() const; |
|
59 |
||
60 |
size_t getBitCount() const; |
|
1802.16.16
by Padraig O'Sullivan
Convert struct to class and move it into optimizer namespace. |
61 |
|
62 |
uint32_t idx; /* # of used key in param->keys */ |
|
63 |
uint32_t keynr; /* # of used key in table */ |
|
64 |
ha_rows records; /* estimate of # records this scan will return */ |
|
65 |
||
66 |
/* Set of intervals over key fields that will be used for row retrieval. */
|
|
67 |
optimizer::SEL_ARG *sel_arg; |
|
68 |
||
69 |
/* Fields used in the query and covered by this ROR scan. */
|
|
1802.16.17
by Padraig O'Sullivan
Hack to fix memory leak. This is horrible but lets us get rid of MyBitmap. This hack is needed for now to prevent a memory leak that occurs because mem_root does not always call desctructors of the objects it allocates memory for. The long term solution to this is to remove the use of mem_root from the optimizer. Once that is done, this hack can be taken back out again which I will very gladly do... |
70 |
uint64_t covered_fields; |
71 |
size_t covered_fields_size; |
|
1802.16.16
by Padraig O'Sullivan
Convert struct to class and move it into optimizer namespace. |
72 |
uint32_t used_fields_covered; /* # of set bits in covered_fields */ |
73 |
int key_rec_length; /* length of key record (including rowid) */ |
|
74 |
||
75 |
/*
|
|
76 |
Cost of reading all index records with values in sel_arg intervals set
|
|
77 |
(assuming there is no need to access full table records)
|
|
78 |
*/
|
|
79 |
double index_read_cost; |
|
80 |
uint32_t first_uncovered_field; /* first unused bit in covered_fields */ |
|
81 |
uint32_t key_components; /* # of parts in the key */ |
|
82 |
};
|
|
83 |
||
1237.13.7
by Padraig O'Sullivan
Renamed PARAM to Parameter and RANGE_OPT_PARAM to RangeParameter. |
84 |
class RangeParameter |
1237.13.6
by Padraig O'Sullivan
Moved the SEL_ARG class into its own header and implementation files. Cleaned up a bunch of style |
85 |
{
|
86 |
public: |
|
1237.13.28
by Padraig O'Sullivan
Modified classes to have names in camel case instead of all upper case. Added default constructors |
87 |
|
88 |
RangeParameter() |
|
89 |
:
|
|
90 |
session(NULL), |
|
91 |
table(NULL), |
|
92 |
cond(NULL), |
|
93 |
prev_tables(), |
|
94 |
read_tables(), |
|
95 |
current_table(), |
|
96 |
key_parts(NULL), |
|
97 |
key_parts_end(NULL), |
|
98 |
mem_root(NULL), |
|
99 |
old_root(NULL), |
|
100 |
keys(0), |
|
101 |
using_real_indexes(false), |
|
102 |
remove_jump_scans(false), |
|
103 |
alloced_sel_args(0), |
|
104 |
force_default_mrr(false) |
|
105 |
{}
|
|
106 |
||
1237.13.6
by Padraig O'Sullivan
Moved the SEL_ARG class into its own header and implementation files. Cleaned up a bunch of style |
107 |
Session *session; /* Current thread handle */ |
108 |
Table *table; /* Table being analyzed */ |
|
109 |
COND *cond; /* Used inside get_mm_tree(). */ |
|
110 |
table_map prev_tables; |
|
111 |
table_map read_tables; |
|
112 |
table_map current_table; /* Bit of the table being analyzed */ |
|
113 |
||
114 |
/* Array of parts of all keys for which range analysis is performed */
|
|
115 |
KEY_PART *key_parts; |
|
116 |
KEY_PART *key_parts_end; |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
117 |
memory::Root *mem_root; /* Memory that will be freed when range analysis completes */ |
118 |
memory::Root *old_root; /* Memory that will last until the query end */ |
|
1237.13.6
by Padraig O'Sullivan
Moved the SEL_ARG class into its own header and implementation files. Cleaned up a bunch of style |
119 |
/*
|
120 |
Number of indexes used in range analysis (In SEL_TREE::keys only first
|
|
121 |
#keys elements are not empty)
|
|
122 |
*/
|
|
123 |
uint32_t keys; |
|
124 |
||
125 |
/*
|
|
126 |
If true, the index descriptions describe real indexes (and it is ok to
|
|
127 |
call field->optimize_range(real_keynr[...], ...).
|
|
128 |
Otherwise index description describes fake indexes.
|
|
129 |
*/
|
|
130 |
bool using_real_indexes; |
|
131 |
||
132 |
bool remove_jump_scans; |
|
133 |
||
134 |
/*
|
|
135 |
used_key_no -> table_key_no translation table. Only makes sense if
|
|
136 |
using_real_indexes==true
|
|
137 |
*/
|
|
138 |
uint32_t real_keynr[MAX_KEY]; |
|
139 |
/* Number of SEL_ARG objects allocated by optimizer::SEL_ARG::clone_tree operations */
|
|
140 |
uint32_t alloced_sel_args; |
|
141 |
bool force_default_mrr; |
|
142 |
};
|
|
143 |
||
1237.13.7
by Padraig O'Sullivan
Renamed PARAM to Parameter and RANGE_OPT_PARAM to RangeParameter. |
144 |
class Parameter : public RangeParameter |
1237.13.6
by Padraig O'Sullivan
Moved the SEL_ARG class into its own header and implementation files. Cleaned up a bunch of style |
145 |
{
|
146 |
public: |
|
1237.13.28
by Padraig O'Sullivan
Modified classes to have names in camel case instead of all upper case. Added default constructors |
147 |
|
148 |
Parameter() |
|
149 |
:
|
|
150 |
RangeParameter(), |
|
151 |
max_key_part(0), |
|
152 |
range_count(0), |
|
153 |
quick(false), |
|
154 |
needed_fields(), |
|
155 |
tmp_covered_fields(), |
|
156 |
needed_reg(NULL), |
|
157 |
imerge_cost_buff(NULL), |
|
158 |
imerge_cost_buff_size(0), |
|
159 |
is_ror_scan(false), |
|
160 |
n_ranges(0) |
|
161 |
{}
|
|
162 |
||
1237.13.6
by Padraig O'Sullivan
Moved the SEL_ARG class into its own header and implementation files. Cleaned up a bunch of style |
163 |
KEY_PART *key[MAX_KEY]; /* First key parts of keys used in the query */ |
164 |
uint32_t max_key_part; |
|
165 |
/* Number of ranges in the last checked tree->key */
|
|
166 |
uint32_t range_count; |
|
1237.13.28
by Padraig O'Sullivan
Modified classes to have names in camel case instead of all upper case. Added default constructors |
167 |
unsigned char min_key[MAX_KEY_LENGTH+MAX_FIELD_WIDTH]; |
168 |
unsigned char max_key[MAX_KEY_LENGTH+MAX_FIELD_WIDTH]; |
|
169 |
bool quick; // Don't calulate possible keys |
|
1237.13.6
by Padraig O'Sullivan
Moved the SEL_ARG class into its own header and implementation files. Cleaned up a bunch of style |
170 |
|
1802.16.4
by Padraig O'Sullivan
Removal of another MyBitmap in the range optimizer. |
171 |
boost::dynamic_bitset<> needed_fields; /* bitmask of fields needed by the query */ |
172 |
boost::dynamic_bitset<> tmp_covered_fields; |
|
1237.13.6
by Padraig O'Sullivan
Moved the SEL_ARG class into its own header and implementation files. Cleaned up a bunch of style |
173 |
|
174 |
key_map *needed_reg; /* ptr to SqlSelect::needed_reg */ |
|
175 |
||
176 |
uint32_t *imerge_cost_buff; /* buffer for index_merge cost estimates */ |
|
177 |
uint32_t imerge_cost_buff_size; /* size of the buffer */ |
|
178 |
||
179 |
/* true if last checked tree->key can be used for ROR-scan */
|
|
180 |
bool is_ror_scan; |
|
181 |
/* Number of ranges in the last checked tree->key */
|
|
182 |
uint32_t n_ranges; |
|
183 |
};
|
|
184 |
||
185 |
} /* namespace optimizer */ |
|
186 |
||
187 |
} /* namespace drizzled */ |
|
188 |
||
1237.13.9
by Padraig O'Sullivan
Updated another include guard that was caught by make check. |
189 |
#endif /* DRIZZLED_OPTIMIZER_RANGE_PARAM_H */ |