Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
10f9c40d
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
10f9c40d
编写于
7月 25, 2023
作者:
D
dapan1121
提交者:
GitHub
7月 25, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #22171 from taosdata/szhou/enhance-limit-proc
enhance: skip data blocks with the merge limit ts when create initial…
上级
96722a07
1d24b96e
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
33 addition
and
2 deletion
+33
-2
source/libs/executor/src/tsort.c
source/libs/executor/src/tsort.c
+33
-2
未找到文件。
source/libs/executor/src/tsort.c
浏览文件 @
10f9c40d
...
...
@@ -51,6 +51,7 @@ struct SSortHandle {
uint32_t
tmpRowIdx
;
int64_t
mergeLimit
;
int64_t
currMergeLimitTs
;
int32_t
sourceId
;
SSDataBlock
*
pDataBlock
;
...
...
@@ -921,7 +922,8 @@ static int32_t sortBlocksToExtSource(SSortHandle* pHandle, SArray* aBlk, SBlockO
int32_t
nMergedRows
=
0
;
bool
mergeLimitReached
=
false
;
size_t
blkPgSz
=
pgHeaderSz
;
int64_t
lastPageBufTs
=
(
order
->
order
==
TSDB_ORDER_ASC
)
?
INT64_MAX
:
INT64_MIN
;
int64_t
currTs
=
(
order
->
order
==
TSDB_ORDER_ASC
)
?
INT64_MAX
:
INT64_MIN
;
while
(
nRows
<
totalRows
)
{
int32_t
minIdx
=
tMergeTreeGetChosenIndex
(
pTree
);
SSDataBlock
*
minBlk
=
taosArrayGetP
(
aBlk
,
minIdx
);
...
...
@@ -929,14 +931,21 @@ static int32_t sortBlocksToExtSource(SSortHandle* pHandle, SArray* aBlk, SBlockO
int32_t
bufInc
=
getPageBufIncForRow
(
minBlk
,
minRow
,
pHandle
->
pDataBlock
->
info
.
rows
);
if
(
blkPgSz
<=
pHandle
->
pageSize
&&
blkPgSz
+
bufInc
>
pHandle
->
pageSize
)
{
SColumnInfoData
*
tsCol
=
taosArrayGet
(
pHandle
->
pDataBlock
->
pDataBlock
,
order
->
slotId
);
lastPageBufTs
=
((
int64_t
*
)
tsCol
->
pData
)[
pHandle
->
pDataBlock
->
info
.
rows
-
1
];
appendDataBlockToPageBuf
(
pHandle
,
pHandle
->
pDataBlock
,
aPgId
);
nMergedRows
+=
pHandle
->
pDataBlock
->
info
.
rows
;
blockDataCleanup
(
pHandle
->
pDataBlock
);
blkPgSz
=
pgHeaderSz
;
bufInc
=
getPageBufIncForRow
(
minBlk
,
minRow
,
0
);
if
((
pHandle
->
mergeLimit
!=
-
1
)
&&
(
nMergedRows
>=
pHandle
->
mergeLimit
))
{
mergeLimitReached
=
true
;
if
((
lastPageBufTs
<
pHandle
->
currMergeLimitTs
&&
order
->
order
==
TSDB_ORDER_ASC
)
||
(
lastPageBufTs
>
pHandle
->
currMergeLimitTs
&&
order
->
order
==
TSDB_ORDER_DESC
))
{
pHandle
->
currMergeLimitTs
=
lastPageBufTs
;
}
break
;
}
}
...
...
@@ -955,8 +964,17 @@ static int32_t sortBlocksToExtSource(SSortHandle* pHandle, SArray* aBlk, SBlockO
}
if
(
pHandle
->
pDataBlock
->
info
.
rows
>
0
)
{
if
(
!
mergeLimitReached
)
{
SColumnInfoData
*
tsCol
=
taosArrayGet
(
pHandle
->
pDataBlock
->
pDataBlock
,
order
->
slotId
);
lastPageBufTs
=
((
int64_t
*
)
tsCol
->
pData
)[
pHandle
->
pDataBlock
->
info
.
rows
-
1
];
appendDataBlockToPageBuf
(
pHandle
,
pHandle
->
pDataBlock
,
aPgId
);
nMergedRows
+=
pHandle
->
pDataBlock
->
info
.
rows
;
if
((
pHandle
->
mergeLimit
!=
-
1
)
&&
(
nMergedRows
>=
pHandle
->
mergeLimit
))
{
mergeLimitReached
=
true
;
if
((
lastPageBufTs
<
pHandle
->
currMergeLimitTs
&&
order
->
order
==
TSDB_ORDER_ASC
)
||
(
lastPageBufTs
>
pHandle
->
currMergeLimitTs
&&
order
->
order
==
TSDB_ORDER_DESC
))
{
pHandle
->
currMergeLimitTs
=
lastPageBufTs
;
}
}
}
blockDataCleanup
(
pHandle
->
pDataBlock
);
}
...
...
@@ -982,11 +1000,24 @@ static int32_t createBlocksMergeSortInitialSources(SSortHandle* pHandle) {
SSortSource
*
pSrc
=
taosArrayGetP
(
pHandle
->
pOrderedSource
,
0
);
int32_t
szSort
=
0
;
if
(
pOrder
->
order
==
TSDB_ORDER_ASC
)
{
pHandle
->
currMergeLimitTs
=
INT64_MAX
;
}
else
{
pHandle
->
currMergeLimitTs
=
INT64_MIN
;
}
SArray
*
aBlkSort
=
taosArrayInit
(
8
,
POINTER_BYTES
);
SSHashObj
*
mUidBlk
=
tSimpleHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_UBIGINT
));
while
(
1
)
{
SSDataBlock
*
pBlk
=
pHandle
->
fetchfp
(
pSrc
->
param
);
if
(
pBlk
!=
NULL
)
{
SColumnInfoData
*
tsCol
=
taosArrayGet
(
pBlk
->
pDataBlock
,
pOrder
->
slotId
);
int64_t
firstRowTs
=
*
(
int64_t
*
)
tsCol
->
pData
;
if
((
pOrder
->
order
==
TSDB_ORDER_ASC
&&
firstRowTs
>
pHandle
->
currMergeLimitTs
)
||
(
pOrder
->
order
==
TSDB_ORDER_DESC
&&
firstRowTs
<
pHandle
->
currMergeLimitTs
))
{
continue
;
}
}
if
(
pBlk
!=
NULL
)
{
szSort
+=
blockDataGetSize
(
pBlk
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录