Commit 8dc612e6 authored by Sergey Petrunya's avatar Sergey Petrunya

MWL#121-125 DS-MRR improvements

 - Address Monty's review feedback, portion 3
parent 3e633eea
......@@ -414,8 +414,6 @@ void Mrr_ordered_index_reader::resume_read()
int Mrr_ordered_index_reader::refill_buffer(bool initial)
{
KEY_MULTI_RANGE cur_range;
uchar **range_info_ptr= (uchar**)&cur_range.ptr;
uchar *key_ptr;
DBUG_ENTER("Mrr_ordered_index_reader::refill_buffer");
DBUG_ASSERT(key_buffer->is_empty());
......@@ -425,9 +423,8 @@ int Mrr_ordered_index_reader::refill_buffer(bool initial)
buf_manager->reset_buffer_sizes(buf_manager->arg);
key_buffer->reset();
key_buffer->setup_writing(&key_ptr, keypar.key_size_in_keybuf,
is_mrr_assoc? (uchar**)&range_info_ptr : NULL,
is_mrr_assoc? sizeof(uchar*):0);
key_buffer->setup_writing(keypar.key_size_in_keybuf,
is_mrr_assoc? sizeof(char*) : 0);
while (key_buffer->can_write() &&
!(source_exhausted= mrr_funcs.next(mrr_iter, &cur_range)))
......@@ -435,9 +432,10 @@ int Mrr_ordered_index_reader::refill_buffer(bool initial)
DBUG_ASSERT(cur_range.range_flag & EQ_RANGE);
/* Put key, or {key, range_id} pair into the buffer */
key_ptr= (keypar.use_key_pointers)? (uchar*)&cur_range.start_key.key :
(uchar*)cur_range.start_key.key;
key_buffer->write_ptr1= keypar.use_key_pointers ?
(uchar*)&cur_range.start_key.key :
(uchar*)cur_range.start_key.key;
key_buffer->write_ptr2= (uchar*)&cur_range.ptr;
key_buffer->write();
}
......@@ -591,16 +589,14 @@ void Mrr_index_reader::position()
int Mrr_ordered_rndpos_reader::refill_from_index_reader()
{
char *range_info;
uchar **range_info_ptr= (uchar**)&range_info;
int res;
DBUG_ENTER("Mrr_ordered_rndpos_reader::refill_from_index_reader");
DBUG_ASSERT(rowid_buffer->is_empty());
index_rowid= index_reader->get_rowid_ptr();
rowid_buffer->reset();
rowid_buffer->setup_writing(&index_rowid, file->ref_length,
is_mrr_assoc? (uchar**)&range_info_ptr: NULL,
is_mrr_assoc? sizeof(char*):0);
rowid_buffer->setup_writing(file->ref_length,
is_mrr_assoc? sizeof(char*) : 0);
last_identical_rowid= NULL;
......@@ -620,6 +616,8 @@ int Mrr_ordered_rndpos_reader::refill_from_index_reader()
index_reader->position();
/* Put rowid, or {rowid, range_id} pair into the buffer */
rowid_buffer->write_ptr1= index_rowid;
rowid_buffer->write_ptr2= (uchar*)&range_info;
rowid_buffer->write();
}
......
......@@ -28,18 +28,18 @@ class Backward_lifo_buffer;
class Lifo_buffer
{
protected:
/**
Pointers to data to be written. write() call will assume that
(*write_ptr1) points to size1 bytes of data to be written.
If write_ptr2 != NULL then the buffer stores pairs, and (*write_ptr2)
points to size2 bytes of data that form the second component.
*/
uchar **write_ptr1;
size_t size1;
uchar **write_ptr2;
size_t size2;
public:
/**
write() will put into buffer size1 bytes pointed by write_ptr1. If
size2!=0, then they will be accompanied by size2 bytes pointed by
write_ptr2.
*/
uchar *write_ptr1;
uchar *write_ptr2;
/**
read() will do reading by storing pointers to read data into read_ptr1 or
into (read_ptr1, read_ptr2), depending on whether the buffer was set to
......@@ -75,11 +75,9 @@ public:
Specify where write() should get the source data from, as well as source
data size.
*/
void setup_writing(uchar **data1, size_t len1, uchar **data2, size_t len2)
void setup_writing(size_t len1, size_t len2)
{
write_ptr1= data1;
size1= len1;
write_ptr2= data2;
size2= len2;
}
......@@ -95,7 +93,7 @@ public:
bool can_write()
{
return have_space_for(size1 + (write_ptr2 ? size2 : 0));
return have_space_for(size1 + size2);
}
virtual void write() = 0;
......@@ -104,7 +102,7 @@ public:
void sort(qsort2_cmp cmp_func, void *cmp_func_arg)
{
uint elem_size= size1 + (write_ptr2 ? size2 : 0);
uint elem_size= size1 + size2;
uint n_elements= used_size() / elem_size;
my_qsort2(used_area(), n_elements, elem_size, cmp_func, cmp_func_arg);
}
......@@ -164,9 +162,9 @@ public:
void write()
{
write_bytes(*write_ptr1, size1);
if (write_ptr2)
write_bytes(*write_ptr2, size2);
write_bytes(write_ptr1, size1);
if (size2)
write_bytes(write_ptr2, size2);
}
void write_bytes(const uchar *data, size_t bytes)
{
......@@ -257,8 +255,8 @@ public:
void write()
{
if (write_ptr2)
write_bytes(*write_ptr2, size2);
write_bytes(*write_ptr1, size1);
write_bytes(write_ptr2, size2);
write_bytes(write_ptr1, size1);
}
void write_bytes(const uchar *data, size_t bytes)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment