Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b57f7414
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看板
提交
b57f7414
编写于
3月 10, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-13039] refactor.
上级
ddbe4095
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
59 addition
and
42 deletion
+59
-42
include/common/tcommon.h
include/common/tcommon.h
+18
-10
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+1
-1
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+40
-31
未找到文件。
include/common/tcommon.h
浏览文件 @
b57f7414
...
...
@@ -56,7 +56,7 @@ typedef struct SColumnDataAgg {
typedef
struct
SDataBlockInfo
{
STimeWindow
window
;
int32_t
rows
;
int32_t
tuple
Size
;
int32_t
row
Size
;
int32_t
numOfCols
;
union
{
int64_t
uid
;
int64_t
blockId
;};
}
SDataBlockInfo
;
...
...
@@ -70,10 +70,10 @@ typedef struct SConstantItem {
// info.numOfCols = taosArrayGetSize(pDataBlock) + taosArrayGetSize(pConstantList);
typedef
struct
SSDataBlock
{
SColumnDataAgg
*
pBlockAgg
;
SArray
*
pDataBlock
;
// SArray<SColumnInfoData>
SArray
*
pConstantList
;
// SArray<SConstantItem>, it is a constant/tags value of the corresponding result value.
SDataBlockInfo
info
;
SColumnDataAgg
*
pBlockAgg
;
SArray
*
pDataBlock
;
// SArray<SColumnInfoData>
SArray
*
pConstantList
;
// SArray<SConstantItem>, it is a constant/tags value of the corresponding result value.
SDataBlockInfo
info
;
}
SSDataBlock
;
typedef
struct
SVarColAttr
{
...
...
@@ -218,18 +218,17 @@ typedef struct SColumn {
int64_t
dataBlockId
;
};
char
name
[
TSDB_COL_NAME_LEN
];
int8_t
flag
;
// column type: normal column, tag, or user-input column (integer/float/string)
union
{
int16_t
colId
;
int16_t
slotId
;
};
char
name
[
TSDB_COL_NAME_LEN
];
int8_t
flag
;
// column type: normal column, tag, or user-input column (integer/float/string)
int16_t
type
;
int32_t
bytes
;
uint8_t
precision
;
uint8_t
scale
;
// SColumnInfo info;
}
SColumn
;
typedef
struct
SLimit
{
...
...
@@ -254,11 +253,20 @@ typedef struct SFunctParam {
}
SFunctParam
;
// the structure for sql function in select clause
typedef
struct
SResSchame
{
int8_t
type
;
int32_t
colId
;
int32_t
bytes
;
int32_t
precision
;
int32_t
scale
;
char
name
[
TSDB_COL_NAME_LEN
];
}
SResSchema
;
// TODO move away to executor.h
typedef
struct
SExprBasicInfo
{
S
Schema
resSchema
;
// TODO refactor
S
ResSchema
resSchema
;
int16_t
numOfParams
;
// argument value of each function
SFunctParam
*
pParam
;
// SVariant param[3]; // parameters are not more than 3
}
SExprBasicInfo
;
typedef
struct
SExprInfo
{
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
b57f7414
...
...
@@ -632,7 +632,7 @@ typedef struct SOrderOperatorInfo {
uint64_t
totalElapsed
;
// total elapsed time
}
SOrderOperatorInfo
;
SOperatorInfo
*
createExchangeOperatorInfo
(
const
S
Array
*
pSources
,
const
SArray
*
pExprInfo
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createExchangeOperatorInfo
(
const
S
NodeList
*
pSources
,
const
SArray
*
pExprInfo
,
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
);
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
b57f7414
...
...
@@ -347,6 +347,7 @@ SSDataBlock* createOutputBuf_rv1(SDataBlockDescNode* pNode) {
pBlock
->
pDataBlock
=
taosArrayInit
(
numOfCols
,
sizeof
(
SColumnInfoData
));
pBlock
->
info
.
blockId
=
pNode
->
dataBlockId
;
pBlock
->
info
.
rowSize
=
pNode
->
resultRowSize
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
idata
=
{{
0
}};
...
...
@@ -683,12 +684,6 @@ static STimeWindow getActiveTimeWindow(SResultRowInfo * pResultRowInfo, int64_t
w
.
ekey
=
w
.
skey
+
pInterval
->
interval
-
1
;
}
}
/*
* query border check, skey should not be bounded by the query time range, since the value skey will
* be used as the time window index value. So we only change ekey of time window accordingly.
*/
// ASSERT(win->skey <= win->ekey); // todo no need this
return
w
;
}
...
...
@@ -3348,14 +3343,13 @@ void setFunctionResultOutput(SOptrBasicInfo* pInfo, SAggSupporter* pSup, int32_t
cleanupResultRowEntry
(
pEntry
);
pCtx
[
i
].
resultInfo
=
pEntry
;
pCtx
[
i
].
pOutput
=
pData
->
pData
;
// todo remove it
pCtx
[
i
].
currentStage
=
stage
;
// set the timestamp output buffer for top/bottom/diff query
int32_t
fid
=
pCtx
[
i
].
functionId
;
if
(
fid
==
FUNCTION_TOP
||
fid
==
FUNCTION_BOTTOM
||
fid
==
FUNCTION_DIFF
||
fid
==
FUNCTION_DERIVATIVE
)
{
if
(
i
>
0
)
pCtx
[
i
].
ptsOutputBuf
=
pCtx
[
i
-
1
].
pOutput
;
}
//
int32_t fid = pCtx[i].functionId;
//
if (fid == FUNCTION_TOP || fid == FUNCTION_BOTTOM || fid == FUNCTION_DIFF || fid == FUNCTION_DERIVATIVE) {
//
if (i > 0) pCtx[i].ptsOutputBuf = pCtx[i-1].pOutput;
//
}
}
initCtxOutputBuffer
(
pCtx
,
pDataBlock
->
info
.
numOfCols
);
...
...
@@ -3663,7 +3657,7 @@ void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, i
* all group belong to one result set, and each group result has different group id so set the id to be one
*/
if
(
pResultRow
->
pageId
==
-
1
)
{
int32_t
ret
=
addNewWindowResultBuf
(
pResultRow
,
pAggInfo
->
pResultBuf
,
tableGroupId
,
pAggInfo
->
binfo
.
pRes
->
info
.
tuple
Size
);
int32_t
ret
=
addNewWindowResultBuf
(
pResultRow
,
pAggInfo
->
pResultBuf
,
tableGroupId
,
pAggInfo
->
binfo
.
pRes
->
info
.
row
Size
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
return
;
}
...
...
@@ -5187,9 +5181,10 @@ static SSDataBlock* doLoadRemoteData(void* param, bool* newgroup) {
#endif
}
// TODO remove it
static
SSDataBlock
*
createResultDataBlock
(
const
SArray
*
pExprInfo
);
SOperatorInfo
*
createExchangeOperatorInfo
(
const
S
Array
*
pSources
,
const
SArray
*
pExprInfo
,
SExecTaskInfo
*
pTaskInfo
)
{
SOperatorInfo
*
createExchangeOperatorInfo
(
const
S
NodeList
*
pSources
,
const
SArray
*
pExprInfo
,
SExecTaskInfo
*
pTaskInfo
)
{
SExchangeInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SExchangeInfo
));
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
...
...
@@ -5200,9 +5195,9 @@ SOperatorInfo* createExchangeOperatorInfo(const SArray* pSources, const SArray*
return
NULL
;
}
size_t
numOfSources
=
taosArrayGetSize
(
pSources
);
size_t
numOfSources
=
LIST_LENGTH
(
pSources
);
pInfo
->
pSources
=
taosArrayDup
(
pSources
);
//
pInfo->pSources = taosArrayDup(pSources);
pInfo
->
pSourceDataInfo
=
taosArrayInit
(
numOfSources
,
sizeof
(
SSourceDataInfo
));
if
(
pInfo
->
pSourceDataInfo
==
NULL
||
pInfo
->
pSources
==
NULL
)
{
tfree
(
pInfo
);
...
...
@@ -5222,8 +5217,8 @@ SOperatorInfo* createExchangeOperatorInfo(const SArray* pSources, const SArray*
taosArrayPush
(
pInfo
->
pSourceDataInfo
,
&
dataInfo
);
}
size_t
size
=
taosArrayGetSize
(
pExprInfo
);
pInfo
->
pResult
=
createResultDataBlock
(
pExprInfo
);
size_t
size
=
taosArrayGetSize
(
pExprInfo
);
pInfo
->
pResult
=
createResultDataBlock
(
pExprInfo
);
pInfo
->
seqLoadData
=
true
;
tsem_init
(
&
pInfo
->
ready
,
0
,
0
);
...
...
@@ -5277,11 +5272,12 @@ SSDataBlock* createResultDataBlock(const SArray* pExprInfo) {
SColumnInfoData
colInfoData
=
{
0
};
SExprInfo
*
p
=
taosArrayGetP
(
pExprInfo
,
i
);
SSchema
*
pSchema
=
&
p
->
base
.
resSchema
;
S
Res
Schema
*
pSchema
=
&
p
->
base
.
resSchema
;
colInfoData
.
info
.
type
=
pSchema
->
type
;
colInfoData
.
info
.
colId
=
pSchema
->
colId
;
colInfoData
.
info
.
bytes
=
pSchema
->
bytes
;
colInfoData
.
info
.
scale
=
pSchema
->
scale
;
colInfoData
.
info
.
precision
=
pSchema
->
precision
;
taosArrayPush
(
pResult
,
&
colInfoData
);
}
...
...
@@ -8016,9 +8012,19 @@ static int32_t deserializeColFilterInfo(SColumnFilterInfo* pColFilters, int16_t
return
TSDB_CODE_SUCCESS
;
}
SArray
*
createExprInfo
(
SAggPhysiNode
*
pPhyNode
,
int32_t
*
resultRowSize
)
{
*
resultRowSize
=
pPhyNode
->
node
.
pOutputDataBlockDesc
->
resultRowSize
;
static
SResSchema
createResSchema
(
int32_t
type
,
int32_t
bytes
,
int32_t
slotId
,
int32_t
scale
,
int32_t
precision
,
const
char
*
name
)
{
SResSchema
s
=
{
0
};
s
.
scale
=
scale
;
s
.
precision
=
precision
;
s
.
type
=
type
;
s
.
bytes
=
bytes
;
s
.
colId
=
slotId
;
strncpy
(
s
.
name
,
name
,
tListLen
(
s
.
name
));
return
s
;
}
SArray
*
createExprInfo
(
SAggPhysiNode
*
pPhyNode
)
{
int32_t
numOfAggFuncs
=
LIST_LENGTH
(
pPhyNode
->
pAggFuncs
);
SArray
*
pArray
=
taosArrayInit
(
numOfAggFuncs
,
POINTER_BYTES
);
...
...
@@ -8038,9 +8044,12 @@ SArray* createExprInfo(SAggPhysiNode* pPhyNode, int32_t* resultRowSize) {
ASSERT
(
pTargetNode
->
slotId
==
i
);
SFunctionNode
*
pFuncNode
=
(
SFunctionNode
*
)
pTargetNode
->
pExpr
;
pExp
->
base
.
resSchema
=
createSchema
(
pFuncNode
->
node
.
resType
.
type
,
pFuncNode
->
node
.
resType
.
bytes
,
pTargetNode
->
slotId
,
pFuncNode
->
node
.
aliasName
);
pExp
->
pExpr
->
_function
.
pFunctNode
=
pFuncNode
;
SDataType
*
pType
=
&
pFuncNode
->
node
.
resType
;
pExp
->
base
.
resSchema
=
createResSchema
(
pType
->
type
,
pType
->
bytes
,
pTargetNode
->
slotId
,
pType
->
scale
,
pType
->
precision
,
pFuncNode
->
node
.
aliasName
);
pExp
->
pExpr
->
_function
.
pFunctNode
=
pFuncNode
;
strncpy
(
pExp
->
pExpr
->
_function
.
functionName
,
pFuncNode
->
functionName
,
tListLen
(
pExp
->
pExpr
->
_function
.
functionName
));
// TODO: value parameter needs to be handled
...
...
@@ -8089,16 +8098,17 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTa
if
(
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
==
nodeType
(
pPhyNode
))
{
SScanPhysiNode
*
pScanPhyNode
=
(
SScanPhysiNode
*
)
pPhyNode
;
size_t
numOfCols
=
LIST_LENGTH
(
pScanPhyNode
->
pScanCols
);
tsdbReaderT
pDataReader
=
doCreateDataReader
((
STableScanPhysiNode
*
)
pPhyNode
,
pHandle
,
(
uint64_t
)
queryId
,
taskId
);
size_t
numOfCols
=
LIST_LENGTH
(
pScanPhyNode
->
pScanCols
);
tsdbReaderT
pDataReader
=
doCreateDataReader
((
STableScanPhysiNode
*
)
pPhyNode
,
pHandle
,
(
uint64_t
)
queryId
,
taskId
);
int32_t
code
=
doCreateTableGroup
(
pHandle
->
meta
,
pScanPhyNode
->
tableType
,
pScanPhyNode
->
uid
,
pTableGroupInfo
,
queryId
,
taskId
);
return
createTableScanOperatorInfo
(
pDataReader
,
pScanPhyNode
->
order
,
numOfCols
,
pScanPhyNode
->
count
,
pScanPhyNode
->
reverse
,
pTaskInfo
);
return
createTableScanOperatorInfo
(
pDataReader
,
pScanPhyNode
->
order
,
numOfCols
,
pScanPhyNode
->
count
,
pScanPhyNode
->
reverse
,
pTaskInfo
);
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
==
nodeType
(
pPhyNode
))
{
// SExchangePhysiNode* pEx = (SExchangePhysiNode*)
pPhyNode;
// return createExchangeOperatorInfo(pEx->pSrcEndPoints, pEx->node.pTargets
, pTaskInfo);
SExchangePhysiNode
*
pEx
=
(
SExchangePhysiNode
*
)
pPhyNode
;
return
createExchangeOperatorInfo
(
pEx
->
pSrcEndPoints
,
NULL
,
pTaskInfo
);
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
==
nodeType
(
pPhyNode
))
{
SScanPhysiNode
*
pScanPhyNode
=
(
SScanPhysiNode
*
)
pPhyNode
;
// simple child table.
SScanPhysiNode
*
pScanPhyNode
=
(
SScanPhysiNode
*
)
pPhyNode
;
// simple child table.
STableGroupInfo
groupInfo
=
{
0
};
int32_t
code
=
doCreateTableGroup
(
pHandle
->
meta
,
pScanPhyNode
->
tableType
,
pScanPhyNode
->
uid
,
&
groupInfo
,
queryId
,
taskId
);
...
...
@@ -8136,8 +8146,7 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTa
SPhysiNode
*
pChildNode
=
(
SPhysiNode
*
)
nodesListGetNode
(
pPhyNode
->
pChildren
,
i
);
SOperatorInfo
*
op
=
doCreateOperatorTreeNode
(
pChildNode
,
pTaskInfo
,
pHandle
,
queryId
,
taskId
,
pTableGroupInfo
);
int32_t
resultRowSize
=
0
;
SArray
*
pExprInfo
=
createExprInfo
((
SAggPhysiNode
*
)
pPhyNode
,
&
resultRowSize
);
SArray
*
pExprInfo
=
createExprInfo
((
SAggPhysiNode
*
)
pPhyNode
);
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pPhyNode
->
pOutputDataBlockDesc
);
return
createAggregateOperatorInfo
(
op
,
pExprInfo
,
pResBlock
,
pTaskInfo
,
pTableGroupInfo
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录