Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
8d07c16a
Commit
8d07c16a
authored
Aug 12, 2010
by
Sergey Petrunya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do dynamic buffer growing/shrinking.
parent
8dc81f47
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
8 deletions
+76
-8
sql/multi_range_read.cc
sql/multi_range_read.cc
+32
-7
sql/multi_range_read.h
sql/multi_range_read.h
+44
-1
No files found.
sql/multi_range_read.cc
View file @
8d07c16a
...
...
@@ -792,7 +792,7 @@ void DsMrr_impl::setup_buffer_sizes(key_range *sample_key)
((
double
)
rowid_buf_elem_size
/
((
double
)
rowid_buf_elem_size
+
key_buff_elem_size
));
uin
t
bytes_for_rowids
=
size_
t
bytes_for_rowids
=
round
(
fraction_for_rowids
*
(
full_buf_end
-
full_buf
));
uint
bytes_for_keys
=
(
full_buf_end
-
full_buf
)
-
bytes_for_rowids
;
...
...
@@ -805,10 +805,10 @@ void DsMrr_impl::setup_buffer_sizes(key_range *sample_key)
(
h
->
ref_length
+
(
int
)
is_mrr_assoc
*
sizeof
(
char
*
)
+
1
));
}
//rowid_buffer.set_buffer_space(full_buf, full_buf + bytes_for_rowids, 1)
;
//key_buffer.set_buffer_space(full_buf + bytes_for_rowids, full_buf
_end, 1);
rowid_buffer
.
set_buffer_space
(
full_buf
,
full_buf
+
bytes_for_rowids
,
1
);
key_buffer
.
set_buffer_space
(
full_buf
+
bytes_for_rowids
,
full_buf_end
,
-
1
);
rowid_buffer_end
=
full_buf
+
bytes_for_rowids
;
rowid_buffer
.
set_buffer_space
(
full_buf
,
rowid_buffer
_end
,
1
);
key_buffer
.
set_buffer_space
(
rowid_buffer_end
,
full_buf_end
,
-
1
);
index_ranges_unique
=
test
(
key_info
->
flags
&
HA_NOSAME
&&
key_info
->
key_parts
==
...
...
@@ -838,7 +838,15 @@ void DsMrr_impl::dsmrr_fill_key_buffer()
// reset the buffer for writing.
if
(
key_tuple_length
)
{
if
(
do_rowid_fetch
)
{
/* Restore original buffer sizes */
rowid_buffer
.
set_buffer_space
(
full_buf
,
rowid_buffer_end
,
1
);
key_buffer
.
set_buffer_space
(
rowid_buffer_end
,
full_buf_end
,
-
1
);
}
key_buffer
.
reset_for_writing
();
}
while
((
key_tuple_length
==
0
||
key_buffer
.
have_space_for
(
key_buff_elem_size
))
&&
...
...
@@ -912,7 +920,6 @@ int DsMrr_impl::dsmrr_next_from_index(char **range_info_arg)
while
(
in_identical_keys_range
)
{
//read_and_check:
/* Read record/key pointer from the buffer */
key_in_buf
=
identical_key_it
.
get_next
(
key_size_in_keybuf
);
if
(
is_mrr_assoc
)
...
...
@@ -980,6 +987,11 @@ check_record:
}
/* First, make sure we have a range at start of the buffer */
//psergey-todo: why would we re-fill it here in the case when
// we're doing rowid retrieval?
// - need to check if this is really happening.
if
(
!
key_buffer
.
have_data
(
key_buff_elem_size
))
{
if
(
dsmrr_eof
)
...
...
@@ -995,6 +1007,18 @@ check_record:
}
}
if
(
do_rowid_fetch
)
{
/*
At this point we're not using anything beyond what we've read from key
buffer. Shrik the key buffer and grow the rowid buffer.
*/
uchar
*
unused_start
;
uchar
*
unused_end
;
key_buffer
.
remove_unused_space
(
&
unused_start
,
&
unused_end
);
rowid_buffer
.
grow
(
unused_start
,
unused_end
);
}
/* Get the next range to scan*/
cur_index_tuple
=
key_in_buf
=
key_buffer
.
read
(
key_size_in_keybuf
);
if
(
use_key_pointers
)
...
...
@@ -1003,6 +1027,7 @@ check_record:
if
(
is_mrr_assoc
)
cur_range_info
=
(
char
*
)
key_buffer
.
read
(
sizeof
(
void
*
));
/* Do index lookup */
if
((
res
=
file
->
ha_index_read_map
(
table
->
record
[
0
],
cur_index_tuple
,
key_tuple_map
,
HA_READ_KEY_EXACT
)))
...
...
sql/multi_range_read.h
View file @
8d07c16a
...
...
@@ -92,6 +92,46 @@ public:
reset_for_writing
();
}
/*
Stop/return the unneded space (the one that we have wrote to and have read
from.
*/
void
remove_unused_space
(
uchar
**
unused_start
,
uchar
**
unused_end
)
{
if
(
direction
==
1
)
{
*
unused_start
=
start
;
*
unused_end
=
read_pos
;
}
else
{
*
unused_start
=
read_pos
;
*
unused_end
=
end
;
}
}
void
grow
(
uchar
*
unused_start
,
uchar
*
unused_end
)
{
/*
Passed memory area can be meaningfully used for growing the buffer if:
- it is adjacent to buffer space we're using
- it is on the end towards which we grow.
*/
if
(
direction
==
1
&&
end
==
unused_start
)
{
end
=
unused_end
;
}
else
if
(
direction
==
-
1
&&
start
==
unused_end
)
{
start
=
unused_start
;
}
else
DBUG_ASSERT
(
0
);
/* Attempt to grow buffer in wrong direction */
}
/* */
void
grow
();
friend
class
PeekIterator
;
class
PeekIterator
{
...
...
@@ -203,6 +243,9 @@ private:
uchar
*
full_buf
;
uchar
*
full_buf_end
;
/* Valid when using both rowid and key buffer: the original bound between them */
uchar
*
rowid_buffer_end
;
/* Buffer to store rowids, or (rowid, range_id) pairs */
SimpleBuffer
rowid_buffer
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment