~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to drizzled/optimizer/quick_range_select.h

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-10-02 14:17:48 UTC
  • mfrom: (1.1.1 upstream)
  • mto: (2.1.17 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20101002141748-m6vbfbfjhrw1153e
Tags: 2010.09.1802-1
* New upstream release.
* Removed pid-file argument hack.
* Updated GPL-2 address to be new address.
* Directly copy in drizzledump.1 since debian doesn't have sphinx 1.0 yet.
* Link to jquery from libjs-jquery. Add it as a depend.
* Add drizzled.8 symlink to the install files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
 */
41
41
class QuickRangeSelect : public QuickSelectInterface
42
42
{
 
43
protected:
 
44
  Cursor *cursor;
 
45
  DYNAMIC_ARRAY ranges; /**< ordered array of range ptrs */
 
46
 
 
47
  /** Members to deal with case when this quick select is a ROR-merged scan */
 
48
  bool in_ror_merged_scan;
 
49
  MyBitmap column_bitmap;
 
50
  MyBitmap *save_read_set;
 
51
  MyBitmap *save_write_set;
 
52
  bool free_file; /**< True when this->file is "owned" by this quick select */
 
53
 
 
54
  /* Range pointers to be used when not using MRR interface */
 
55
  QuickRange **cur_range; /**< current element in ranges  */
 
56
  QuickRange *last_range;
 
57
 
 
58
  /** Members needed to use the MRR interface */
 
59
  QuickRangeSequenceContext qr_traversal_ctx;
 
60
  uint32_t mrr_buf_size; /**< copy from session->variables.read_rnd_buff_size */
 
61
 
 
62
  /** Info about index we're scanning */
 
63
  KEY_PART *key_parts;
 
64
  KeyPartInfo *key_part_info;
 
65
 
 
66
  bool dont_free; /**< Used by QuickSelectDescending */
 
67
 
 
68
  /**
 
69
   * Compare if found key is over max-value
 
70
   * @return 0 if key <= range->max_key
 
71
   * @todo: Figure out why can't this function be as simple as cmp_prev().
 
72
   */
 
73
  int cmp_next(QuickRange *range);
 
74
 
 
75
  /**
 
76
   * @return 0 if found key is inside range (found key >= range->min_key).
 
77
   */
 
78
  int cmp_prev(QuickRange *range);
 
79
 
 
80
  /**
 
81
   * Check if current row will be retrieved by this QuickRangeSelect
 
82
   *
 
83
   * NOTES
 
84
   * It is assumed that currently a scan is being done on another index
 
85
   * which reads all necessary parts of the index that is scanned by this
 
86
   * quick select.
 
87
   * The implementation does a binary search on sorted array of disjoint
 
88
   * ranges, without taking size of range into account.
 
89
   *
 
90
   * This function is used to filter out clustered PK scan rows in
 
91
   * index_merge quick select.
 
92
   *
 
93
   * RETURN
 
94
   * @retval true  if current row will be retrieved by this quick select
 
95
   * false if not
 
96
   */
 
97
  bool row_in_ranges();
43
98
 
44
99
public:
45
100
 
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,