Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
d6fa853b
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看板
提交
d6fa853b
编写于
2月 17, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-11818] refactor.
上级
36aedfbb
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
67 addition
and
126 deletion
+67
-126
include/libs/planner/plannerOp.h
include/libs/planner/plannerOp.h
+1
-0
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+15
-23
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+51
-103
未找到文件。
include/libs/planner/plannerOp.h
浏览文件 @
d6fa853b
...
...
@@ -47,5 +47,6 @@ OP_ENUM_MACRO(AllTimeWindow)
OP_ENUM_MACRO
(
AllMultiTableTimeInterval
)
OP_ENUM_MACRO
(
Order
)
OP_ENUM_MACRO
(
Exchange
)
OP_ENUM_MACRO
(
SortMerge
)
//OP_ENUM_MACRO(TableScan)
source/libs/executor/inc/executorimpl.h
浏览文件 @
d6fa853b
...
...
@@ -549,27 +549,19 @@ typedef struct SDistinctOperatorInfo {
SArray
*
pDistinctDataInfo
;
}
SDistinctOperatorInfo
;
struct
SGlobalMerger
;
typedef
struct
SMultiwayMergeInfo
{
struct
SGlobalMerger
*
pMerge
;
SOptrBasicInfo
binfo
;
int32_t
bufCapacity
;
int64_t
seed
;
char
**
prevRow
;
SArray
*
orderColumnList
;
int32_t
resultRowFactor
;
bool
hasGroupColData
;
char
**
currentGroupColData
;
SArray
*
groupColumnList
;
bool
hasDataBlockForNewGroup
;
SSDataBlock
*
pExistBlock
;
SArray
*
udfInfo
;
bool
hasPrev
;
bool
multiGroupResults
;
}
SMultiwayMergeInfo
;
typedef
struct
SSortMergeOperatorInfo
{
SOptrBasicInfo
binfo
;
SArray
*
orderInfo
;
// SArray<SBlockOrderInfo>
SArray
*
groupColumnList
;
bool
hasDataBlockForNewGroup
;
char
**
currentGroupColData
;
SArray
*
udfInfo
;
int32_t
numOfSources
;
// char** prevRow;
// int32_t resultRowFactor;
// bool multiGroupResults;
// bool hasGroupColData;
}
SSortMergeOperatorInfo
;
typedef
struct
SMsortComparParam
{
struct
SExternalMemSource
**
pSources
;
...
...
@@ -592,6 +584,7 @@ typedef struct SOrderOperatorInfo {
SMsortComparParam
cmpParam
;
// TODO extact struct
int64_t
startTs
;
// sort start time
uint64_t
sortElapsed
;
// sort elapsed time, time to flush to disk not included.
uint64_t
totalSize
;
// total load bytes from remote
...
...
@@ -642,8 +635,7 @@ SOperatorInfo* createFilterOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorI
SOperatorInfo
*
createJoinOperatorInfo
(
SOperatorInfo
**
pdownstream
,
int32_t
numOfDownstream
,
SSchema
*
pSchema
,
int32_t
numOfOutput
);
SOperatorInfo
*
createOrderOperatorInfo
(
SOperatorInfo
*
downstream
,
SArray
*
pExprInfo
,
SArray
*
pOrderVal
);
SOperatorInfo
*
createMergeSortOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
SOrder
*
pOrderVal
);
SOperatorInfo
*
createSortMergeOperatorInfo
(
SOperatorInfo
*
downstream
,
SArray
*
pExprInfo
,
void
*
param
,
SArray
*
pUdfInfo
,
SExecTaskInfo
*
pTaskInfo
);
// SSDataBlock* doGlobalAggregate(void* param, bool* newgroup);
// SSDataBlock* doMultiwayMergeSort(void* param, bool* newgroup);
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
d6fa853b
...
...
@@ -5600,12 +5600,9 @@ SArray* getResultGroupCheckColumns(STaskAttr* pQuery) {
}
static
void
destroyGlobalAggOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
S
MultiwayMergeInfo
*
pInfo
=
(
SMultiwayMerge
Info
*
)
param
;
S
SortMergeOperatorInfo
*
pInfo
=
(
SSortMergeOperator
Info
*
)
param
;
destroyBasicOperatorInfo
(
&
pInfo
->
binfo
,
numOfOutput
);
taosArrayDestroy
(
pInfo
->
orderColumnList
);
taosArrayDestroy
(
pInfo
->
groupColumnList
);
tfree
(
pInfo
->
prevRow
);
tfree
(
pInfo
->
currentGroupColData
);
}
...
...
@@ -5616,118 +5613,82 @@ static void destroySlimitOperatorInfo(void* param, int32_t numOfOutput) {
tfree
(
pInfo
->
prevRow
);
}
SOperatorInfo
*
createGlobalAggregateOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
void
*
param
,
SArray
*
pUdfInfo
,
bool
groupResultMixedUp
)
{
SMultiwayMergeInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SMultiwayMergeInfo
));
pInfo
->
resultRowFactor
=
(
int32_t
)(
getRowNumForMultioutput
(
pRuntimeEnv
->
pQueryAttr
,
pRuntimeEnv
->
pQueryAttr
->
topBotQuery
,
false
));
pRuntimeEnv
->
scanFlag
=
MERGE_STAGE
;
// TODO init when creating pCtx
pInfo
->
multiGroupResults
=
groupResultMixedUp
;
pInfo
->
pMerge
=
param
;
pInfo
->
bufCapacity
=
4096
;
pInfo
->
udfInfo
=
pUdfInfo
;
pInfo
->
binfo
.
pRes
=
createOutputBuf
(
pExpr
,
numOfOutput
,
pInfo
->
bufCapacity
*
pInfo
->
resultRowFactor
);
pInfo
->
binfo
.
pCtx
=
createSqlFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pInfo
->
binfo
.
rowCellInfoOffset
);
pInfo
->
orderColumnList
=
getOrderCheckColumns
(
pRuntimeEnv
->
pQueryAttr
);
pInfo
->
groupColumnList
=
getResultGroupCheckColumns
(
pRuntimeEnv
->
pQueryAttr
);
// TODO refactor
int32_t
len
=
0
;
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
// len += pExpr[i].base.;
static
SExprInfo
*
exprArrayDup
(
SArray
*
pExprInfo
)
{
size_t
numOfOutput
=
taosArrayGetSize
(
pExprInfo
);
SExprInfo
*
p
=
calloc
(
numOfOutput
,
sizeof
(
SExprInfo
));
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pExprInfo
);
++
i
)
{
SExprInfo
*
pExpr
=
taosArrayGetP
(
pExprInfo
,
i
);
assignExprInfo
(
&
p
[
i
],
pExpr
);
}
int32_t
numOfCols
=
(
pInfo
->
orderColumnList
!=
NULL
)
?
(
int32_t
)
taosArrayGetSize
(
pInfo
->
orderColumnList
)
:
0
;
pInfo
->
prevRow
=
calloc
(
1
,
(
POINTER_BYTES
*
numOfCols
+
len
));
int32_t
offset
=
POINTER_BYTES
*
numOfCols
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
pInfo
->
prevRow
[
i
]
=
(
char
*
)
pInfo
->
prevRow
+
offset
;
return
p
;
}
SColIndex
*
index
=
taosArrayGet
(
pInfo
->
orderColumnList
,
i
);
offset
+=
pExpr
[
index
->
colIndex
].
base
.
resSchema
.
bytes
;
static
SSDataBlock
*
doSortMerge
(
void
*
param
,
bool
*
newgroup
)
{
SOperatorInfo
*
pOperator
=
(
SOperatorInfo
*
)
param
;
if
(
pOperator
->
status
==
OP_EXEC_DONE
)
{
return
NULL
;
}
numOfCols
=
(
pInfo
->
groupColumnList
!=
NULL
)
?
(
int32_t
)
taosArrayGetSize
(
pInfo
->
groupColumnList
)
:
0
;
pInfo
->
currentGroupColData
=
calloc
(
1
,
(
POINTER_BYTES
*
numOfCols
+
len
));
offset
=
POINTER_BYTES
*
numOfCols
;
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
SSortMergeOperatorInfo
*
pInfo
=
pOperator
->
info
;
for
(
int32_t
i
=
0
;
i
<
numOfCol
s
;
++
i
)
{
pInfo
->
currentGroupColData
[
i
]
=
(
char
*
)
pInfo
->
currentGroupColData
+
offset
;
for
(
int32_t
i
=
0
;
i
<
pInfo
->
numOfSource
s
;
++
i
)
{
SSDataBlock
*
pBlock
=
pOperator
->
pDownstream
[
i
]
->
exec
(
pOperator
->
pDownstream
[
i
],
newgroup
)
;
SColIndex
*
index
=
taosArrayGet
(
pInfo
->
groupColumnList
,
i
);
offset
+=
pExpr
[
index
->
colIndex
].
base
.
resSchema
.
bytes
;
}
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
,
TSDB_DATA_TYPE_INT
);
pInfo
->
seed
=
rand
();
setDefaultOutputBuf
(
pRuntimeEnv
,
&
pInfo
->
binfo
,
pInfo
->
seed
,
MERGE_STAGE
);
return
NULL
;
}
SOperatorInfo
*
createSortMergeOperatorInfo
(
SOperatorInfo
*
downstream
,
SArray
*
pExprInfo
,
void
*
param
,
SArray
*
pUdfInfo
,
SExecTaskInfo
*
pTaskInfo
)
{
SSortMergeOperatorInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SSortMergeOperatorInfo
));
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
pOperator
->
name
=
"GlobalAggregate"
;
// pOperator->operatorType = OP_GlobalAggregate;
pOperator
->
blockingOptr
=
true
;
pOperator
->
status
=
OP_IN_EXECUTING
;
pOperator
->
info
=
pInfo
;
pOperator
->
pExpr
=
pExpr
;
pOperator
->
numOfOutput
=
numOfOutput
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
// pOperator->exec = doGlobalAggregate;
pOperator
->
cleanupFn
=
destroyGlobalAggOperatorInfo
;
appendDownstream
(
pOperator
,
downstream
);
return
pOperator
;
}
SOperatorInfo
*
createMultiwaySortOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
int32_t
numOfRows
,
void
*
merger
)
{
SMultiwayMergeInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SMultiwayMergeInfo
));
// pInfo->resultRowFactor =
// (int32_t)(getRowNumForMultioutput(pRuntimeEnv->pQueryAttr, pRuntimeEnv->pQueryAttr->topBotQuery, false));
pInfo
->
pMerge
=
merger
;
pInfo
->
bufCapacity
=
numOfRows
;
pInfo
->
orderColumnList
=
getResultGroupCheckColumns
(
pRuntimeEnv
->
pQueryAttr
);
pInfo
->
binfo
.
pRes
=
createOutputBuf
(
pExpr
,
numOfOutput
,
numOfRows
);
int32_t
numOfOutput
=
taosArrayGetSize
(
pExprInfo
);
pInfo
->
binfo
.
capacity
=
4096
;
pInfo
->
udfInfo
=
pUdfInfo
;
pInfo
->
binfo
.
pRes
=
createOutputBuf_rv
(
pExprInfo
,
pInfo
->
binfo
.
capacity
);
pInfo
->
binfo
.
pCtx
=
createSqlFunctionCtx_rv
(
pExprInfo
,
&
pInfo
->
binfo
.
rowCellInfoOffset
,
&
pInfo
->
binfo
.
resRowSize
);
{
// todo extract method to create prev compare buffer
int32_t
len
=
0
;
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
// len += pExpr[i].base.colBytes;
}
int32_t
numOfCols
=
(
pInfo
->
groupColumnList
!=
NULL
)
?
(
int32_t
)
taosArrayGetSize
(
pInfo
->
groupColumnList
)
:
0
;
// pInfo->currentGroupColData = calloc(1, (POINTER_BYTES * numOfCols + len));
int32_t
offset
=
POINTER_BYTES
*
numOfCols
;
int32_t
numOfCols
=
(
pInfo
->
orderColumnList
!=
NULL
)
?
(
int32_t
)
taosArrayGetSize
(
pInfo
->
orderColumnList
)
:
0
;
pInfo
->
prevRow
=
calloc
(
1
,
(
POINTER_BYTES
*
numOfCols
+
len
));
// for(int32_t i = 0; i < numOfCols; ++i) {
// pInfo->currentGroupColData[i] = (char*)pInfo->currentGroupColData + offset;
//
// SColIndex* index = taosArrayGet(pInfo->groupColumnList, i);
// offset += pExpr[index->colIndex].base.resSchema.bytes;
// }
int32_t
offset
=
POINTER_BYTES
*
numOfCols
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
pInfo
->
prevRow
[
i
]
=
(
char
*
)
pInfo
->
prevRow
+
offset
;
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
,
TSDB_DATA_TYPE_INT
);
SColIndex
*
index
=
taosArrayGet
(
pInfo
->
orderColumnList
,
i
);
// offset += pExpr[index->colIndex].base.colBytes;
}
}
int32_t
numOfRows
=
1
;
// setDefaultOutputBuf_rv(pExprInfo, numOfRows);
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
pOperator
->
name
=
"MultiwaySortOperator"
;
// pOperator->operatorType = OP_MultiwayMergeSort;
pOperator
->
blockingOptr
=
false
;
pOperator
->
name
=
"SortMerge"
;
pOperator
->
operatorType
=
OP_SortMerge
;
pOperator
->
blockingOptr
=
true
;
pOperator
->
status
=
OP_IN_EXECUTING
;
pOperator
->
info
=
pInfo
;
pOperator
->
p
RuntimeEnv
=
pRuntimeEnv
;
pOperator
->
p
Expr
=
exprArrayDup
(
pExprInfo
)
;
pOperator
->
numOfOutput
=
numOfOutput
;
pOperator
->
pExpr
=
pExpr
;
// pOperator->exec = doMultiwayMergeSort;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
exec
=
doSortMerge
;
pOperator
->
cleanupFn
=
destroyGlobalAggOperatorInfo
;
appendDownstream
(
pOperator
,
downstream
);
return
pOperator
;
}
typedef
struct
SExternalMemSource
{
SArray
*
pageIdList
;
int32_t
pageIndex
;
int32_t
sourceId
;
int32_t
rowIndex
;
SSDataBlock
*
pBlock
;
}
SExternalMemSource
;
...
...
@@ -5879,8 +5840,6 @@ static int32_t doAddNewSource(SOrderOperatorInfo* pInfo, SArray* pAllSources, in
}
pSource
->
pageIdList
=
getDataBufPagesIdList
(
pInfo
->
pSortInternalBuf
,
pInfo
->
sourceId
);
pSource
->
sourceId
=
pInfo
->
sourceId
;
pSource
->
pBlock
=
calloc
(
1
,
sizeof
(
SSDataBlock
));
pSource
->
pBlock
->
pDataBlock
=
taosArrayInit
(
numOfCols
,
sizeof
(
SColumnInfoData
));
pSource
->
pBlock
->
info
.
numOfCols
=
numOfCols
;
...
...
@@ -7197,17 +7156,6 @@ static int32_t initAggInfo(SAggOperatorInfo* pInfo, SArray* pExprInfo, int32_t n
return
TSDB_CODE_SUCCESS
;
}
static
SExprInfo
*
exprArrayDup
(
SArray
*
pExprInfo
)
{
size_t
numOfOutput
=
taosArrayGetSize
(
pExprInfo
);
SExprInfo
*
p
=
calloc
(
numOfOutput
,
sizeof
(
SExprInfo
));
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pExprInfo
);
++
i
)
{
SExprInfo
*
pExpr
=
taosArrayGetP
(
pExprInfo
,
i
);
assignExprInfo
(
&
p
[
i
],
pExpr
);
}
return
p
;
}
SOperatorInfo
*
createAggregateOperatorInfo
(
SOperatorInfo
*
downstream
,
SArray
*
pExprInfo
,
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
)
{
SAggOperatorInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SAggOperatorInfo
));
...
...
@@ -8198,12 +8146,12 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhyNode* pPhyNode, SExecTaskInfo* pTask
// Transfer the Array of STableKeyInfo into uid list.
size_t
numOfTables
=
taosArrayGetSize
(
pa
);
idList
=
taosArrayInit
(
numOfTables
,
sizeof
(
uint64_t
));
for
(
int32_t
i
=
0
;
i
<
numOfTables
;
++
i
)
{
STableKeyInfo
*
pkeyInfo
=
taosArrayGet
(
pa
,
i
);
taosArrayPush
(
idList
,
&
pkeyInfo
->
uid
);
}
idList
=
taosArrayInit
(
numOfTables
,
sizeof
(
uint64_t
));
}
else
{
idList
=
taosArrayInit
(
4
,
sizeof
(
uint64_t
));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录