1237.13.11
by Padraig O'Sullivan
Split the QUICK_ROR_INTERSECT_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 |
*
|
|
4 |
* Copyright (C) 2008-2009 Sun Microsystems
|
|
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 |
||
20 |
#ifndef DRIZZLED_OPTIMIZER_QUICK_ROR_INTERSECT_SELECT_H
|
|
21 |
#define DRIZZLED_OPTIMIZER_QUICK_ROR_INTERSECT_SELECT_H
|
|
22 |
||
23 |
#include "drizzled/optimizer/range.h" |
|
24 |
||
1237.13.16
by Padraig O'Sullivan
Replaced List with std::vector in the QuickRorIntersectSelect class. |
25 |
#include <vector> |
26 |
||
1237.13.11
by Padraig O'Sullivan
Split the QUICK_ROR_INTERSECT_SELECT class out into its own header and implementation files. |
27 |
namespace drizzled |
28 |
{
|
|
29 |
||
30 |
namespace optimizer |
|
31 |
{
|
|
32 |
||
33 |
/**
|
|
34 |
Rowid-Ordered Retrieval (ROR) index intersection quick select.
|
|
35 |
This quick select produces intersection of row sequences returned
|
|
36 |
by several QuickRangeSelects it "merges".
|
|
37 |
||
38 |
All merged QuickRangeSelects must return rowids in rowid order.
|
|
1237.13.12
by Padraig O'Sullivan
Corrected the name of the QUICK_ROR_INTERSECT_CLASS class to adhere to the drizzle coding standards. |
39 |
QuickRorIntersectSelect will return rows in rowid order, too.
|
1237.13.11
by Padraig O'Sullivan
Split the QUICK_ROR_INTERSECT_SELECT class out into its own header and implementation files. |
40 |
|
41 |
All merged quick selects retrieve {rowid, covered_fields} tuples (not full
|
|
42 |
table records).
|
|
1237.13.12
by Padraig O'Sullivan
Corrected the name of the QUICK_ROR_INTERSECT_CLASS class to adhere to the drizzle coding standards. |
43 |
QuickRorIntersectSelect retrieves full records if it is not being used
|
44 |
by QuickRorIntersectSelect and all merged quick selects together don't
|
|
1237.13.11
by Padraig O'Sullivan
Split the QUICK_ROR_INTERSECT_SELECT class out into its own header and implementation files. |
45 |
cover needed all fields.
|
46 |
||
47 |
If one of the merged quick selects is a Clustered PK range scan, it is
|
|
48 |
used only to filter rowid sequence produced by other merged quick selects.
|
|
49 |
*/
|
|
1237.13.12
by Padraig O'Sullivan
Corrected the name of the QUICK_ROR_INTERSECT_CLASS class to adhere to the drizzle coding standards. |
50 |
class QuickRorIntersectSelect : public QuickSelectInterface |
1237.13.11
by Padraig O'Sullivan
Split the QUICK_ROR_INTERSECT_SELECT class out into its own header and implementation files. |
51 |
{
|
52 |
public: |
|
53 |
||
1237.13.12
by Padraig O'Sullivan
Corrected the name of the QUICK_ROR_INTERSECT_CLASS class to adhere to the drizzle coding standards. |
54 |
QuickRorIntersectSelect(Session *session, |
1237.13.11
by Padraig O'Sullivan
Split the QUICK_ROR_INTERSECT_SELECT class out into its own header and implementation files. |
55 |
Table *table, |
56 |
bool retrieve_full_rows, |
|
57 |
MEM_ROOT *parent_alloc); |
|
58 |
||
1237.13.12
by Padraig O'Sullivan
Corrected the name of the QUICK_ROR_INTERSECT_CLASS class to adhere to the drizzle coding standards. |
59 |
~QuickRorIntersectSelect(); |
1237.13.11
by Padraig O'Sullivan
Split the QUICK_ROR_INTERSECT_SELECT class out into its own header and implementation files. |
60 |
|
61 |
/**
|
|
62 |
* Do post-constructor initialization.
|
|
63 |
* SYNOPSIS
|
|
1237.13.12
by Padraig O'Sullivan
Corrected the name of the QUICK_ROR_INTERSECT_CLASS class to adhere to the drizzle coding standards. |
64 |
* QuickRorIntersectSelect::init()
|
1237.13.11
by Padraig O'Sullivan
Split the QUICK_ROR_INTERSECT_SELECT class out into its own header and implementation files. |
65 |
*
|
66 |
* RETURN
|
|
67 |
* @retval 0 OK
|
|
68 |
* @retval other Error code
|
|
69 |
*/
|
|
70 |
int init(); |
|
71 |
||
72 |
/**
|
|
73 |
* Initialize quick select for row retrieval.
|
|
74 |
* SYNOPSIS
|
|
75 |
* reset()
|
|
76 |
* RETURN
|
|
77 |
* @retval 0 OK
|
|
78 |
* @retval other Error code
|
|
79 |
*/
|
|
80 |
int reset(void); |
|
81 |
||
82 |
/**
|
|
83 |
* Retrieve next record.
|
|
84 |
* SYNOPSIS
|
|
1237.13.12
by Padraig O'Sullivan
Corrected the name of the QUICK_ROR_INTERSECT_CLASS class to adhere to the drizzle coding standards. |
85 |
* QuickRorIntersectSelect::get_next()
|
1237.13.11
by Padraig O'Sullivan
Split the QUICK_ROR_INTERSECT_SELECT class out into its own header and implementation files. |
86 |
*
|
87 |
* NOTES
|
|
88 |
* Invariant on enter/exit: all intersected selects have retrieved all index
|
|
89 |
* records with rowid <= some_rowid_val and no intersected select has
|
|
90 |
* retrieved any index records with rowid > some_rowid_val.
|
|
91 |
* We start fresh and loop until we have retrieved the same rowid in each of
|
|
92 |
* the key scans or we got an error.
|
|
93 |
*
|
|
94 |
* If a Clustered PK scan is present, it is used only to check if row
|
|
95 |
* satisfies its condition (and never used for row retrieval).
|
|
96 |
*
|
|
97 |
* RETURN
|
|
98 |
* @retval 0 - Ok
|
|
99 |
* @retval other - Error code if any error occurred.
|
|
100 |
*/
|
|
101 |
int get_next(); |
|
102 |
||
103 |
bool reverse_sorted() const |
|
104 |
{
|
|
105 |
return false; |
|
106 |
}
|
|
107 |
||
108 |
bool unique_key_range() const |
|
109 |
{
|
|
110 |
return false; |
|
111 |
}
|
|
112 |
||
113 |
int get_type() const |
|
114 |
{
|
|
115 |
return QS_TYPE_ROR_INTERSECT; |
|
116 |
}
|
|
117 |
||
118 |
void add_keys_and_lengths(String *key_names, String *used_lengths); |
|
119 |
void add_info_string(String *str); |
|
120 |
bool is_keys_used(const MyBitmap *fields); |
|
121 |
||
122 |
/**
|
|
123 |
* Initialize this quick select to be a part of a ROR-merged scan.
|
|
124 |
* SYNOPSIS
|
|
1237.13.12
by Padraig O'Sullivan
Corrected the name of the QUICK_ROR_INTERSECT_CLASS class to adhere to the drizzle coding standards. |
125 |
* QuickRorIntersectSelect::init_ror_merged_scan()
|
1237.13.11
by Padraig O'Sullivan
Split the QUICK_ROR_INTERSECT_SELECT class out into its own header and implementation files. |
126 |
* reuse_handler If true, use head->cursor, otherwise create separate
|
127 |
* Cursor object.
|
|
128 |
* RETURN
|
|
129 |
* @retval 0 OK
|
|
130 |
* @retval other error code
|
|
131 |
*/
|
|
132 |
int init_ror_merged_scan(bool reuse_handler); |
|
133 |
||
134 |
/**
|
|
135 |
* Add a merged quick select to this ROR-intersection quick select.
|
|
136 |
*
|
|
137 |
* SYNOPSIS
|
|
1237.13.12
by Padraig O'Sullivan
Corrected the name of the QUICK_ROR_INTERSECT_CLASS class to adhere to the drizzle coding standards. |
138 |
* QuickRorIntersectSelect::push_quick_back()
|
1237.13.11
by Padraig O'Sullivan
Split the QUICK_ROR_INTERSECT_SELECT class out into its own header and implementation files. |
139 |
* quick Quick select to be added. The quick select must return
|
140 |
* rows in rowid order.
|
|
141 |
* NOTES
|
|
142 |
* This call can only be made before init() is called.
|
|
143 |
*
|
|
144 |
* RETURN
|
|
145 |
* @retval false OK
|
|
146 |
* @retval true Out of memory.
|
|
147 |
*/
|
|
148 |
bool push_quick_back(QuickRangeSelect *quick_sel_range); |
|
149 |
||
150 |
/**
|
|
151 |
* Range quick selects this intersection consists of, not including
|
|
152 |
* cpk_quick.
|
|
153 |
*/
|
|
1237.13.16
by Padraig O'Sullivan
Replaced List with std::vector in the QuickRorIntersectSelect class. |
154 |
std::vector<QuickRangeSelect *> quick_selects; |
1237.13.11
by Padraig O'Sullivan
Split the QUICK_ROR_INTERSECT_SELECT class out into its own header and implementation files. |
155 |
|
156 |
/**
|
|
157 |
* Merged quick select that uses Clustered PK, if there is one. This quick
|
|
158 |
* select is not used for row retrieval, it is used for row retrieval.
|
|
159 |
*/
|
|
160 |
QuickRangeSelect *cpk_quick; |
|
161 |
||
162 |
MEM_ROOT alloc; /**< Memory pool for this and merged quick selects data. */ |
|
163 |
Session *session; /**< Pointer to the current session */ |
|
164 |
bool need_to_fetch_row; /**< if true, do retrieve full table records. */ |
|
165 |
/** in top-level quick select, true if merged scans where initialized */
|
|
166 |
bool scans_inited; |
|
167 |
};
|
|
168 |
||
169 |
} /* namespace optimizer */ |
|
170 |
||
171 |
} /* namespace drizzled */ |
|
172 |
||
173 |
#endif /* DRIZZLED_OPTIMIZER_QUICK_ROR_INTERSECT_SELECT_H */ |