Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e30eb2e4
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看板
提交
e30eb2e4
编写于
3月 12, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-13039] refactor.
上级
0271413a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
55 addition
and
62 deletion
+55
-62
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+11
-11
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+44
-51
未找到文件。
source/libs/executor/inc/executorimpl.h
浏览文件 @
e30eb2e4
...
...
@@ -521,8 +521,9 @@ typedef struct SProjectOperatorInfo {
}
SProjectOperatorInfo
;
typedef
struct
SLimitOperatorInfo
{
int64_t
limit
;
int64_t
total
;
SLimit
limit
;
int64_t
currentOffset
;
int64_t
currentRows
;
}
SLimitOperatorInfo
;
typedef
struct
SSLimitOperatorInfo
{
...
...
@@ -565,14 +566,15 @@ typedef struct SGroupbyOperatorInfo {
char
*
prevData
;
// previous group by value
}
SGroupbyOperatorInfo
;
typedef
struct
SS
Window
OperatorInfo
{
typedef
struct
SS
essionAgg
OperatorInfo
{
SOptrBasicInfo
binfo
;
SAggSupporter
aggSup
;
STimeWindow
curWindow
;
// current time window
TSKEY
prevTs
;
// previous timestamp
int32_t
numOfRows
;
// number of rows
int32_t
start
;
// start row index
bool
reptScan
;
// next round scan
}
SS
Window
OperatorInfo
;
}
SS
essionAgg
OperatorInfo
;
typedef
struct
SStateWindowOperatorInfo
{
SOptrBasicInfo
binfo
;
...
...
@@ -647,25 +649,23 @@ typedef struct SOrderOperatorInfo {
SOperatorInfo
*
createExchangeOperatorInfo
(
const
SNodeList
*
pSources
,
SSDataBlock
*
pBlock
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createTableScanOperatorInfo
(
void
*
pTsdbReadHandle
,
int32_t
order
,
int32_t
numOfOutput
,
int32_t
repeatTime
,
int32_t
reverseTime
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createTableSeqScanOperatorInfo
(
void
*
pTsdbReadHandle
,
STaskRuntimeEnv
*
pRuntimeEnv
);
SOperatorInfo
*
createAggregateOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
);
SOperatorInfo
*
createMultiTableAggOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResBlock
,
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
);
SOperatorInfo
*
createProjectOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
num
,
SSDataBlock
*
pResBlock
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createOrderOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SArray
*
pOrderVal
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createOrderOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SArray
*
pOrderVal
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createSortedMergeOperatorInfo
(
SOperatorInfo
**
downstream
,
int32_t
numOfDownstream
,
SExprInfo
*
pExprInfo
,
int32_t
num
,
SArray
*
pOrderVal
,
SArray
*
pGroupInfo
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createSysTableScanOperatorInfo
(
void
*
pSysTableReadHandle
,
const
SArray
*
pExprInfo
,
const
SSchema
*
pSchema
,
int32_t
tableType
,
SEpSet
epset
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createLimitOperatorInfo
(
SOperatorInfo
*
downstream
,
SLimit
*
pLimit
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createLimitOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
);
SOperatorInfo
*
createIntervalOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SInterval
*
pInterval
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createSessionAggOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResBlock
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createLimitOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
);
SOperatorInfo
*
createTableSeqScanOperatorInfo
(
void
*
pTsdbReadHandle
,
STaskRuntimeEnv
*
pRuntimeEnv
);
SOperatorInfo
*
createAllTimeIntervalOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createSWindowOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createFillOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
bool
multigroupResult
);
SOperatorInfo
*
createGroupbyOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
e30eb2e4
...
...
@@ -1692,7 +1692,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SGroupbyOperatorInfo *pIn
tfree
(
pInfo
->
prevData
);
}
static
void
doSessionWindowAggImpl
(
SOperatorInfo
*
pOperator
,
SS
Window
OperatorInfo
*
pInfo
,
SSDataBlock
*
pSDataBlock
)
{
static
void
doSessionWindowAggImpl
(
SOperatorInfo
*
pOperator
,
SS
essionAgg
OperatorInfo
*
pInfo
,
SSDataBlock
*
pSDataBlock
)
{
STaskRuntimeEnv
*
pRuntimeEnv
=
pOperator
->
pRuntimeEnv
;
STableQueryInfo
*
item
=
pRuntimeEnv
->
current
;
...
...
@@ -5613,7 +5613,7 @@ void setTableScanFilterOperatorInfo(STableScanInfo* pTableScanInfo, SOperatorInf
pTableScanInfo->pResultRowInfo = &pInfo->binfo.resultRowInfo;
pTableScanInfo->rowCellInfoOffset = pInfo->binfo.rowCellInfoOffset;
} else if (pDownstream->operatorType == OP_SessionWindow) {
SS
Window
OperatorInfo* pInfo = pDownstream->info;
SS
essionAgg
OperatorInfo* pInfo = pDownstream->info;
pTableScanInfo->pCtx = pInfo->binfo.pCtx;
pTableScanInfo->pResultRowInfo = &pInfo->binfo.resultRowInfo;
...
...
@@ -6431,46 +6431,47 @@ static SSDataBlock* doLimit(SOperatorInfo *pOperator, bool* newgroup) {
}
SLimitOperatorInfo
*
pInfo
=
pOperator
->
info
;
STaskRuntimeEnv
*
pRuntimeEnv
=
pOperator
->
pRuntimeEnv
;
SSDataBlock
*
pBlock
=
NULL
;
SOperatorInfo
*
pDownstream
=
pOperator
->
pDownstream
[
0
];
while
(
1
)
{
publishOperatorProfEvent
(
p
Operator
->
pDownstream
[
0
]
,
QUERY_PROF_BEFORE_OPERATOR_EXEC
);
pBlock
=
p
Operator
->
pDownstream
[
0
]
->
getNextFn
(
pOperator
->
pDownstream
[
0
]
,
newgroup
);
publishOperatorProfEvent
(
p
Operator
->
pDownstream
[
0
]
,
QUERY_PROF_AFTER_OPERATOR_EXEC
);
publishOperatorProfEvent
(
p
Downstream
,
QUERY_PROF_BEFORE_OPERATOR_EXEC
);
pBlock
=
p
Downstream
->
getNextFn
(
pDownstream
,
newgroup
);
publishOperatorProfEvent
(
p
Downstream
,
QUERY_PROF_AFTER_OPERATOR_EXEC
);
if
(
pBlock
==
NULL
)
{
doSetOperatorCompleted
(
pOperator
);
return
NULL
;
}
if
(
p
RuntimeEnv
->
currentOffset
==
0
)
{
if
(
p
Info
->
currentOffset
==
0
)
{
break
;
}
else
if
(
p
RuntimeEnv
->
currentOffset
>=
pBlock
->
info
.
rows
)
{
p
RuntimeEnv
->
currentOffset
-=
pBlock
->
info
.
rows
;
}
else
{
int32_t
remain
=
(
int32_t
)(
pBlock
->
info
.
rows
-
p
RuntimeEnv
->
currentOffset
);
}
else
if
(
p
Info
->
currentOffset
>=
pBlock
->
info
.
rows
)
{
p
Info
->
currentOffset
-=
pBlock
->
info
.
rows
;
}
else
{
// TODO handle the data movement
int32_t
remain
=
(
int32_t
)(
pBlock
->
info
.
rows
-
p
Info
->
currentOffset
);
pBlock
->
info
.
rows
=
remain
;
for
(
int32_t
i
=
0
;
i
<
pBlock
->
info
.
numOfCols
;
++
i
)
{
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
int16_t
bytes
=
pColInfoData
->
info
.
bytes
;
memmove
(
pColInfoData
->
pData
,
pColInfoData
->
pData
+
bytes
*
p
RuntimeEnv
->
currentOffset
,
remain
*
bytes
);
memmove
(
pColInfoData
->
pData
,
pColInfoData
->
pData
+
bytes
*
p
Info
->
currentOffset
,
remain
*
bytes
);
}
p
RuntimeEnv
->
currentOffset
=
0
;
p
Info
->
currentOffset
=
0
;
break
;
}
}
if
(
pInfo
->
total
+
pBlock
->
info
.
rows
>=
pInfo
->
limit
)
{
pBlock
->
info
.
rows
=
(
int32_t
)(
pInfo
->
limit
-
pInfo
->
total
);
pInfo
->
total
=
pInfo
->
limit
;
if
(
pInfo
->
currentRows
+
pBlock
->
info
.
rows
>=
pInfo
->
limit
.
limit
)
{
pBlock
->
info
.
rows
=
(
int32_t
)(
pInfo
->
limit
.
limit
-
pInfo
->
currentRows
);
pInfo
->
currentRows
=
pInfo
->
limit
.
limit
;
doSetOperatorCompleted
(
pOperator
);
}
else
{
pInfo
->
total
+=
pBlock
->
info
.
rows
;
pInfo
->
currentRows
+=
pBlock
->
info
.
rows
;
}
return
pBlock
;
...
...
@@ -6875,26 +6876,19 @@ static SSDataBlock* doSessionWindowAgg(SOperatorInfo *pOperator, bool* newgroup)
return
NULL
;
}
SS
Window
OperatorInfo
*
pWindowInfo
=
pOperator
->
info
;
SS
essionAgg
OperatorInfo
*
pWindowInfo
=
pOperator
->
info
;
SOptrBasicInfo
*
pBInfo
=
&
pWindowInfo
->
binfo
;
STaskRuntimeEnv
*
pRuntimeEnv
=
pOperator
->
pRuntimeEnv
;
if
(
pOperator
->
status
==
OP_RES_TO_RETURN
)
{
// toSDatablock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pBInfo->pRes);
if
(
pBInfo
->
pRes
->
info
.
rows
==
0
||
!
hasRemainDataInCurrentGroup
(
&
pRuntimeEnv
->
groupResInfo
))
{
if
(
pBInfo
->
pRes
->
info
.
rows
==
0
/* || !hasRemainDataInCurrentGroup(&pRuntimeEnv->groupResInfo)*/
)
{
pOperator
->
status
=
OP_EXEC_DONE
;
}
return
pBInfo
->
pRes
;
}
STaskAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
//pQueryAttr->order.order = TSDB_ORDER_ASC;
int32_t
order
=
pQueryAttr
->
order
.
order
;
STimeWindow
win
=
pQueryAttr
->
window
;
int32_t
order
=
TSDB_ORDER_ASC
;
SOperatorInfo
*
downstream
=
pOperator
->
pDownstream
[
0
];
while
(
1
)
{
...
...
@@ -6906,23 +6900,19 @@ static SSDataBlock* doSessionWindowAgg(SOperatorInfo *pOperator, bool* newgroup)
}
// the pDataBlock are always the same one, no need to call this again
setInputDataBlock
(
pOperator
,
pBInfo
->
pCtx
,
pBlock
,
pQueryAttr
->
order
.
order
);
setInputDataBlock
(
pOperator
,
pBInfo
->
pCtx
,
pBlock
,
order
);
doSessionWindowAggImpl
(
pOperator
,
pWindowInfo
,
pBlock
);
}
// restore the value
pQueryAttr
->
order
.
order
=
order
;
pQueryAttr
->
window
=
win
;
pOperator
->
status
=
OP_RES_TO_RETURN
;
closeAllResultRows
(
&
pBInfo
->
resultRowInfo
);
// setTaskStatus(pOperator->pTaskInfo, QUERY_COMPLETED);
finalizeQueryResult
(
pOperator
,
pBInfo
->
pCtx
,
&
pBInfo
->
resultRowInfo
,
pBInfo
->
rowCellInfoOffset
);
initGroupResInfo
(
&
pRuntimeEnv
->
groupResInfo
,
&
pBInfo
->
resultRowInfo
);
// initGroupResInfo(&pBInfo
->groupResInfo, &pBInfo->resultRowInfo);
// toSDatablock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pBInfo->pRes);
if
(
pBInfo
->
pRes
->
info
.
rows
==
0
||
!
hasRemainDataInCurrentGroup
(
&
pRuntimeEnv
->
groupResInfo
))
{
if
(
pBInfo
->
pRes
->
info
.
rows
==
0
/* || !hasRemainDataInCurrentGroup(&pRuntimeEnv->groupResInfo)*/
)
{
pOperator
->
status
=
OP_EXEC_DONE
;
}
...
...
@@ -7230,7 +7220,7 @@ static void destroyAggOperatorInfo(void* param, int32_t numOfOutput) {
}
static
void
destroySWindowOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
SS
WindowOperatorInfo
*
pInfo
=
(
SSWindow
OperatorInfo
*
)
param
;
SS
essionAggOperatorInfo
*
pInfo
=
(
SSessionAgg
OperatorInfo
*
)
param
;
doDestroyBasicInfo
(
&
pInfo
->
binfo
,
numOfOutput
);
}
...
...
@@ -7385,19 +7375,20 @@ SColumnInfo* extractColumnFilterInfo(SExprInfo* pExpr, int32_t numOfOutput, int3
return
0
;
}
SOperatorInfo
*
createLimitOperatorInfo
(
S
TaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
)
{
SOperatorInfo
*
createLimitOperatorInfo
(
S
OperatorInfo
*
downstream
,
SLimit
*
pLimit
,
SExecTaskInfo
*
pTaskInfo
)
{
SLimitOperatorInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SLimitOperatorInfo
));
pInfo
->
limit
=
pRuntimeEnv
->
pQueryAttr
->
limit
.
limit
;
pInfo
->
limit
=
*
pLimit
;
pInfo
->
currentOffset
=
pLimit
->
offset
;
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
pOperator
->
name
=
"LimitOperator"
;
// pOperator->operatorType =
OP_Limit
;
// pOperator->operatorType =
QUERY_NODE_PHYSICAL_PLAN_LIMIT
;
pOperator
->
blockingOptr
=
false
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
getNextFn
=
doLimit
;
pOperator
->
getNextFn
=
doLimit
;
pOperator
->
info
=
pInfo
;
pOperator
->
p
RuntimeEnv
=
pRuntimeEnv
;
pOperator
->
p
TaskInfo
=
pTaskInfo
;
int32_t
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
return
pOperator
;
...
...
@@ -7481,14 +7472,15 @@ SOperatorInfo* createStatewindowOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOper
pOperator
->
getNextFn
=
doStateWindowAgg
;
pOperator
->
closeFn
=
destroyStateWindowOperatorInfo
;
int32_t
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
int32_t
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
return
pOperator
;
}
SOperatorInfo
*
createSWindowOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
)
{
SSWindowOperatorInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SSWindowOperatorInfo
));
pInfo
->
binfo
.
pCtx
=
createSqlFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pInfo
->
binfo
.
rowCellInfoOffset
);
pInfo
->
binfo
.
pRes
=
createOutputBuf
(
pExpr
,
numOfOutput
,
pRuntimeEnv
->
resultInfo
.
capacity
);
SOperatorInfo
*
createSessionAggOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResBlock
,
SExecTaskInfo
*
pTaskInfo
)
{
SSessionAggOperatorInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SSessionAggOperatorInfo
));
doInitAggInfoSup
(
&
pInfo
->
aggSup
,
pInfo
->
binfo
.
pCtx
,
numOfCols
);
pInfo
->
binfo
.
pRes
=
pResBlock
;
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
);
pInfo
->
prevTs
=
INT64_MIN
;
...
...
@@ -7499,14 +7491,15 @@ SOperatorInfo* createSWindowOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperator
// pOperator->operatorType = OP_SessionWindow;
pOperator
->
blockingOptr
=
true
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
pExpr
=
pExpr
;
pOperator
->
numOfOutput
=
numOfOutput
;
pOperator
->
pExpr
=
pExprInfo
;
pOperator
->
numOfOutput
=
numOfCols
;
pOperator
->
info
=
pInfo
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
getNextFn
=
doSessionWindowAgg
;
pOperator
->
closeFn
=
destroySWindowOperator
Info
;
pOperator
->
getNextFn
=
doSessionWindowAgg
;
pOperator
->
closeFn
=
destroySWindowOperatorInfo
;
pOperator
->
pTaskInfo
=
pTask
Info
;
int32_t
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
int32_t
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
return
pOperator
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录