Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
aab31f65
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
aab31f65
编写于
2月 02, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(query): fix bug in multi-group limit/offset of the merge sort .
上级
8258c68b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
17 addition
and
15 deletion
+17
-15
source/libs/executor/src/sortoperator.c
source/libs/executor/src/sortoperator.c
+17
-15
未找到文件。
source/libs/executor/src/sortoperator.c
浏览文件 @
aab31f65
...
...
@@ -544,7 +544,6 @@ typedef struct SMultiwayMergeOperatorInfo {
SSDataBlock
*
pIntermediateBlock
;
// to hold the intermediate result
int64_t
startTs
;
// sort start time
bool
groupSort
;
bool
hasGroupId
;
uint64_t
groupId
;
STupleHandle
*
prefetchedTuple
;
}
SMultiwayMergeOperatorInfo
;
...
...
@@ -591,7 +590,9 @@ int32_t openMultiwayMergeOperator(SOperatorInfo* pOperator) {
return
TSDB_CODE_SUCCESS
;
}
static
void
doGetSortedBlockData
(
SMultiwayMergeOperatorInfo
*
pInfo
,
SSortHandle
*
pHandle
,
int32_t
capacity
,
SSDataBlock
*
p
)
{
static
void
doGetSortedBlockData
(
SMultiwayMergeOperatorInfo
*
pInfo
,
SSortHandle
*
pHandle
,
int32_t
capacity
,
SSDataBlock
*
p
,
bool
*
newgroup
)
{
*
newgroup
=
false
;
while
(
1
)
{
STupleHandle
*
pTupleHandle
=
NULL
;
...
...
@@ -600,8 +601,12 @@ static void doGetSortedBlockData(SMultiwayMergeOperatorInfo* pInfo, SSortHandle*
pTupleHandle
=
tsortNextTuple
(
pHandle
);
}
else
{
pTupleHandle
=
pInfo
->
prefetchedTuple
;
pInfo
->
groupId
=
tsortGetGroupId
(
pTupleHandle
);
pInfo
->
prefetchedTuple
=
NULL
;
uint64_t
gid
=
tsortGetGroupId
(
pTupleHandle
);
if
(
gid
!=
pInfo
->
groupId
)
{
*
newgroup
=
true
;
pInfo
->
groupId
=
gid
;
}
}
}
else
{
pTupleHandle
=
tsortNextTuple
(
pHandle
);
...
...
@@ -614,12 +619,10 @@ static void doGetSortedBlockData(SMultiwayMergeOperatorInfo* pInfo, SSortHandle*
if
(
pInfo
->
groupSort
)
{
uint64_t
tupleGroupId
=
tsortGetGroupId
(
pTupleHandle
);
if
(
!
pInfo
->
hasGroupId
)
{
pInfo
->
groupId
=
tupleGroupId
;
pInfo
->
hasGroupId
=
true
;
appendOneRowToDataBlock
(
p
,
pTupleHandle
);
}
else
if
(
pInfo
->
groupId
==
tupleGroupId
)
{
if
(
pInfo
->
groupId
==
0
||
pInfo
->
groupId
==
tupleGroupId
)
{
appendOneRowToDataBlock
(
p
,
pTupleHandle
);
p
->
info
.
id
.
groupId
=
tupleGroupId
;
pInfo
->
groupId
=
tupleGroupId
;
}
else
{
pInfo
->
prefetchedTuple
=
pTupleHandle
;
break
;
...
...
@@ -632,11 +635,6 @@ static void doGetSortedBlockData(SMultiwayMergeOperatorInfo* pInfo, SSortHandle*
break
;
}
}
if
(
pInfo
->
groupSort
)
{
pInfo
->
hasGroupId
=
false
;
}
}
SSDataBlock
*
getMultiwaySortedBlockData
(
SSortHandle
*
pHandle
,
SSDataBlock
*
pDataBlock
,
SArray
*
pColMatchInfo
,
...
...
@@ -660,14 +658,18 @@ SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pData
}
SSDataBlock
*
p
=
pInfo
->
pIntermediateBlock
;
bool
newgroup
=
false
;
while
(
1
)
{
doGetSortedBlockData
(
pInfo
,
pHandle
,
capacity
,
p
);
doGetSortedBlockData
(
pInfo
,
pHandle
,
capacity
,
p
,
&
newgroup
);
if
(
p
->
info
.
rows
==
0
)
{
break
;
}
// todo fix it: we need to decide whether this block is belonged to previous group or not .
if
(
newgroup
)
{
resetLimitInfoForNextGroup
(
&
pInfo
->
limitInfo
);
}
bool
limitReached
=
applyLimitOffset
(
&
pInfo
->
limitInfo
,
p
,
pTaskInfo
);
if
(
limitReached
)
{
resetLimitInfoForNextGroup
(
&
pInfo
->
limitInfo
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录