#include <quick_range_select.h>
Public Types | |
enum | { QS_TYPE_RANGE = 0, QS_TYPE_INDEX_MERGE = 1, QS_TYPE_RANGE_DESC = 2, QS_TYPE_ROR_INTERSECT = 4, QS_TYPE_ROR_UNION = 5, QS_TYPE_GROUP_MIN_MAX = 6 } |
Public Member Functions | |
QuickRangeSelect (Session *session, Table *table, uint32_t index_arg, bool no_alloc, memory::Root *parent_alloc) | |
int | init () |
int | reset (void) |
int | get_next () |
void | range_end () |
int | get_next_prefix (uint32_t prefix_length, key_part_map keypart_map, unsigned char *cur_prefix) |
bool | reverse_sorted () const |
bool | unique_key_range () const |
int | init_ror_merged_scan (bool reuse_handler) |
void | save_last_pos () |
int | get_type () const |
void | add_keys_and_lengths (std::string *key_names, std::string *used_lengths) |
void | add_info_string (std::string *str) |
void | resetCursor () |
virtual bool | is_keys_used (const boost::dynamic_bitset<> &fields) |
Public Attributes | |
uint32_t | mrr_flags |
memory::Root | alloc |
bool | sorted |
ha_rows | records |
double | read_time |
Table * | head |
uint32_t | index |
uint32_t | max_used_key_length |
uint32_t | used_key_parts |
unsigned char * | last_rowid |
unsigned char * | record |
Protected Member Functions | |
int | cmp_next (QuickRange *range) |
int | cmp_prev (QuickRange *range) |
bool | row_in_ranges () |
Protected Attributes | |
Cursor * | cursor |
DYNAMIC_ARRAY | ranges |
bool | in_ror_merged_scan |
boost::dynamic_bitset * | column_bitmap |
boost::dynamic_bitset * | save_read_set |
boost::dynamic_bitset * | save_write_set |
bool | free_file |
QuickRange ** | cur_range |
QuickRange * | last_range |
QuickRangeSequenceContext | qr_traversal_ctx |
uint32_t | mrr_buf_size |
KEY_PART * | key_parts |
KeyPartInfo * | key_part_info |
bool | dont_free |
Private Member Functions | |
QuickRangeSelect (const QuickRangeSelect &org) |
Friends | |
class | ::drizzled::RorIntersectReadPlan |
class | QuickSelectDescending |
class | QuickIndexMergeSelect |
class | QuickRorIntersectSelect |
class | QuickGroupMinMaxSelect |
QuickRangeSelect * | get_quick_select_for_ref (Session *session, Table *table, struct table_reference_st *ref, ha_rows records) |
bool | get_quick_keys (Parameter *param, QuickRangeSelect *quick, KEY_PART *key, SEL_ARG *key_tree, unsigned char *min_key, uint32_t min_key_flag, unsigned char *max_key, uint32_t max_key_flag) |
QuickRangeSelect * | get_quick_select (Parameter *, uint32_t idx, SEL_ARG *key_tree, uint32_t mrr_flags, uint32_t mrr_buf_size, memory::Root *alloc) |
uint32_t | quick_range_seq_next (range_seq_t rseq, KEY_MULTI_RANGE *range) |
range_seq_t | quick_range_seq_init (void *init_param, uint32_t n_ranges, uint32_t flags) |
void | select_describe (Join *join, bool need_tmp_table, bool need_order, bool distinct, const char *message) |
Quick select that does a range scan on a single key.
The records are returned in key order.
Definition at line 37 of file quick_range_select.h.
|
virtual |
Append text representation of quick select structure (what and how is merged) to str. The result is added to "Extra" field in EXPLAIN output.
This function is implemented only by quick selects that merge other quick selects output and/or can produce output suitable for merging.
Reimplemented from drizzled::optimizer::QuickSelectInterface.
Definition at line 426 of file quick_range_select.cc.
Referenced by drizzled::optimizer::QuickIndexMergeSelect::add_info_string().
|
virtual |
Append comma-separated list of keys this quick select uses to key_names; append comma-separated list of corresponding used lengths to used_lengths.
Implements drizzled::optimizer::QuickSelectInterface.
Definition at line 433 of file quick_range_select.cc.
|
protected |
Compare if found key is over max-value
Definition at line 376 of file quick_range_select.cc.
References drizzled::store_length().
|
protected |
Definition at line 412 of file quick_range_select.cc.
References drizzled::key_cmp().
|
virtual |
Get next possible record using quick-struct.
SYNOPSIS QuickRangeSelect::get_next()
NOTES Record is read into table->getInsertRecord()
RETURN
0 | Found row |
HA_ERR_END_OF_FILE | No (more) rows in range # Error code |
Implements drizzled::optimizer::QuickSelectInterface.
Reimplemented in drizzled::optimizer::QuickSelectDescending.
Definition at line 271 of file quick_range_select.cc.
Referenced by drizzled::optimizer::QuickRorIntersectSelect::get_next(), and drizzled::optimizer::QuickIndexMergeSelect::read_keys_and_merge().
int drizzled::optimizer::QuickRangeSelect::get_next_prefix | ( | uint32_t | prefix_length, |
key_part_map | keypart_map, | ||
unsigned char * | cur_prefix | ||
) |
Get the next record with a different prefix.
SYNOPSIS QuickRangeSelect::get_next_prefix()
[in] | prefix_length | length of cur_prefix |
[in] | cur_prefix | prefix of a key to be searched for |
DESCRIPTION Each subsequent call to the method retrieves the first record that has a prefix with length prefix_length different from cur_prefix, such that the record with the new prefix is within the ranges described by this->ranges. The record found is stored into the buffer pointed by this->record. The method is useful for GROUP-BY queries with range conditions to discover the prefix of the next group that satisfies the range conditions.
RETURN
0 | on success |
HA_ERR_END_OF_FILE | if returned all keys |
other | if some error occurred |
Definition at line 294 of file quick_range_select.cc.
Referenced by drizzled::optimizer::QuickGroupMinMaxSelect::next_prefix().
|
inlinevirtual |
Returns the type of this quick select - one of the QS_TYPE_* values
Implements drizzled::optimizer::QuickSelectInterface.
Reimplemented in drizzled::optimizer::QuickSelectDescending.
Definition at line 196 of file quick_range_select.h.
|
virtual |
Do post-constructor initialization.
Performs initializations that should have been in constructor if it was possible to return errors from constructors. The join optimizer may create and then delete quick selects without retrieving any rows so init() must not contain any IO or CPU intensive code.
If init() call fails the only valid action is to delete this quick select, reset() and get_next() must not be called.
0 | OK |
other | Error code |
Implements drizzled::optimizer::QuickSelectInterface.
Definition at line 89 of file quick_range_select.cc.
Referenced by drizzled::optimizer::QuickIndexMergeSelect::read_keys_and_merge().
|
virtual |
Initialize this quick select to be a ROR-merged scan.
SYNOPSIS QuickRangeSelect::init_ror_merged_scan()
[in] | reuse_handler | If true, use head->cursor, otherwise create a separate Cursor object |
NOTES This function creates and prepares for subsequent use a separate Cursor object if it can't reuse head->cursor. The reason for this is that during ROR-merge several key scans are performed simultaneously, and a single Cursor is only capable of preserving context of a single key scan.
In ROR-merge the quick select doing merge does full records retrieval, merged quick selects read only keys.
RETURN 0 ROR child scan initialized, ok to use.
1 | error |
Reimplemented from drizzled::optimizer::QuickSelectInterface.
Definition at line 132 of file quick_range_select.cc.
References drizzled::Session::mem_root.
Referenced by drizzled::optimizer::QuickRorIntersectSelect::init_ror_merged_scan().
|
virtualinherited |
Returns true if any index used by this quick select uses field which is marked in passed bitmap.
Reimplemented in drizzled::optimizer::QuickIndexMergeSelect, drizzled::optimizer::QuickRorIntersectSelect, and drizzled::optimizer::QuickRorUnionSelect.
Definition at line 4125 of file range.cc.
Referenced by drizzled::optimizer::QuickRorUnionSelect::is_keys_used(), and drizzled::update_query().
|
virtual |
Range end should be called when we have looped over the whole index
Reimplemented from drizzled::optimizer::QuickSelectInterface.
Definition at line 97 of file quick_range_select.cc.
Referenced by drizzled::optimizer::QuickIndexMergeSelect::read_keys_and_merge().
|
virtual |
Initializes quick select for row retrieval.
Should be called when it is certain that row retrieval will be necessary. This call may do heavyweight initialization like buffering first N records etc. If reset() call fails get_next() must not be called. Note that reset() may be called several times if
0 | OK |
other | Error code |
Implements drizzled::optimizer::QuickSelectInterface.
Definition at line 237 of file quick_range_select.cc.
Referenced by drizzled::optimizer::QuickIndexMergeSelect::read_keys_and_merge(), drizzled::optimizer::QuickRorIntersectSelect::reset(), and drizzled::optimizer::QuickGroupMinMaxSelect::reset().
|
protected |
Check if current row will be retrieved by this QuickRangeSelect
NOTES It is assumed that currently a scan is being done on another index which reads all necessary parts of the index that is scanned by this quick select. The implementation does a binary search on sorted array of disjoint ranges, without taking size of range into account.
This function is used to filter out clustered PK scan rows in index_merge quick select.
RETURN
true | if current row will be retrieved by this quick select false if not |
Definition at line 353 of file quick_range_select.cc.
|
virtual |
Save ROWID of last retrieved row in file->ref. This used in ROR-merging.
Reimplemented from drizzled::optimizer::QuickSelectInterface.
Definition at line 215 of file quick_range_select.cc.
|
virtual |
Reimplemented from drizzled::optimizer::QuickSelectInterface.
Definition at line 221 of file quick_range_select.cc.
|
protected |
current element in ranges
Definition at line 51 of file quick_range_select.h.
|
protected |
Used by QuickSelectDescending
Definition at line 62 of file quick_range_select.h.
|
protected |
True when this->file is "owned" by this quick select
Definition at line 48 of file quick_range_select.h.
|
protected |
Members to deal with case when this quick select is a ROR-merged scan
Definition at line 44 of file quick_range_select.h.
|
inherited |
Index this quick select uses, or MAX_KEY for quick selects that use several indexes
Definition at line 106 of file range.h.
Referenced by drizzled::optimizer::QuickRorIntersectSelect::add_info_string(), drizzled::optimizer::QuickRorIntersectSelect::add_keys_and_lengths(), drizzled::optimizer::QuickIndexMergeSelect::add_keys_and_lengths(), drizzled::best_access_path(), drizzled::optimizer::Scan::getStats(), drizzled::optimizer::QuickRorIntersectSelect::is_keys_used(), drizzled::optimizer::QuickIndexMergeSelect::is_keys_used(), drizzled::optimizer::QuickGroupMinMaxSelect::reset(), drizzled::test_if_skip_sort_order(), and drizzled::update_query().
|
protected |
Info about index we're scanning
Definition at line 59 of file quick_range_select.h.
|
inherited |
The rowid of last row retrieved by this quick select. This is used only when doing ROR-index_merge selects
Definition at line 124 of file range.h.
Referenced by drizzled::optimizer::QuickRorUnionSelect::get_next().
|
inherited |
Total length of first used_key_parts parts of the key. Applicable if index!= MAX_KEY.
Definition at line 111 of file range.h.
Referenced by drizzled::optimizer::QuickRorIntersectSelect::add_keys_and_lengths(), drizzled::optimizer::QuickIndexMergeSelect::add_keys_and_lengths(), drizzled::optimizer::QuickGroupMinMaxSelect::add_keys_and_lengths(), drizzled::optimizer::QuickGroupMinMaxSelect::adjust_prefix_ranges(), and drizzled::optimizer::QuickGroupMinMaxSelect::update_key_stat().
|
protected |
copy from session->variables.read_rnd_buff_size
Definition at line 56 of file quick_range_select.h.
uint32_t drizzled::optimizer::QuickRangeSelect::mrr_flags |
Flags to be used with MRR interface
Definition at line 97 of file quick_range_select.h.
|
protected |
Members needed to use the MRR interface
Definition at line 55 of file quick_range_select.h.
|
protected |
ordered array of range ptrs
Definition at line 41 of file quick_range_select.h.
Referenced by drizzled::optimizer::QuickGroupMinMaxSelect::adjust_prefix_ranges().
|
inherited |
time to perform this retrieval
Definition at line 100 of file range.h.
Referenced by drizzled::best_access_path(), and drizzled::make_join_statistics().
|
inherited |
Table record buffer used by this quick select.
Definition at line 129 of file range.h.
Referenced by drizzled::optimizer::QuickRorUnionSelect::get_next(), drizzled::optimizer::QuickRorIntersectSelect::get_next(), and drizzled::optimizer::QuickIndexMergeSelect::read_keys_and_merge().
|
inherited |
estimate of # of records to be retrieved
Definition at line 99 of file range.h.
Referenced by drizzled::FileSort::run().
|
inherited |
Maximum number of (first) key parts this quick select uses for retrieval. eg. for "(key1p1=c1 AND key1p2=c2) OR key1p1=c2" used_key_parts == 2. Applicable if index!= MAX_KEY.
For QUICK_GROUP_MIN_MAX_SELECT it includes MIN/MAX argument keyparts.
Definition at line 119 of file range.h.
Referenced by drizzled::test_if_skip_sort_order(), and drizzled::optimizer::QuickGroupMinMaxSelect::update_key_stat().