Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ba2b4042
T
TDengine
项目概览
taosdata
/
TDengine
11 个月 前同步成功
通知
1179
Star
22014
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ba2b4042
编写于
7月 17, 2023
作者:
S
slzhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enhance: optimize msortComparFn for table merge scan
上级
1b9754f1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
63 addition
and
38 deletion
+63
-38
source/libs/executor/inc/tsort.h
source/libs/executor/inc/tsort.h
+6
-0
source/libs/executor/src/tsort.c
source/libs/executor/src/tsort.c
+57
-38
未找到文件。
source/libs/executor/inc/tsort.h
浏览文件 @
ba2b4042
...
...
@@ -54,6 +54,12 @@ typedef struct SMsortComparParam {
int32_t
numOfSources
;
SArray
*
orderInfo
;
// SArray<SBlockOrderInfo>
bool
cmpGroupId
;
int32_t
sortType
;
// the following field to speed up when sortType == SORT_TABLE_MERGE_SCAN
int32_t
tsSlotId
;
int32_t
order
;
__compar_fn_t
cmpFn
;
}
SMsortComparParam
;
typedef
struct
SSortHandle
SSortHandle
;
...
...
source/libs/executor/src/tsort.c
浏览文件 @
ba2b4042
...
...
@@ -197,7 +197,13 @@ SSortHandle* tsortCreateSortHandle(SArray* pSortInfo, int32_t type, int32_t page
pSortHandle
->
pOrderedSource
=
taosArrayInit
(
4
,
POINTER_BYTES
);
pSortHandle
->
cmpParam
.
orderInfo
=
pSortInfo
;
pSortHandle
->
cmpParam
.
cmpGroupId
=
false
;
pSortHandle
->
cmpParam
.
sortType
=
type
;
if
(
type
==
SORT_TABLE_MERGE_SCAN
)
{
SBlockOrderInfo
*
pOrder
=
TARRAY_GET_ELEM
(
pSortInfo
,
0
);
pSortHandle
->
cmpParam
.
tsSlotId
=
pOrder
->
slotId
;
pSortHandle
->
cmpParam
.
order
=
pOrder
->
order
;
pSortHandle
->
cmpParam
.
cmpFn
=
(
pOrder
->
order
==
TSDB_ORDER_ASC
)
?
compareInt64Val
:
compareInt64ValDesc
;
}
tsortSetComparFp
(
pSortHandle
,
msortComparFn
);
if
(
idstr
!=
NULL
)
{
...
...
@@ -489,6 +495,8 @@ static int32_t adjustMergeTreeForNextTuple(SSortSource* pSource, SMultiwayMergeT
}
releaseBufPage
(
pHandle
->
pBuf
,
pPage
);
if
(
pSource
->
pageIndex
%
256
==
0
)
uInfo
(
"got block from page %d from ext mem source %p"
,
pSource
->
pageIndex
,
pSource
);
}
}
else
{
int64_t
st
=
taosGetTimestampUs
();
...
...
@@ -498,6 +506,7 @@ static int32_t adjustMergeTreeForNextTuple(SSortSource* pSource, SMultiwayMergeT
if
(
pSource
->
src
.
pBlock
==
NULL
)
{
(
*
numOfCompleted
)
+=
1
;
pSource
->
src
.
rowIndex
=
-
1
;
uInfo
(
"adjust merge tree. %d source completed"
,
*
numOfCompleted
);
}
}
}
...
...
@@ -578,53 +587,63 @@ int32_t msortComparFn(const void* pLeft, const void* pRight, void* param) {
}
}
for
(
int32_t
i
=
0
;
i
<
pInfo
->
size
;
++
i
)
{
SBlockOrderInfo
*
pOrder
=
TARRAY_GET_ELEM
(
pInfo
,
i
);
SColumnInfoData
*
pLeftColInfoData
=
TARRAY_GET_ELEM
(
pLeftBlock
->
pDataBlock
,
pOrder
->
slotId
);
if
(
pParam
->
sortType
==
SORT_TABLE_MERGE_SCAN
)
{
SColumnInfoData
*
pLeftColInfoData
=
TARRAY_GET_ELEM
(
pLeftBlock
->
pDataBlock
,
pParam
->
tsSlotId
);
SColumnInfoData
*
pRightColInfoData
=
TARRAY_GET_ELEM
(
pRightBlock
->
pDataBlock
,
pParam
->
tsSlotId
);
int64_t
*
left1
=
(
int64_t
*
)(
pLeftColInfoData
->
pData
)
+
pLeftSource
->
src
.
rowIndex
;
int64_t
*
right1
=
(
int64_t
*
)(
pRightColInfoData
->
pData
)
+
pRightSource
->
src
.
rowIndex
;
bool
leftNull
=
false
;
if
(
pLeftColInfoData
->
hasNull
)
{
if
(
pLeftBlock
->
pBlockAgg
==
NULL
)
{
leftNull
=
colDataIsNull_s
(
pLeftColInfoData
,
pLeftSource
->
src
.
rowIndex
);
}
else
{
leftNull
=
colDataIsNull
(
pLeftColInfoData
,
pLeftBlock
->
info
.
rows
,
pLeftSource
->
src
.
rowIndex
,
pLeftBlock
->
pBlockAgg
[
i
]);
int
ret
=
pParam
->
cmpFn
(
left1
,
right1
);
return
ret
;
}
else
{
for
(
int32_t
i
=
0
;
i
<
pInfo
->
size
;
++
i
)
{
SBlockOrderInfo
*
pOrder
=
TARRAY_GET_ELEM
(
pInfo
,
i
);
SColumnInfoData
*
pLeftColInfoData
=
TARRAY_GET_ELEM
(
pLeftBlock
->
pDataBlock
,
pOrder
->
slotId
);
SColumnInfoData
*
pRightColInfoData
=
TARRAY_GET_ELEM
(
pRightBlock
->
pDataBlock
,
pOrder
->
slotId
);
bool
leftNull
=
false
;
if
(
pLeftColInfoData
->
hasNull
)
{
if
(
pLeftBlock
->
pBlockAgg
==
NULL
)
{
leftNull
=
colDataIsNull_s
(
pLeftColInfoData
,
pLeftSource
->
src
.
rowIndex
);
}
else
{
leftNull
=
colDataIsNull
(
pLeftColInfoData
,
pLeftBlock
->
info
.
rows
,
pLeftSource
->
src
.
rowIndex
,
pLeftBlock
->
pBlockAgg
[
i
]);
}
}
}
SColumnInfoData
*
pRightColInfoData
=
TARRAY_GET_ELEM
(
pRightBlock
->
pDataBlock
,
pOrder
->
slotId
)
;
bool
rightNull
=
false
;
if
(
pRightColInfoData
->
hasNull
)
{
if
(
pRightBlock
->
pBlockAgg
==
NULL
)
{
rightNull
=
colDataIsNull_s
(
pRightColInfoData
,
pRightSource
->
src
.
rowIndex
);
}
else
{
rightNull
=
colDataIsNull
(
pRightColInfoData
,
pRightBlock
->
info
.
rows
,
pRightSource
->
src
.
rowIndex
,
pRightBlock
->
pBlockAgg
[
i
]);
bool
rightNull
=
false
;
if
(
pRightColInfoData
->
hasNull
)
{
if
(
pRightBlock
->
pBlockAgg
==
NULL
)
{
rightNull
=
colDataIsNull_s
(
pRightColInfoData
,
pRightSource
->
src
.
rowIndex
);
}
else
{
rightNull
=
colDataIsNull
(
pRightColInfoData
,
pRightBlock
->
info
.
rows
,
pRightSource
->
src
.
rowIndex
,
pRightBlock
->
pBlockAgg
[
i
]);
}
}
}
if
(
leftNull
&&
rightNull
)
{
continue
;
// continue to next slot
}
if
(
leftNull
&&
rightNull
)
{
continue
;
// continue to next slot
}
if
(
rightNull
)
{
return
pOrder
->
nullFirst
?
1
:
-
1
;
}
if
(
rightNull
)
{
return
pOrder
->
nullFirst
?
1
:
-
1
;
}
if
(
leftNull
)
{
return
pOrder
->
nullFirst
?
-
1
:
1
;
}
if
(
leftNull
)
{
return
pOrder
->
nullFirst
?
-
1
:
1
;
}
void
*
left1
=
colDataGetData
(
pLeftColInfoData
,
pLeftSource
->
src
.
rowIndex
);
void
*
right1
=
colDataGetData
(
pRightColInfoData
,
pRightSource
->
src
.
rowIndex
);
void
*
left1
=
colDataGetData
(
pLeftColInfoData
,
pLeftSource
->
src
.
rowIndex
);
void
*
right1
=
colDataGetData
(
pRightColInfoData
,
pRightSource
->
src
.
rowIndex
);
__compar_fn_t
fn
=
getKeyComparFunc
(
pLeftColInfoData
->
info
.
type
,
pOrder
->
order
);
__compar_fn_t
fn
=
getKeyComparFunc
(
pLeftColInfoData
->
info
.
type
,
pOrder
->
order
);
int
ret
=
fn
(
left1
,
right1
);
if
(
ret
==
0
)
{
continue
;
}
else
{
return
ret
;
int
ret
=
fn
(
left1
,
right1
);
if
(
ret
==
0
)
{
continue
;
}
else
{
return
ret
;
}
}
}
return
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录