Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0f3fc6cf
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
未验证
提交
0f3fc6cf
编写于
6月 20, 2022
作者:
S
shenglian-zhou
提交者:
GitHub
6月 20, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #14030 from taosdata/szhou/feature/sort-group
feat: order group by group id generated by partition
上级
57e6846d
48d22c35
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
29 addition
and
7 deletion
+29
-7
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+2
-1
source/libs/executor/src/groupoperator.c
source/libs/executor/src/groupoperator.c
+27
-6
未找到文件。
source/libs/executor/inc/executorimpl.h
浏览文件 @
0f3fc6cf
...
...
@@ -506,7 +506,8 @@ typedef struct SPartitionOperatorInfo {
SDiskbasedBuf
*
pBuf
;
// query result buffer based on blocked-wised disk file
int32_t
rowCapacity
;
// maximum number of rows for each buffer page
int32_t
*
columnOffset
;
// start position for each column data
void
*
pGroupIter
;
// group iterator
SArray
*
sortedGroupArray
;
// SDataGroupInfo sorted by group id
int32_t
groupIndex
;
// group index
int32_t
pageIndex
;
// page index of current group
SSDataBlock
*
pUpdateRes
;
SExprSupp
scalarSup
;
...
...
source/libs/executor/src/groupoperator.c
浏览文件 @
0f3fc6cf
...
...
@@ -586,24 +586,30 @@ static void clearPartitionOperator(SPartitionOperatorInfo* pInfo) {
while
(
(
ite
=
taosHashIterate
(
pInfo
->
pGroupSet
,
ite
))
!=
NULL
)
{
taosArrayDestroy
(
((
SDataGroupInfo
*
)
ite
)
->
pPageList
);
}
taos
HashClear
(
pInfo
->
pGroupSet
);
taos
ArrayClear
(
pInfo
->
sortedGroupArray
);
clearDiskbasedBuf
(
pInfo
->
pBuf
);
}
static
int
compareDataGroupInfo
(
const
void
*
group1
,
const
void
*
group2
)
{
const
SDataGroupInfo
*
pGroupInfo1
=
group1
;
const
SDataGroupInfo
*
pGroupInfo2
=
group2
;
return
pGroupInfo1
->
groupId
-
pGroupInfo2
->
groupId
;
}
static
SSDataBlock
*
buildPartitionResult
(
SOperatorInfo
*
pOperator
)
{
SPartitionOperatorInfo
*
pInfo
=
pOperator
->
info
;
SDataGroupInfo
*
pGroupInfo
=
pInfo
->
pGroupIter
;
if
(
pInfo
->
pGroupIter
==
NULL
||
pInfo
->
pageIndex
>=
taosArrayGetSize
(
pGroupInfo
->
pPageList
))
{
SDataGroupInfo
*
pGroupInfo
=
(
pInfo
->
groupIndex
!=
-
1
)
?
taosArrayGet
(
pInfo
->
sortedGroupArray
,
pInfo
->
groupIndex
)
:
NULL
;
if
(
pInfo
->
groupIndex
==
-
1
||
pInfo
->
pageIndex
>=
taosArrayGetSize
(
pGroupInfo
->
pPageList
))
{
// try next group data
pInfo
->
pGroupIter
=
taosHashIterate
(
pInfo
->
pGroupSet
,
pInfo
->
pGroupIter
)
;
if
(
pInfo
->
pGroupIter
==
NULL
)
{
++
pInfo
->
groupIndex
;
if
(
pInfo
->
groupIndex
>=
taosArrayGetSize
(
pInfo
->
sortedGroupArray
)
)
{
doSetOperatorCompleted
(
pOperator
);
clearPartitionOperator
(
pInfo
);
return
NULL
;
}
pGroupInfo
=
pInfo
->
pGroupIter
;
pGroupInfo
=
taosArrayGet
(
pInfo
->
sortedGroupArray
,
pInfo
->
groupIndex
)
;
pInfo
->
pageIndex
=
0
;
}
...
...
@@ -657,6 +663,20 @@ static SSDataBlock* hashPartition(SOperatorInfo* pOperator) {
doHashPartition
(
pOperator
,
pBlock
);
}
SArray
*
groupArray
=
taosArrayInit
(
taosHashGetSize
(
pInfo
->
pGroupSet
),
sizeof
(
SDataGroupInfo
));
void
*
pGroupIter
=
NULL
;
pGroupIter
=
taosHashIterate
(
pInfo
->
pGroupSet
,
NULL
);
while
(
pGroupIter
!=
NULL
)
{
SDataGroupInfo
*
pGroupInfo
=
pGroupIter
;
taosArrayPush
(
groupArray
,
pGroupInfo
);
pGroupIter
=
taosHashIterate
(
pInfo
->
pGroupSet
,
pGroupIter
);
}
taosArraySort
(
groupArray
,
compareDataGroupInfo
);
pInfo
->
sortedGroupArray
=
groupArray
;
pInfo
->
groupIndex
=
-
1
;
taosHashClear
(
pInfo
->
pGroupSet
);
pOperator
->
cost
.
openCost
=
(
taosGetTimestampUs
()
-
st
)
/
1000
.
0
;
pOperator
->
status
=
OP_RES_TO_RETURN
;
...
...
@@ -676,6 +696,7 @@ static void destroyPartitionOperatorInfo(void* param, int32_t numOfOutput) {
taosArrayDestroy
(
pInfo
->
pGroupColVals
);
taosMemoryFree
(
pInfo
->
keyBuf
);
taosArrayDestroy
(
pInfo
->
sortedGroupArray
);
taosHashCleanup
(
pInfo
->
pGroupSet
);
taosMemoryFree
(
pInfo
->
columnOffset
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录