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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
6a34ba31
Commit
6a34ba31
authored
8 years ago
by
Vicențiu Ciorbaru
Committed by
Vicențiu Ciorbaru
8 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Code cleanup] Refactor duplicate code within myisam and maria sort.cc
parent
bfef17be
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
73 deletions
+53
-73
storage/maria/ma_sort.c
storage/maria/ma_sort.c
+26
-36
storage/myisam/sort.c
storage/myisam/sort.c
+27
-37
No files found.
storage/maria/ma_sort.c
View file @
6a34ba31
...
...
@@ -86,6 +86,27 @@ static int write_merge_key_varlen(MARIA_SORT_PARAM *info,
static
inline
int
my_var_write
(
MARIA_SORT_PARAM
*
info
,
IO_CACHE
*
to_file
,
uchar
*
bufs
);
/*
Sets the appropriate read and write methods for the MARIA_SORT_PARAM
based on the variable length key flag.
*/
static
void
set_sort_param_read_write
(
MARIA_SORT_PARAM
*
sort_param
)
{
if
(
sort_param
->
keyinfo
->
flag
&
HA_VAR_LENGTH_KEY
)
{
sort_param
->
write_keys
=
write_keys_varlen
;
sort_param
->
read_to_buffer
=
read_to_buffer_varlen
;
sort_param
->
write_key
=
write_merge_key_varlen
;
}
else
{
sort_param
->
write_keys
=
write_keys
;
sort_param
->
read_to_buffer
=
read_to_buffer
;
sort_param
->
write_key
=
write_merge_key
;
}
}
/*
Creates a index of sorted keys
...
...
@@ -115,18 +136,7 @@ int _ma_create_index_by_sort(MARIA_SORT_PARAM *info, my_bool no_messages,
(
ulong
)
sortbuff_size
,
info
->
key_length
,
(
ulong
)
info
->
sort_info
->
max_records
));
if
(
info
->
keyinfo
->
flag
&
HA_VAR_LENGTH_KEY
)
{
info
->
write_keys
=
write_keys_varlen
;
info
->
read_to_buffer
=
read_to_buffer_varlen
;
info
->
write_key
=
write_merge_key_varlen
;
}
else
{
info
->
write_keys
=
write_keys
;
info
->
read_to_buffer
=
read_to_buffer
;
info
->
write_key
=
write_merge_key
;
}
set_sort_param_read_write
(
info
);
my_b_clear
(
&
tempfile
);
my_b_clear
(
&
tempfile_for_exceptions
);
...
...
@@ -347,18 +357,7 @@ pthread_handler_t _ma_thr_find_all_keys(void *arg)
if
(
sort_param
->
sort_info
->
got_error
)
goto
err
;
if
(
sort_param
->
keyinfo
->
flag
&
HA_VAR_LENGTH_KEY
)
{
sort_param
->
write_keys
=
write_keys_varlen
;
sort_param
->
read_to_buffer
=
read_to_buffer_varlen
;
sort_param
->
write_key
=
write_merge_key_varlen
;
}
else
{
sort_param
->
write_keys
=
write_keys
;
sort_param
->
read_to_buffer
=
read_to_buffer
;
sort_param
->
write_key
=
write_merge_key
;
}
set_sort_param_read_write
(
sort_param
);
my_b_clear
(
&
sort_param
->
tempfile
);
my_b_clear
(
&
sort_param
->
tempfile_for_exceptions
);
...
...
@@ -564,18 +563,9 @@ int _ma_thr_write_keys(MARIA_SORT_PARAM *sort_param)
{
if
(
got_error
)
continue
;
if
(
sinfo
->
keyinfo
->
flag
&
HA_VAR_LENGTH_KEY
)
{
sinfo
->
write_keys
=
write_keys_varlen
;
sinfo
->
read_to_buffer
=
read_to_buffer_varlen
;
sinfo
->
write_key
=
write_merge_key_varlen
;
}
else
{
sinfo
->
write_keys
=
write_keys
;
sinfo
->
read_to_buffer
=
read_to_buffer
;
sinfo
->
write_key
=
write_merge_key
;
}
set_sort_param_read_write
(
sinfo
);
if
(
sinfo
->
buffpek
.
elements
)
{
uint
maxbuffer
=
sinfo
->
buffpek
.
elements
-
1
;
...
...
This diff is collapsed.
Click to expand it.
storage/myisam/sort.c
View file @
6a34ba31
...
...
@@ -84,6 +84,28 @@ static int write_merge_key_varlen(MI_SORT_PARAM *info,
static
inline
int
my_var_write
(
MI_SORT_PARAM
*
info
,
IO_CACHE
*
to_file
,
uchar
*
bufs
);
/*
Sets the appropriate read and write methods for the MI_SORT_PARAM
based on the variable length key flag.
*/
static
void
set_sort_param_read_write
(
MI_SORT_PARAM
*
sort_param
)
{
if
(
sort_param
->
keyinfo
->
flag
&
HA_VAR_LENGTH_KEY
)
{
sort_param
->
write_keys
=
write_keys_varlen
;
sort_param
->
read_to_buffer
=
read_to_buffer_varlen
;
sort_param
->
write_key
=
write_merge_key_varlen
;
}
else
{
sort_param
->
write_keys
=
write_keys
;
sort_param
->
read_to_buffer
=
read_to_buffer
;
sort_param
->
write_key
=
write_merge_key
;
}
}
/*
Creates a index of sorted keys
...
...
@@ -111,18 +133,7 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages,
DBUG_ENTER
(
"_create_index_by_sort"
);
DBUG_PRINT
(
"enter"
,(
"sort_length: %d"
,
info
->
key_length
));
if
(
info
->
keyinfo
->
flag
&
HA_VAR_LENGTH_KEY
)
{
info
->
write_keys
=
write_keys_varlen
;
info
->
read_to_buffer
=
read_to_buffer_varlen
;
info
->
write_key
=
write_merge_key_varlen
;
}
else
{
info
->
write_keys
=
write_keys
;
info
->
read_to_buffer
=
read_to_buffer
;
info
->
write_key
=
write_merge_key
;
}
set_sort_param_read_write
(
info
);
my_b_clear
(
&
tempfile
);
my_b_clear
(
&
tempfile_for_exceptions
);
...
...
@@ -307,7 +318,6 @@ static ha_rows find_all_keys(MI_SORT_PARAM *info, uint keys,
DBUG_RETURN
((
*
maxbuffer
)
*
(
keys
-
1
)
+
idx
);
}
/* find_all_keys */
/* Search after all keys and place them in a temp. file */
pthread_handler_t
thr_find_all_keys
(
void
*
arg
)
...
...
@@ -332,18 +342,7 @@ pthread_handler_t thr_find_all_keys(void *arg)
if
(
sort_param
->
sort_info
->
got_error
)
goto
err
;
if
(
sort_param
->
keyinfo
->
flag
&
HA_VAR_LENGTH_KEY
)
{
sort_param
->
write_keys
=
write_keys_varlen
;
sort_param
->
read_to_buffer
=
read_to_buffer_varlen
;
sort_param
->
write_key
=
write_merge_key_varlen
;
}
else
{
sort_param
->
write_keys
=
write_keys
;
sort_param
->
read_to_buffer
=
read_to_buffer
;
sort_param
->
write_key
=
write_merge_key
;
}
set_sort_param_read_write
(
sort_param
);
my_b_clear
(
&
sort_param
->
tempfile
);
my_b_clear
(
&
sort_param
->
tempfile_for_exceptions
);
...
...
@@ -550,18 +549,9 @@ int thr_write_keys(MI_SORT_PARAM *sort_param)
{
if
(
got_error
)
continue
;
if
(
sinfo
->
keyinfo
->
flag
&
HA_VAR_LENGTH_KEY
)
{
sinfo
->
write_keys
=
write_keys_varlen
;
sinfo
->
read_to_buffer
=
read_to_buffer_varlen
;
sinfo
->
write_key
=
write_merge_key_varlen
;
}
else
{
sinfo
->
write_keys
=
write_keys
;
sinfo
->
read_to_buffer
=
read_to_buffer
;
sinfo
->
write_key
=
write_merge_key
;
}
set_sort_param_read_write
(
sinfo
);
if
(
sinfo
->
buffpek
.
elements
)
{
uint
maxbuffer
=
sinfo
->
buffpek
.
elements
-
1
;
...
...
This diff is collapsed.
Click to expand it.
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