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