Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e6a4af8e
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
e6a4af8e
编写于
4月 15, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(query): refactor the executor module of query.
上级
774e4ad6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
45 addition
and
92 deletion
+45
-92
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+2
-4
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+43
-88
未找到文件。
source/libs/executor/inc/executorimpl.h
浏览文件 @
e6a4af8e
...
@@ -81,9 +81,9 @@ typedef struct SResultInfo { // TODO refactor
...
@@ -81,9 +81,9 @@ typedef struct SResultInfo { // TODO refactor
}
SResultInfo
;
}
SResultInfo
;
typedef
struct
STableQueryInfo
{
typedef
struct
STableQueryInfo
{
TSKEY
lastKey
;
// last check ts
TSKEY
lastKey
;
// last check ts
, todo remove it later
uint64_t
uid
;
// table uid
uint64_t
uid
;
// table uid
int32_t
groupIndex
;
// group id in table list
//
int32_t groupIndex; // group id in table list
// SVariant tag;
// SVariant tag;
SResultRowInfo
resInfo
;
// result info
SResultRowInfo
resInfo
;
// result info
}
STableQueryInfo
;
}
STableQueryInfo
;
...
@@ -645,8 +645,6 @@ SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOf
...
@@ -645,8 +645,6 @@ SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOf
SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntimeEnv* pRuntimeEnv);
SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntimeEnv* pRuntimeEnv);
SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream,
SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream,
SExprInfo* pExpr, int32_t numOfOutput);
SExprInfo* pExpr, int32_t numOfOutput);
SOperatorInfo* createAllMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream,
SExprInfo* pExpr, int32_t numOfOutput);
SOperatorInfo* createTagScanOperatorInfo(SReaderHandle* pReaderHandle, SExprInfo* pExpr, int32_t numOfOutput);
SOperatorInfo* createTagScanOperatorInfo(SReaderHandle* pReaderHandle, SExprInfo* pExpr, int32_t numOfOutput);
#endif
#endif
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
e6a4af8e
...
@@ -3173,17 +3173,14 @@ int32_t setTimestampListJoinInfo(STaskRuntimeEnv* pRuntimeEnv, SVariant* pTag, S
...
@@ -3173,17 +3173,14 @@ int32_t setTimestampListJoinInfo(STaskRuntimeEnv* pRuntimeEnv, SVariant* pTag, S
* merged during merge stage. In this case, we need the pTableQueryInfo->lastResRows to decide if there
* merged during merge stage. In this case, we need the pTableQueryInfo->lastResRows to decide if there
* is a previous result generated or not.
* is a previous result generated or not.
*/
*/
void
setIntervalQueryRange
(
STaskRuntimeEnv
*
pRuntimeEnv
,
TSKEY
key
)
{
void
setIntervalQueryRange
(
STableQueryInfo
*
pTableQueryInfo
,
TSKEY
key
,
STimeWindow
*
pQRange
)
{
STaskAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
STableQueryInfo
*
pTableQueryInfo
=
pRuntimeEnv
->
current
;
SResultRowInfo
*
pResultRowInfo
=
&
pTableQueryInfo
->
resInfo
;
SResultRowInfo
*
pResultRowInfo
=
&
pTableQueryInfo
->
resInfo
;
if
(
pResultRowInfo
->
curPos
!=
-
1
)
{
if
(
pResultRowInfo
->
curPos
!=
-
1
)
{
return
;
return
;
}
}
// pTableQueryInfo->win.skey = key;
// pTableQueryInfo->win.skey = key;
STimeWindow
win
=
{.
skey
=
key
,
.
ekey
=
pQ
ueryAttr
->
window
.
ekey
};
STimeWindow
win
=
{.
skey
=
key
,
.
ekey
=
pQ
Range
->
ekey
};
/**
/**
* In handling the both ascending and descending order super table query, we need to find the first qualified
* In handling the both ascending and descending order super table query, we need to find the first qualified
...
@@ -5082,8 +5079,8 @@ static SSDataBlock* doMultiTableAggregate(SOperatorInfo* pOperator, bool* newgro
...
@@ -5082,8 +5079,8 @@ static SSDataBlock* doMultiTableAggregate(SOperatorInfo* pOperator, bool* newgro
TSKEY_MIN_SUB
(
key
,
-
1
);
TSKEY_MIN_SUB
(
key
,
-
1
);
}
}
setExecutionContext
(
pOperator
->
numOfOutput
,
pAggInfo
->
current
->
groupIndex
,
key
,
pTaskInfo
,
pAggInfo
->
current
,
//
setExecutionContext(pOperator->numOfOutput, pAggInfo->current->groupIndex, key, pTaskInfo, pAggInfo->current,
pAggInfo
);
//
pAggInfo);
doAggregateImpl
(
pOperator
,
0
,
pInfo
->
pCtx
);
doAggregateImpl
(
pOperator
,
0
,
pInfo
->
pCtx
);
}
}
...
@@ -5288,21 +5285,22 @@ static SSDataBlock* doBuildIntervalResult(SOperatorInfo* pOperator, bool* newgro
...
@@ -5288,21 +5285,22 @@ static SSDataBlock* doBuildIntervalResult(SOperatorInfo* pOperator, bool* newgro
if
(
pInfo
->
execModel
==
OPTR_EXEC_MODEL_STREAM
)
{
if
(
pInfo
->
execModel
==
OPTR_EXEC_MODEL_STREAM
)
{
return
pOperator
->
getStreamResFn
(
pOperator
,
newgroup
);
return
pOperator
->
getStreamResFn
(
pOperator
,
newgroup
);
}
}
else
{
pTaskInfo
->
code
=
pOperator
->
_openFn
(
pOperator
);
if
(
pTaskInfo
->
code
!=
TSDB_CODE_SUCCESS
)
{
return
NULL
;
}
pTaskInfo
->
code
=
pOperator
->
_openFn
(
pOperator
);
blockDataEnsureCapacity
(
pInfo
->
binfo
.
pRes
,
pInfo
->
binfo
.
capacity
);
if
(
pTaskInfo
->
code
!=
TSDB_CODE_SUCCESS
)
{
toSDatablock
(
pInfo
->
binfo
.
pRes
,
pInfo
->
binfo
.
capacity
,
&
pInfo
->
groupResInfo
,
pOperator
->
pExpr
,
return
NULL
;
pInfo
->
aggSup
.
pResultBuf
,
pInfo
->
binfo
.
rowCellInfoOffset
);
}
blockDataEnsureCapacity
(
pInfo
->
binfo
.
pRes
,
pInfo
->
binfo
.
capacity
);
if
(
pInfo
->
binfo
.
pRes
->
info
.
rows
==
0
||
!
hasRemainDataInCurrentGroup
(
&
pInfo
->
groupResInfo
))
{
toSDatablock
(
pInfo
->
binfo
.
pRes
,
pInfo
->
binfo
.
capacity
,
&
pInfo
->
groupResInfo
,
pOperator
->
pExpr
,
pInfo
->
aggSup
.
pResultBuf
,
pInfo
->
binfo
.
rowCellInfoOffset
);
doSetOperatorCompleted
(
pOperator
);
}
if
(
pInfo
->
binfo
.
pRes
->
info
.
rows
==
0
||
!
hasRemainDataInCurrentGroup
(
&
pInfo
->
groupResInfo
))
{
return
pInfo
->
binfo
.
pRes
->
info
.
rows
==
0
?
NULL
:
pInfo
->
binfo
.
pRes
;
doSetOperatorCompleted
(
pOperator
);
}
}
return
pInfo
->
binfo
.
pRes
->
info
.
rows
==
0
?
NULL
:
pInfo
->
binfo
.
pRes
;
}
}
static
SSDataBlock
*
doStreamIntervalAgg
(
SOperatorInfo
*
pOperator
,
bool
*
newgroup
)
{
static
SSDataBlock
*
doStreamIntervalAgg
(
SOperatorInfo
*
pOperator
,
bool
*
newgroup
)
{
...
@@ -5411,20 +5409,18 @@ static SSDataBlock* doSTableIntervalAgg(SOperatorInfo* pOperator, bool* newgroup
...
@@ -5411,20 +5409,18 @@ static SSDataBlock* doSTableIntervalAgg(SOperatorInfo* pOperator, bool* newgroup
return
NULL
;
return
NULL
;
}
}
STableIntervalOperatorInfo
*
pIntervalInfo
=
pOperator
->
info
;
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
STaskRuntimeEnv
*
pRuntimeEnv
=
pOperator
->
pRuntimeEnv
;
STableIntervalOperatorInfo
*
pInfo
=
pOperator
->
info
;
if
(
pOperator
->
status
==
OP_RES_TO_RETURN
)
{
if
(
pOperator
->
status
==
OP_RES_TO_RETURN
)
{
int64_t
st
=
taosGetTimestampUs
();
int64_t
st
=
taosGetTimestampUs
();
if
(
pInfo
->
binfo
.
pRes
->
info
.
rows
==
0
||
!
hasRemainDataInCurrentGroup
(
&
pInfo
->
groupResInfo
))
{
// copyToSDataBlock(NULL, 3000, pIntervalInfo->pRes, pIntervalInfo->rowCellInfoOffset);
if
(
pIntervalInfo
->
binfo
.
pRes
->
info
.
rows
==
0
||
!
hasRemainData
(
&
pRuntimeEnv
->
groupResInfo
))
{
doSetOperatorCompleted
(
pOperator
);
doSetOperatorCompleted
(
pOperator
);
}
}
return
pIntervalInfo
->
binfo
.
pRes
;
return
pInfo
->
binfo
.
pRes
->
info
.
rows
==
0
?
NULL
:
pInfo
->
binfo
.
pRes
;
}
}
STaskAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
SOperatorInfo
*
downstream
=
pOperator
->
pDownstream
[
0
];
SOperatorInfo
*
downstream
=
pOperator
->
pDownstream
[
0
];
while
(
1
)
{
while
(
1
)
{
...
@@ -5437,25 +5433,30 @@ static SSDataBlock* doSTableIntervalAgg(SOperatorInfo* pOperator, bool* newgroup
...
@@ -5437,25 +5433,30 @@ static SSDataBlock* doSTableIntervalAgg(SOperatorInfo* pOperator, bool* newgroup
}
}
// the pDataBlock are always the same one, no need to call this again
// the pDataBlock are always the same one, no need to call this again
STableQueryInfo
*
pTableQueryInfo
=
pRuntimeEnv
->
current
;
// setTagValue(pOperator, pTableQueryInfo->pTable, pIntervalInfo->pCtx, pOperator->numOfOutput);
// setTagValue(pOperator, pTableQueryInfo->pTable, pIntervalInfo->pCtx, pOperator->numOfOutput);
setInputDataBlock
(
pOperator
,
pIn
tervalIn
fo
->
binfo
.
pCtx
,
pBlock
,
TSDB_ORDER_ASC
);
setInputDataBlock
(
pOperator
,
pInfo
->
binfo
.
pCtx
,
pBlock
,
TSDB_ORDER_ASC
);
setIntervalQueryRange
(
pRuntimeEnv
,
pBlock
->
info
.
window
.
skey
)
;
STableQueryInfo
*
pTableQueryInfo
=
pInfo
->
pCurrent
;
hashIntervalAgg
(
pOperator
,
&
pTableQueryInfo
->
resInfo
,
pBlock
,
pTableQueryInfo
->
groupIndex
);
setIntervalQueryRange
(
pTableQueryInfo
,
pBlock
->
info
.
window
.
skey
,
&
pTaskInfo
->
window
);
hashIntervalAgg
(
pOperator
,
&
pTableQueryInfo
->
resInfo
,
pBlock
,
pBlock
->
info
.
groupId
);
}
}
pOperator
->
status
=
OP_RES_TO_RETURN
;
closeAllResultRows
(
&
pInfo
->
binfo
.
resultRowInfo
)
;
doCloseAllTimeWindow
(
pRuntimeEnv
);
finalizeMultiTupleQueryResult
(
pInfo
->
binfo
.
pCtx
,
pOperator
->
numOfOutput
,
pInfo
->
aggSup
.
pResultBuf
,
setTaskStatus
(
pOperator
->
pTaskInfo
,
TASK_COMPLETED
);
&
pInfo
->
binfo
.
resultRowInfo
,
pInfo
->
binfo
.
rowCellInfoOffset
);
// copyToSDataBlock(pRuntimeEnv, 3000, pIntervalInfo->pRes, pIntervalInfo->rowCellInfoOffset);
initGroupResInfo
(
&
pInfo
->
groupResInfo
,
&
pInfo
->
binfo
.
resultRowInfo
);
if
(
pIntervalInfo
->
binfo
.
pRes
->
info
.
rows
==
0
||
!
hasRemainData
(
&
pRuntimeEnv
->
groupResInfo
))
{
OPTR_SET_OPENED
(
pOperator
);
pOperator
->
status
=
OP_EXEC_DONE
;
blockDataEnsureCapacity
(
pInfo
->
binfo
.
pRes
,
pInfo
->
binfo
.
capacity
);
toSDatablock
(
pInfo
->
binfo
.
pRes
,
pInfo
->
binfo
.
capacity
,
&
pInfo
->
groupResInfo
,
pOperator
->
pExpr
,
pInfo
->
aggSup
.
pResultBuf
,
pInfo
->
binfo
.
rowCellInfoOffset
);
if
(
pInfo
->
binfo
.
pRes
->
info
.
rows
==
0
||
!
hasRemainDataInCurrentGroup
(
&
pInfo
->
groupResInfo
))
{
doSetOperatorCompleted
(
pOperator
);
}
}
return
pIn
terval
Info
->
binfo
.
pRes
;
return
pIn
fo
->
binfo
.
pRes
->
info
.
rows
==
0
?
NULL
:
p
Info
->
binfo
.
pRes
;
}
}
static
SSDataBlock
*
doAllSTableIntervalAgg
(
SOperatorInfo
*
pOperator
,
bool
*
newgroup
)
{
static
SSDataBlock
*
doAllSTableIntervalAgg
(
SOperatorInfo
*
pOperator
,
bool
*
newgroup
)
{
...
@@ -5491,9 +5492,9 @@ static SSDataBlock* doAllSTableIntervalAgg(SOperatorInfo* pOperator, bool* newgr
...
@@ -5491,9 +5492,9 @@ static SSDataBlock* doAllSTableIntervalAgg(SOperatorInfo* pOperator, bool* newgr
// setTagValue(pOperator, pTableQueryInfo->pTable, pIntervalInfo->pCtx, pOperator->numOfOutput);
// setTagValue(pOperator, pTableQueryInfo->pTable, pIntervalInfo->pCtx, pOperator->numOfOutput);
// setInputDataBlock(pOperator, pIntervalInfo->binfo.pCtx, pBlock, pQueryAttr->order.order);
// setInputDataBlock(pOperator, pIntervalInfo->binfo.pCtx, pBlock, pQueryAttr->order.order);
setIntervalQueryRange
(
pRuntimeEnv
,
pBlock
->
info
.
window
.
skey
);
//
setIntervalQueryRange(pRuntimeEnv, pBlock->info.window.skey);
hashAllIntervalAgg
(
pOperator
,
&
pTableQueryInfo
->
resInfo
,
pBlock
,
pTableQueryInfo
->
groupIndex
);
//
hashAllIntervalAgg(pOperator, &pTableQueryInfo->resInfo, pBlock, pTableQueryInfo->groupIndex);
}
}
pOperator
->
status
=
OP_RES_TO_RETURN
;
pOperator
->
status
=
OP_RES_TO_RETURN
;
...
@@ -5874,7 +5875,7 @@ static STableQueryInfo* initTableQueryInfo(const STableGroupInfo* pTableGroupInf
...
@@ -5874,7 +5875,7 @@ static STableQueryInfo* initTableQueryInfo(const STableGroupInfo* pTableGroupInf
STableQueryInfo
*
pTQueryInfo
=
&
pTableQueryInfo
[
index
++
];
STableQueryInfo
*
pTQueryInfo
=
&
pTableQueryInfo
[
index
++
];
pTQueryInfo
->
uid
=
pk
->
uid
;
pTQueryInfo
->
uid
=
pk
->
uid
;
pTQueryInfo
->
lastKey
=
pk
->
lastKey
;
pTQueryInfo
->
lastKey
=
pk
->
lastKey
;
pTQueryInfo
->
groupIndex
=
i
;
//
pTQueryInfo->groupIndex = i;
}
}
}
}
...
@@ -6276,52 +6277,6 @@ _error:
...
@@ -6276,52 +6277,6 @@ _error:
return
NULL
;
return
NULL
;
}
}
SOperatorInfo
*
createMultiTableTimeIntervalOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
)
{
STableIntervalOperatorInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
STableIntervalOperatorInfo
));
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
);
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
pOperator
->
name
=
"MultiTableTimeIntervalOperator"
;
// pOperator->operatorType = OP_MultiTableTimeInterval;
pOperator
->
blockingOptr
=
true
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
pExpr
=
pExpr
;
pOperator
->
numOfOutput
=
numOfOutput
;
pOperator
->
info
=
pInfo
;
pOperator
->
getNextFn
=
doSTableIntervalAgg
;
pOperator
->
closeFn
=
destroyBasicOperatorInfo
;
int32_t
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
return
pOperator
;
}
SOperatorInfo
*
createAllMultiTableTimeIntervalOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
)
{
STableIntervalOperatorInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
STableIntervalOperatorInfo
));
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
);
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
pOperator
->
name
=
"AllMultiTableTimeIntervalOperator"
;
// pOperator->operatorType = OP_AllMultiTableTimeInterval;
pOperator
->
blockingOptr
=
true
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
pExpr
=
pExpr
;
pOperator
->
numOfOutput
=
numOfOutput
;
pOperator
->
info
=
pInfo
;
pOperator
->
getNextFn
=
doAllSTableIntervalAgg
;
pOperator
->
closeFn
=
destroyBasicOperatorInfo
;
int32_t
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
return
pOperator
;
}
static
int32_t
initFillInfo
(
SFillOperatorInfo
*
pInfo
,
SExprInfo
*
pExpr
,
int32_t
numOfCols
,
int64_t
*
fillVal
,
static
int32_t
initFillInfo
(
SFillOperatorInfo
*
pInfo
,
SExprInfo
*
pExpr
,
int32_t
numOfCols
,
int64_t
*
fillVal
,
STimeWindow
win
,
int32_t
capacity
,
const
char
*
id
,
SInterval
*
pInterval
,
int32_t
fillType
)
{
STimeWindow
win
,
int32_t
capacity
,
const
char
*
id
,
SInterval
*
pInterval
,
int32_t
fillType
)
{
struct
SFillColInfo
*
pColInfo
=
createFillColInfo
(
pExpr
,
numOfCols
,
(
int64_t
*
)
fillVal
);
struct
SFillColInfo
*
pColInfo
=
createFillColInfo
(
pExpr
,
numOfCols
,
(
int64_t
*
)
fillVal
);
...
@@ -7480,7 +7435,7 @@ SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOf
...
@@ -7480,7 +7435,7 @@ SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOf
pOperator
->
name
=
"JoinOperator"
;
pOperator
->
name
=
"JoinOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_JOIN
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_JOIN
;
pOperator
->
blockingOptr
=
tru
e
;
pOperator
->
blockingOptr
=
fals
e
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
pExpr
=
pExprInfo
;
pOperator
->
pExpr
=
pExprInfo
;
pOperator
->
numOfOutput
=
numOfCols
;
pOperator
->
numOfOutput
=
numOfCols
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录