~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/optimizer/quick_range_select.h

  • Committer: Stewart Smith
  • Date: 2010-11-03 03:27:09 UTC
  • mto: (1902.1.1 build) (1910.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1903.
  • Revision ID: stewart@flamingspork.com-20101103032709-oyvfrc6eb8fzj0mr
fix docs warning: docs/unlock.rst:2: (WARNING/2) Title underline too short.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
#include "drizzled/optimizer/range.h"
24
24
 
 
25
#include <boost/dynamic_bitset.hpp>
25
26
#include <vector>
26
27
 
27
28
namespace drizzled
40
41
 */
41
42
class QuickRangeSelect : public QuickSelectInterface
42
43
{
 
44
protected:
 
45
  Cursor *cursor;
 
46
  DYNAMIC_ARRAY ranges; /**< ordered array of range ptrs */
 
47
 
 
48
  /** Members to deal with case when this quick select is a ROR-merged scan */
 
49
  bool in_ror_merged_scan;
 
50
  boost::dynamic_bitset<> *column_bitmap;
 
51
  boost::dynamic_bitset<> *save_read_set;
 
52
  boost::dynamic_bitset<> *save_write_set;
 
53
  bool free_file; /**< True when this->file is "owned" by this quick select */
 
54
 
 
55
  /* Range pointers to be used when not using MRR interface */
 
56
  QuickRange **cur_range; /**< current element in ranges  */
 
57
  QuickRange *last_range;
 
58
 
 
59
  /** Members needed to use the MRR interface */
 
60
  QuickRangeSequenceContext qr_traversal_ctx;
 
61
  uint32_t mrr_buf_size; /**< copy from session->variables.read_rnd_buff_size */
 
62
 
 
63
  /** Info about index we're scanning */
 
64
  KEY_PART *key_parts;
 
65
  KeyPartInfo *key_part_info;
 
66
 
 
67
  bool dont_free; /**< Used by QuickSelectDescending */
 
68
 
 
69
  /**
 
70
   * Compare if found key is over max-value
 
71
   * @return 0 if key <= range->max_key
 
72
   * @todo: Figure out why can't this function be as simple as cmp_prev().
 
73
   */
 
74
  int cmp_next(QuickRange *range);
 
75
 
 
76
  /**
 
77
   * @return 0 if found key is inside range (found key >= range->min_key).
 
78
   */
 
79
  int cmp_prev(QuickRange *range);
 
80
 
 
81
  /**
 
82
   * Check if current row will be retrieved by this QuickRangeSelect
 
83
   *
 
84
   * NOTES
 
85
   * It is assumed that currently a scan is being done on another index
 
86
   * which reads all necessary parts of the index that is scanned by this
 
87
   * quick select.
 
88
   * The implementation does a binary search on sorted array of disjoint
 
89
   * ranges, without taking size of range into account.
 
90
   *
 
91
   * This function is used to filter out clustered PK scan rows in
 
92
   * index_merge quick select.
 
93
   *
 
94
   * RETURN
 
95
   * @retval true  if current row will be retrieved by this quick select
 
96
   * false if not
 
97
   */
 
98
  bool row_in_ranges();
43
99
 
44
100
public:
45
101
 
51
107
                     Table *table,
52
108
                     uint32_t index_arg,
53
109
                     bool no_alloc,
54
 
                     memory::Root *parent_alloc,
55
 
                     bool *create_err);
 
110
                     memory::Root *parent_alloc);
56
111
 
57
112
  ~QuickRangeSelect();
58
113
 
67
122
   * QuickRangeSelect::get_next()
68
123
   *
69
124
   * NOTES
70
 
   * Record is read into table->record[0]
 
125
   * Record is read into table->getInsertRecord()
71
126
   *
72
127
   * RETURN
73
128
   * @retval 0                  Found row
157
212
    cursor= NULL;
158
213
  }
159
214
 
160
 
protected:
161
 
 
162
 
  Cursor *cursor;
163
 
  DYNAMIC_ARRAY ranges; /**< ordered array of range ptrs */
164
 
 
165
 
  /** Members to deal with case when this quick select is a ROR-merged scan */
166
 
  bool in_ror_merged_scan;
167
 
  MyBitmap column_bitmap;
168
 
  MyBitmap *save_read_set;
169
 
  MyBitmap *save_write_set;
170
 
  bool free_file; /**< True when this->file is "owned" by this quick select */
171
 
 
172
 
  /* Range pointers to be used when not using MRR interface */
173
 
  QuickRange **cur_range; /**< current element in ranges  */
174
 
  QuickRange *last_range;
175
 
 
176
 
  /** Members needed to use the MRR interface */
177
 
  QuickRangeSequenceContext qr_traversal_ctx;
178
 
  uint32_t mrr_buf_size; /**< copy from session->variables.read_rnd_buff_size */
179
 
  HANDLER_BUFFER *mrr_buf_desc; /**< the Cursor buffer */
180
 
 
181
 
  /** Info about index we're scanning */
182
 
  KEY_PART *key_parts;
183
 
  KEY_PART_INFO *key_part_info;
184
 
 
185
 
  bool dont_free; /**< Used by QuickSelectDescending */
186
 
 
187
 
  /**
188
 
   * Compare if found key is over max-value
189
 
   * @return 0 if key <= range->max_key
190
 
   * @todo: Figure out why can't this function be as simple as cmp_prev().
191
 
   */
192
 
  int cmp_next(QuickRange *range);
193
 
 
194
 
  /**
195
 
   * @return 0 if found key is inside range (found key >= range->min_key).
196
 
   */
197
 
  int cmp_prev(QuickRange *range);
198
 
 
199
 
  /**
200
 
   * Check if current row will be retrieved by this QuickRangeSelect
201
 
   *
202
 
   * NOTES
203
 
   * It is assumed that currently a scan is being done on another index
204
 
   * which reads all necessary parts of the index that is scanned by this
205
 
   * quick select.
206
 
   * The implementation does a binary search on sorted array of disjoint
207
 
   * ranges, without taking size of range into account.
208
 
   *
209
 
   * This function is used to filter out clustered PK scan rows in
210
 
   * index_merge quick select.
211
 
   *
212
 
   * RETURN
213
 
   * @retval true  if current row will be retrieved by this quick select
214
 
   * false if not
215
 
   */
216
 
  bool row_in_ranges();
217
 
 
218
215
private:
219
216
 
220
217
  /* Used only by QuickSelectDescending */
225
222
      Use default MRR implementation for reverse scans. No table engine
226
223
      currently can do an MRR scan with output in reverse index order.
227
224
    */
228
 
    mrr_buf_desc= NULL;
229
225
    mrr_flags|= HA_MRR_USE_DEFAULT_IMPL;
230
226
    mrr_buf_size= 0;
231
227
  }
266
262
                                          uint32_t n_ranges, 
267
263
                                          uint32_t flags);
268
264
 
269
 
  friend void select_describe(JOIN *join, 
 
265
  friend void select_describe(Join *join, 
270
266
                              bool need_tmp_table, 
271
267
                              bool need_order,
272
268
                              bool distinct,