Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
educg-net-25737-2462428
DB2024-HIT-2869
Commits
a77760b6
Commit
a77760b6
authored
11 months ago
by
lepsa
Browse files
Options
Download
Patches
Plain Diff
fix:explain sort
parent
8fdaab20
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/common/merge_sorter.h
+6
-5
src/common/merge_sorter.h
src/execution/execution_sort.h
+0
-2
src/execution/execution_sort.h
src/execution/executor_merge_join.h
+5
-4
src/execution/executor_merge_join.h
with
11 additions
and
11 deletions
+11
-11
src/common/merge_sorter.h
+
6
−
5
View file @
a77760b6
...
...
@@ -15,7 +15,7 @@
#include
<memory>
#include
"config.h"
#include
"system/sm_meta.h"
class
MergeSort
er
{
class
MergeSort
{
private:
ssize_t
max_mem_size
;
ssize_t
rcd_size
;
...
...
@@ -33,8 +33,9 @@ private:
bool
isFull
=
true
;
public
:
MergeSorter
(
ssize_t
rcd_size
,
void
*
arg
=
nullptr
)
:
rcd_size
(
rcd_size
),
arg_
(
arg
)
{}
MergeSort
(
ssize_t
rcd_size
,
void
*
arg
=
nullptr
)
:
rcd_size
(
rcd_size
),
arg_
(
arg
)
{}
MergeSort
()
=
default
;
void
beginSort
(
const
char
*
record
)
{
max_mem_size
=
(
MAX_MEMORY
-
MAX_MEMORY
%
rcd_size
);
...
...
@@ -66,13 +67,13 @@ public:
return
total_record
==
0
;
}
MergeSort
er
(
MergeSort
er
&&
sorter
)
noexcept
MergeSort
(
MergeSort
&&
sorter
)
noexcept
:
rcd_size
(
sorter
.
rcd_size
),
total_record
(
sorter
.
total_record
),
index
(
sorter
.
index
),
data
(
sorter
.
data
),
isFull
(
sorter
.
isFull
),
record_list
(
std
::
move
(
sorter
.
record_list
)),
heap
(
std
::
move
(
sorter
.
heap
)),
arg_
(
sorter
.
arg_
),
buffer_list
(
std
::
move
(
sorter
.
buffer_list
)),
opened_files
(
std
::
move
(
sorter
.
opened_files
)),
filenames_
(
std
::
move
(
sorter
.
filenames_
))
{}
~
MergeSort
er
()
{
~
MergeSort
()
{
for
(
size_t
i
=
0
;
i
<
opened_files
.
size
();
++
i
)
{
if
(
opened_files
[
i
].
is_open
())
{
opened_files
[
i
].
close
();
...
...
This diff is collapsed.
Click to expand it.
src/execution/execution_sort.h
+
0
−
2
View file @
a77760b6
...
...
@@ -10,7 +10,6 @@ See the Mulan PSL v2 for more details. */
#pragma once
#include
"common/config.h"
#include
"common/merge_sorter.h"
#include
"execution_defs.h"
#include
"execution_manager.h"
#include
"executor_abstract.h"
...
...
@@ -27,7 +26,6 @@ class SortExecutor : public AbstractExecutor {
ColMeta
cols_
;
// 框架中只支持一个键排序,需要自行修改数据结构支持多个键排序
std
::
unique_ptr
<
RmRecord
>
current_tuple
;
std
::
unique_ptr
<
MergeSorter
>
sorter
;
[[
maybe_unused
]]
bool
is_end_
=
false
;
std
::
vector
<
RmRecord
>
records_
;
...
...
This diff is collapsed.
Click to expand it.
src/execution/executor_merge_join.h
+
5
−
4
View file @
a77760b6
...
...
@@ -53,6 +53,7 @@ class MergeJoinExecutor : public AbstractExecutor {
if
(
use_index_
)
{
initializeExecutorsWithIndex
();
}
else
{
sleep
(
2
);
initializeExecutorsWithoutIndex
();
}
nextTuple
();
...
...
@@ -127,9 +128,9 @@ private:
right_
->
beginTuple
();
}
std
::
vector
<
MergeSorter
>
sorters_
;
std
::
vector
<
MergeSort
>
sorters_
;
MergeSort
L_sort
,
R_sort
;
void
initializeExecutorsWithoutIndex
()
{
sleep
(
2
);
sorters_
.
push_back
(
startSort
(
left_
,
left_col_
));
sorters_
.
push_back
(
startSort
(
right_
,
right_col_
));
}
...
...
@@ -249,9 +250,9 @@ private:
}
}
MergeSort
er
startSort
(
std
::
unique_ptr
<
AbstractExecutor
>
&
executor
,
const
ColMeta
&
joined_col
)
{
MergeSort
startSort
(
std
::
unique_ptr
<
AbstractExecutor
>
&
executor
,
const
ColMeta
&
joined_col
)
{
MergeSort
er
sorter
(
executor
->
tupleLen
(),
const_cast
<
void
*>
(
static_cast
<
const
void
*>
(
&
joined_col
)));
MergeSort
sorter
(
executor
->
tupleLen
(),
const_cast
<
void
*>
(
static_cast
<
const
void
*>
(
&
joined_col
)));
for
(
executor
->
beginTuple
();
!
executor
->
is_end
();
executor
->
nextTuple
())
{
sorter
.
beginSort
(
executor
->
Next
()
->
data
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets