Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
大炮V587
oceanbase
提交
15f8652a
O
oceanbase
项目概览
大炮V587
/
oceanbase
与 Fork 源项目一致
Fork自
oceanbase / oceanbase
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
oceanbase
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
15f8652a
编写于
2月 06, 2023
作者:
O
obdev
提交者:
ob-robot
2月 06, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix sort core at aqs item's len overflow
上级
4f65ea33
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
42 addition
and
30 deletion
+42
-30
src/sql/engine/sort/ob_sort_op.cpp
src/sql/engine/sort/ob_sort_op.cpp
+4
-2
src/sql/engine/sort/ob_sort_op_impl.cpp
src/sql/engine/sort/ob_sort_op_impl.cpp
+16
-6
src/sql/engine/sort/ob_sort_op_impl.h
src/sql/engine/sort/ob_sort_op_impl.h
+22
-22
未找到文件。
src/sql/engine/sort/ob_sort_op.cpp
浏览文件 @
15f8652a
...
...
@@ -411,8 +411,9 @@ int ObSortOp::init_prefix_sort(int64_t tenant_id,
}
else
{
read_func_
=
&
ObSortOp
::
prefix_sort_impl_next
;
}
int
aqs_head
=
MY_SPEC
.
enable_encode_sortkey_opt_
?
sizeof
(
oceanbase
::
sql
::
ObSortOpImpl
::
AQSItem
)
:
0
;
prefix_sort_impl_
.
set_input_rows
(
row_count
);
prefix_sort_impl_
.
set_input_width
(
MY_SPEC
.
width_
);
prefix_sort_impl_
.
set_input_width
(
MY_SPEC
.
width_
+
aqs_head
);
prefix_sort_impl_
.
set_operator_type
(
MY_SPEC
.
type_
);
prefix_sort_impl_
.
set_operator_id
(
MY_SPEC
.
id_
);
prefix_sort_impl_
.
set_io_event_observer
(
&
io_event_observer_
);
...
...
@@ -433,8 +434,9 @@ int ObSortOp::init_sort(int64_t tenant_id,
}
else
{
read_func_
=
&
ObSortOp
::
sort_impl_next
;
}
int
aqs_head
=
MY_SPEC
.
enable_encode_sortkey_opt_
?
sizeof
(
oceanbase
::
sql
::
ObSortOpImpl
::
AQSItem
)
:
0
;
sort_impl_
.
set_input_rows
(
row_count
);
sort_impl_
.
set_input_width
(
MY_SPEC
.
width_
);
sort_impl_
.
set_input_width
(
MY_SPEC
.
width_
+
aqs_head
);
sort_impl_
.
set_operator_type
(
MY_SPEC
.
type_
);
sort_impl_
.
set_operator_id
(
MY_SPEC
.
id_
);
sort_impl_
.
set_io_event_observer
(
&
io_event_observer_
);
...
...
src/sql/engine/sort/ob_sort_op_impl.cpp
浏览文件 @
15f8652a
...
...
@@ -26,10 +26,15 @@ namespace sql
/************************************* start ObSortOpImpl *********************************/
ObSortOpImpl
::
ObAdaptiveQS
::
ObAdaptiveQS
(
common
::
ObIArray
<
ObChunkDatumStore
::
StoredRow
*>
&
sort_rows
,
common
::
ObIAllocator
&
alloc
,
int64_t
rows_begin
,
int64_t
rows_end
,
bool
&
can_encode
)
common
::
ObIAllocator
&
alloc
)
:
orig_sort_rows_
(
sort_rows
),
alloc_
(
alloc
)
{
}
int
ObSortOpImpl
::
ObAdaptiveQS
::
init
(
common
::
ObIArray
<
ObChunkDatumStore
::
StoredRow
*>
&
sort_rows
,
common
::
ObIAllocator
&
alloc
,
int64_t
rows_begin
,
int64_t
rows_end
,
bool
&
can_encode
)
{
int
ret
=
OB_SUCCESS
;
can_encode
=
true
;
...
...
@@ -56,6 +61,7 @@ ObSortOpImpl::ObAdaptiveQS::ObAdaptiveQS(common::ObIArray<ObChunkDatumStore::Sto
if
(
item
.
len_
>
1
)
item
.
sub_cache_
[
1
]
=
item
.
key_ptr_
[
1
];
}
}
return
ret
;
}
/*
...
...
@@ -1352,8 +1358,10 @@ int ObSortOpImpl::do_partition_sort(common::ObIArray<ObChunkDatumStore::StoredRo
if
(
comp_
.
cmp_start_
!=
comp_
.
cmp_end_
)
{
if
(
enable_encode_sortkey_
)
{
bool
can_encode
=
true
;
ObAdaptiveQS
aqs
(
rows
,
allocator
,
rows_last
,
rows_idx
,
can_encode
);
if
(
can_encode
)
{
ObAdaptiveQS
aqs
(
rows
,
allocator
);
if
(
OB_FAIL
(
aqs
.
init
(
rows
,
allocator
,
rows_last
,
rows_idx
,
can_encode
)))
{
LOG_WARN
(
"failed to init aqs"
,
K
(
ret
));
}
else
if
(
can_encode
)
{
aqs
.
sort
(
rows_last
,
rows_idx
);
}
else
{
enable_encode_sortkey_
=
false
;
...
...
@@ -1631,8 +1639,10 @@ int ObSortOpImpl::sort_inmem_data()
do_partition_sort
(
*
rows_
,
begin
,
rows_
->
count
());
}
else
if
(
enable_encode_sortkey_
)
{
bool
can_encode
=
true
;
ObAdaptiveQS
aqs
(
*
rows_
,
mem_context_
->
get_malloc_allocator
(),
begin
,
rows_
->
count
(),
can_encode
);
if
(
can_encode
)
{
ObAdaptiveQS
aqs
(
*
rows_
,
mem_context_
->
get_malloc_allocator
());
if
(
OB_FAIL
(
aqs
.
init
(
*
rows_
,
mem_context_
->
get_malloc_allocator
(),
begin
,
rows_
->
count
(),
can_encode
)))
{
LOG_WARN
(
"failed to init aqs"
,
K
(
ret
));
}
else
if
(
can_encode
)
{
aqs
.
sort
(
begin
,
rows_
->
count
());
}
else
{
enable_encode_sortkey_
=
false
;
...
...
src/sql/engine/sort/ob_sort_op_impl.h
浏览文件 @
15f8652a
...
...
@@ -335,37 +335,23 @@ public:
Compare
&
compare_
;
};
protected:
class
MemEntifyFreeGuard
{
public:
explicit
MemEntifyFreeGuard
(
lib
::
MemoryContext
&
entify
)
:
entify_
(
entify
)
{}
~
MemEntifyFreeGuard
()
{
if
(
NULL
!=
entify_
)
{
DESTROY_CONTEXT
(
entify_
);
entify_
=
NULL
;
}
}
lib
::
MemoryContext
&
entify_
;
};
struct
AQSItem
{
short
len_
;
unsigned
char
sub_cache_
[
2
];
unsigned
char
*
key_ptr_
;
ObChunkDatumStore
::
StoredRow
*
row_ptr_
;
AQSItem
()
:
len_
(
0
),
sub_cache_
(),
key_ptr_
(
NULL
),
row_ptr_
(
NULL
)
uint32_t
len_
;
unsigned
char
sub_cache_
[
2
];
AQSItem
()
:
key_ptr_
(
NULL
),
row_ptr_
(
NULL
),
len_
(
0
),
sub_cache_
()
{
}
TO_STRING_KV
(
K_
(
len
),
K_
(
sub_cache
),
K_
(
key_ptr
),
KP
(
row_ptr_
));
};
class
ObAdaptiveQS
{
public:
ObAdaptiveQS
(
common
::
ObIArray
<
ObChunkDatumStore
::
StoredRow
*>
&
sort_rows
,
ObAdaptiveQS
(
common
::
ObIArray
<
ObChunkDatumStore
::
StoredRow
*>
&
sort_rows
,
common
::
ObIAllocator
&
alloc
);
int
init
(
common
::
ObIArray
<
ObChunkDatumStore
::
StoredRow
*>
&
sort_rows
,
common
::
ObIAllocator
&
alloc
,
int64_t
rows_begin
,
int64_t
rows_end
,
bool
&
can_encode
);
~
ObAdaptiveQS
()
{
reset
();
...
...
@@ -408,6 +394,20 @@ protected:
common
::
ObIAllocator
&
alloc_
;
};
protected:
class
MemEntifyFreeGuard
{
public:
explicit
MemEntifyFreeGuard
(
lib
::
MemoryContext
&
entify
)
:
entify_
(
entify
)
{}
~
MemEntifyFreeGuard
()
{
if
(
NULL
!=
entify_
)
{
DESTROY_CONTEXT
(
entify_
);
entify_
=
NULL
;
}
}
lib
::
MemoryContext
&
entify_
;
};
//Optimize mem usage/performance of top-n sort:
//https://aone.alibaba-inc.com/project/81079/issue/8572633
//Record buf_len of each allocated row. When old row pop-ed out of the heap
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录