Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
414b3242
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看板
提交
414b3242
编写于
6月 09, 2022
作者:
S
shenglian zhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: add group id to sort operator
上级
9afcca03
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
47 addition
and
27 deletion
+47
-27
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+5
-1
source/libs/executor/src/sortoperator.c
source/libs/executor/src/sortoperator.c
+42
-26
未找到文件。
source/libs/executor/inc/executorimpl.h
浏览文件 @
414b3242
...
...
@@ -700,6 +700,10 @@ typedef struct SSortOperatorInfo {
int64_t
startTs
;
// sort start time
uint64_t
sortElapsed
;
// sort elapsed time, time to flush to disk not included.
STupleHandle
*
prefetchedTuple
;
bool
hasGroupId
;
uint64_t
groupId
;
}
SSortOperatorInfo
;
typedef
struct
STagFilterOperatorInfo
{
...
...
@@ -759,7 +763,7 @@ void setTbNameColData(void* pMeta, const SSDataBlock* pBlock, SColumnInfoData
SInterval
extractIntervalInfo
(
const
STableScanPhysiNode
*
pTableScanNode
);
SColumn
extractColumnFromColumnNode
(
SColumnNode
*
pColNode
);
SSDataBlock
*
getSortedBlockData
(
SSortHandle
*
pHandle
,
SSDataBlock
*
pDataBlock
,
int32_t
capacity
,
SArray
*
pColMatchInfo
);
SSDataBlock
*
getSortedBlockData
(
SSortHandle
*
pHandle
,
SSDataBlock
*
pDataBlock
,
int32_t
capacity
,
SArray
*
pColMatchInfo
,
SSortOperatorInfo
*
pInfo
);
SSDataBlock
*
loadNextDataBlock
(
void
*
param
);
void
setResultRowInitCtx
(
SResultRow
*
pResult
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
int32_t
*
rowCellInfoOffset
);
...
...
source/libs/executor/src/sortoperator.c
浏览文件 @
414b3242
...
...
@@ -42,6 +42,8 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSDataBlock* pR
pInfo
->
pSortInfo
=
pSortInfo
;
pInfo
->
pColMatchInfo
=
pColMatchColInfo
;
pInfo
->
hasGroupId
=
false
;
pInfo
->
prefetchedTuple
=
NULL
;
pOperator
->
name
=
"SortOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_SORT
;
pOperator
->
blocking
=
true
;
...
...
@@ -81,8 +83,8 @@ void appendOneRowToDataBlock(SSDataBlock* pBlock, STupleHandle* pTupleHandle) {
pBlock
->
info
.
rows
+=
1
;
}
SSDataBlock
*
getSortedBlockData
(
SSortHandle
*
pHandle
,
SSDataBlock
*
pDataBlock
,
int32_t
capacity
,
S
Array
*
pColMatch
Info
)
{
SSDataBlock
*
getSortedBlockData
(
SSortHandle
*
pHandle
,
SSDataBlock
*
pDataBlock
,
int32_t
capacity
,
SArray
*
pColMatchInfo
,
S
SortOperatorInfo
*
p
Info
)
{
blockDataCleanup
(
pDataBlock
);
SSDataBlock
*
p
=
tsortGetSortedDataBlock
(
pHandle
);
...
...
@@ -93,14 +95,33 @@ SSDataBlock* getSortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlock, i
blockDataEnsureCapacity
(
p
,
capacity
);
while
(
1
)
{
STupleHandle
*
pTupleHandle
=
tsortNextTuple
(
pHandle
);
STupleHandle
*
pTupleHandle
=
NULL
;
if
(
pInfo
->
prefetchedTuple
==
NULL
)
{
pTupleHandle
=
tsortNextTuple
(
pHandle
);
}
else
{
pTupleHandle
=
pInfo
->
prefetchedTuple
;
pInfo
->
groupId
=
tsortGetGroupId
(
pTupleHandle
);
pInfo
->
prefetchedTuple
=
NULL
;
}
if
(
pTupleHandle
==
NULL
)
{
break
;
}
appendOneRowToDataBlock
(
p
,
pTupleHandle
);
uint64_t
tupleGroupId
=
tsortGetGroupId
(
pTupleHandle
);
if
(
!
pInfo
->
hasGroupId
)
{
pInfo
->
groupId
=
tupleGroupId
;
pInfo
->
hasGroupId
=
true
;
appendOneRowToDataBlock
(
p
,
pTupleHandle
);
}
else
if
(
pInfo
->
groupId
==
tupleGroupId
)
{
appendOneRowToDataBlock
(
p
,
pTupleHandle
);
}
else
{
pInfo
->
prefetchedTuple
=
pTupleHandle
;
break
;
}
if
(
p
->
info
.
rows
>=
capacity
)
{
return
pDataBloc
k
;
brea
k
;
}
}
...
...
@@ -117,6 +138,7 @@ SSDataBlock* getSortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlock, i
pDataBlock
->
info
.
rows
=
p
->
info
.
rows
;
pDataBlock
->
info
.
capacity
=
p
->
info
.
rows
;
pDataBlock
->
info
.
groupId
=
pInfo
->
groupId
;
}
blockDataDestroy
(
p
);
...
...
@@ -188,8 +210,8 @@ SSDataBlock* doSort(SOperatorInfo* pOperator) {
longjmp
(
pTaskInfo
->
env
,
code
);
}
SSDataBlock
*
pBlock
=
getSortedBlockData
(
pInfo
->
pSortHandle
,
pInfo
->
binfo
.
pRes
,
pOperator
->
resultInfo
.
capacity
,
pInfo
->
pColMatch
Info
);
SSDataBlock
*
pBlock
=
getSortedBlockData
(
pInfo
->
pSortHandle
,
pInfo
->
binfo
.
pRes
,
pOperator
->
resultInfo
.
capacity
,
pInfo
->
pColMatchInfo
,
p
Info
);
if
(
pBlock
!=
NULL
)
{
pOperator
->
resultInfo
.
totalRows
+=
pBlock
->
info
.
rows
;
...
...
@@ -230,11 +252,11 @@ typedef struct SMultiwaySortMergeOperatorInfo {
SArray
*
pColMatchInfo
;
// for index map from table scan output
SSDataBlock
*
pInputBlock
;
int64_t
startTs
;
// sort start time
int64_t
startTs
;
// sort start time
bool
hasGroupId
;
uint64_t
groupId
;
STupleHandle
*
prefetchedTuple
;
bool
hasGroupId
;
uint64_t
groupId
;
STupleHandle
*
prefetchedTuple
;
}
SMultiwaySortMergeOperatorInfo
;
int32_t
doOpenMultiwaySortMergeOperator
(
SOperatorInfo
*
pOperator
)
{
...
...
@@ -274,7 +296,7 @@ int32_t doOpenMultiwaySortMergeOperator(SOperatorInfo* pOperator) {
}
SSDataBlock
*
getMultiwaySortedBlockData
(
SSortHandle
*
pHandle
,
SSDataBlock
*
pDataBlock
,
int32_t
capacity
,
SArray
*
pColMatchInfo
,
SMultiwaySortMergeOperatorInfo
*
pInfo
)
{
SArray
*
pColMatchInfo
,
SMultiwaySortMergeOperatorInfo
*
pInfo
)
{
blockDataCleanup
(
pDataBlock
);
SSDataBlock
*
p
=
tsortGetSortedDataBlock
(
pHandle
);
...
...
@@ -285,7 +307,6 @@ SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pData
blockDataEnsureCapacity
(
p
,
capacity
);
while
(
1
)
{
STupleHandle
*
pTupleHandle
=
NULL
;
if
(
pInfo
->
prefetchedTuple
==
NULL
)
{
pTupleHandle
=
tsortNextTuple
(
pHandle
);
...
...
@@ -314,7 +335,6 @@ SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pData
if
(
p
->
info
.
rows
>=
capacity
)
{
break
;
}
}
if
(
p
->
info
.
rows
>
0
)
{
...
...
@@ -337,7 +357,6 @@ SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pData
return
(
pDataBlock
->
info
.
rows
>
0
)
?
pDataBlock
:
NULL
;
}
SSDataBlock
*
doMultiwaySortMerge
(
SOperatorInfo
*
pOperator
)
{
if
(
pOperator
->
status
==
OP_EXEC_DONE
)
{
return
NULL
;
...
...
@@ -351,12 +370,8 @@ SSDataBlock* doMultiwaySortMerge(SOperatorInfo* pOperator) {
longjmp
(
pTaskInfo
->
env
,
code
);
}
SSDataBlock
*
pBlock
=
getMultiwaySortedBlockData
(
pInfo
->
pSortHandle
,
pInfo
->
binfo
.
pRes
,
pOperator
->
resultInfo
.
capacity
,
pInfo
->
pColMatchInfo
,
pInfo
);
SSDataBlock
*
pBlock
=
getMultiwaySortedBlockData
(
pInfo
->
pSortHandle
,
pInfo
->
binfo
.
pRes
,
pOperator
->
resultInfo
.
capacity
,
pInfo
->
pColMatchInfo
,
pInfo
);
if
(
pBlock
!=
NULL
)
{
pOperator
->
resultInfo
.
totalRows
+=
pBlock
->
info
.
rows
;
...
...
@@ -367,7 +382,7 @@ SSDataBlock* doMultiwaySortMerge(SOperatorInfo* pOperator) {
}
void
destroyMultiwaySortMergeOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
SMultiwaySortMergeOperatorInfo
*
pInfo
=
(
SMultiwaySortMergeOperatorInfo
*
)
param
;
SMultiwaySortMergeOperatorInfo
*
pInfo
=
(
SMultiwaySortMergeOperatorInfo
*
)
param
;
pInfo
->
binfo
.
pRes
=
blockDataDestroy
(
pInfo
->
binfo
.
pRes
);
pInfo
->
pInputBlock
=
blockDataDestroy
(
pInfo
->
pInputBlock
);
...
...
@@ -387,9 +402,9 @@ int32_t getMultiwaySortMergeExplainExecInfo(SOperatorInfo* pOptr, void** pOptrEx
return
TSDB_CODE_SUCCESS
;
}
SOperatorInfo
*
createMultiwaySortMergeOperatorInfo
(
SOperatorInfo
**
downStreams
,
int32_t
numStreams
,
SSDataBlock
*
pInputBlock
,
SSDataBlock
*
p
ResBlock
,
SArray
*
pSortInfo
,
SArray
*
pColMatchCol
Info
,
SExecTaskInfo
*
pTaskInfo
)
{
SOperatorInfo
*
createMultiwaySortMergeOperatorInfo
(
SOperatorInfo
**
downStreams
,
int32_t
numStreams
,
SSDataBlock
*
p
InputBlock
,
SSDataBlock
*
pResBlock
,
SArray
*
pSort
Info
,
S
Array
*
pColMatchColInfo
,
S
ExecTaskInfo
*
pTaskInfo
)
{
SMultiwaySortMergeOperatorInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SMultiwaySortMergeOperatorInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
int32_t
rowSize
=
pResBlock
->
info
.
rowSize
;
...
...
@@ -413,7 +428,8 @@ SOperatorInfo* createMultiwaySortMergeOperatorInfo(SOperatorInfo** downStreams,
pInfo
->
bufPageSize
=
rowSize
<
1024
?
1024
:
rowSize
*
2
;
pInfo
->
sortBufSize
=
pInfo
->
bufPageSize
*
16
;
pInfo
->
hasGroupId
=
false
;
pInfo
->
prefetchedTuple
=
NULL
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
fpSet
=
createOperatorFpSet
(
doOpenMultiwaySortMergeOperator
,
doMultiwaySortMerge
,
NULL
,
NULL
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录