Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
46242e8a
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
46242e8a
编写于
3月 18, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-13039] refactor.
上级
0354ac2f
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
186 addition
and
141 deletion
+186
-141
source/dnode/mnode/impl/src/mndInfoSchema.c
source/dnode/mnode/impl/src/mndInfoSchema.c
+1
-1
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+19
-3
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+3
-2
source/libs/executor/src/dataDispatcher.c
source/libs/executor/src/dataDispatcher.c
+7
-3
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+154
-130
source/libs/executor/test/executorTests.cpp
source/libs/executor/test/executorTests.cpp
+2
-2
未找到文件。
source/dnode/mnode/impl/src/mndInfoSchema.c
浏览文件 @
46242e8a
...
...
@@ -118,7 +118,7 @@ static const SInfosTableSchema userUsersSchema[] = {{.name = "name", .
static
const
SInfosTableSchema
vgroupsSchema
[]
=
{{.
name
=
"vgroup_id"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"db_name"
,
.
bytes
=
(
TSDB_DB_NAME_LEN
-
1
)
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"tables"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"status"
,
.
bytes
=
1
0
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"status"
,
.
bytes
=
1
2
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
{.
name
=
"onlines"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"v1_dnode"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"v1_status"
,
.
bytes
=
10
,
.
type
=
TSDB_DATA_TYPE_BINARY
},
...
...
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
46242e8a
...
...
@@ -701,7 +701,7 @@ static int32_t mndRetrieveVnodes(SMnodeMsg *pReq, SShowObj *pShow, char *data, i
SVgObj
*
pVgroup
=
NULL
;
char
*
pWrite
;
int32_t
cols
=
0
;
int32_t
dnodeId
=
pShow
->
replica
;
//
int32_t dnodeId = pShow->replica;
while
(
numOfRows
<
rows
)
{
pShow
->
pIter
=
sdbFetch
(
pSdb
,
SDB_VGROUP
,
pShow
->
pIter
,
(
void
**
)
&
pVgroup
);
...
...
@@ -709,17 +709,33 @@ static int32_t mndRetrieveVnodes(SMnodeMsg *pReq, SShowObj *pShow, char *data, i
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
replica
&&
numOfRows
<
rows
;
++
i
)
{
SVnodeGid
*
pVgid
=
&
pVgroup
->
vnodeGid
[
i
];
if
(
pVgid
->
dnodeId
!=
dnodeId
)
continue
;
cols
=
0
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
uint32_t
*
)
pWrite
=
pVgroup
->
vgId
;
cols
++
;
SName
name
=
{
0
};
char
db
[
TSDB_DB_NAME_LEN
]
=
{
0
};
tNameFromString
(
&
name
,
pVgroup
->
dbName
,
T_NAME_ACCT
|
T_NAME_DB
);
tNameGetDbName
(
&
name
,
db
);
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
STR_TO_VARSTR
(
pWrite
,
db
);
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
uint32_t
*
)
pWrite
=
0
;
//todo: Tables
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
STR_TO_VARSTR
(
pWrite
,
mndGetRoleStr
(
pVgid
->
role
));
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
uint32_t
*
)
pWrite
=
pVgroup
->
replica
;
//onlines
cols
++
;
numOfRows
++
;
}
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
46242e8a
...
...
@@ -493,7 +493,8 @@ typedef struct SAggOperatorInfo {
typedef
struct
SProjectOperatorInfo
{
SOptrBasicInfo
binfo
;
SSDataBlock
*
existDataBlock
;
SSDataBlock
*
existDataBlock
;
int32_t
threshold
;
}
SProjectOperatorInfo
;
typedef
struct
SLimitOperatorInfo
{
...
...
@@ -626,7 +627,7 @@ SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order,
SOperatorInfo
*
createTableSeqScanOperatorInfo
(
void
*
pTsdbReadHandle
,
STaskRuntimeEnv
*
pRuntimeEnv
);
SOperatorInfo
*
createAggregateOperatorInfo
(
SOperatorInfo
*
downstream
,
SArray
*
pExprInfo
,
SSDataBlock
*
pResultBlock
,
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
);
SOperatorInfo
*
createMultiTableAggOperatorInfo
(
SOperatorInfo
*
downstream
,
SArray
*
pExprInfo
,
SSDataBlock
*
pResultBlock
,
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
);
SOperatorInfo
*
createProjectOperatorInfo
(
SOperatorInfo
*
downstream
,
SArray
*
pExprInfo
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createProjectOperatorInfo
(
SOperatorInfo
*
downstream
,
SArray
*
pExprInfo
,
S
SDataBlock
*
pResBlock
,
S
ExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createSysTableScanOperatorInfo
(
void
*
pSysTableReadHandle
,
SSDataBlock
*
pResBlock
,
const
SName
*
pName
,
SNode
*
pCondition
,
SEpSet
epset
,
SExecTaskInfo
*
pTaskInfo
);
...
...
source/libs/executor/src/dataDispatcher.c
浏览文件 @
46242e8a
...
...
@@ -15,11 +15,12 @@
#include "dataSinkInt.h"
#include "dataSinkMgt.h"
#include "executorimpl.h"
#include "planner.h"
#include "tcompression.h"
#include "tglobal.h"
#include "tqueue.h"
#include "
executorimpl
.h"
#include "
tdatablock
.h"
typedef
struct
SDataDispatchBuf
{
int32_t
useSize
;
...
...
@@ -84,8 +85,11 @@ static void copyData(const SInputData* pInput, const SDataBlockDescNode* pSchema
*
compLen
+=
compSizes
[
col
];
compSizes
[
col
]
=
htonl
(
compSizes
[
col
]);
}
else
{
memmove
(
data
,
pColRes
->
pData
,
pColRes
->
info
.
bytes
*
pInput
->
pData
->
info
.
rows
);
data
+=
pColRes
->
info
.
bytes
*
pInput
->
pData
->
info
.
rows
;
for
(
int32_t
i
=
0
;
i
<
pInput
->
pData
->
info
.
rows
;
++
i
)
{
char
*
pData
=
colDataGetData
(
pColRes
,
i
);
memmove
(
data
,
pData
,
pColRes
->
info
.
bytes
);
data
+=
pColRes
->
info
.
bytes
;
}
}
}
}
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
46242e8a
...
...
@@ -1183,13 +1183,6 @@ static void doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx,
ASSERT
(
pCtx
[
i
].
input
.
pData
[
0
]
!=
NULL
);
// if (pCtx[i].functionId < 0) {
// SColumnInfoData* tsInfo = taosArrayGet(pBlock->pDataBlock, 0);
// pCtx[i].ptsList = (int64_t*) tsInfo->pData;
// continue;
// }
// uint32_t status = aAggs[pCtx[i].functionId].status;
// if ((status & (FUNCSTATE_SELECTIVITY | FUNCSTATE_NEED_TS)) != 0) {
// SColumnInfoData* tsInfo = taosArrayGet(pBlock->pDataBlock, 0);
...
...
@@ -1224,27 +1217,17 @@ static void doAggregateImpl(SOperatorInfo* pOperator, TSKEY startTs, SqlFunction
}
}
static
void
projectApplyFunctions
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
)
{
STaskAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
static
void
projectApplyFunctions
(
SSDataBlock
*
pResult
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
)
{
for
(
int32_t
k
=
0
;
k
<
numOfOutput
;
++
k
)
{
pCtx
[
k
].
startTs
=
pQueryAttr
->
window
.
skey
;
// Always set the asc order for merge stage process
if
(
pCtx
[
k
].
currentStage
==
MERGE_STAGE
)
{
pCtx
[
k
].
order
=
TSDB_ORDER_ASC
;
}
pCtx
[
k
].
startTs
=
pQueryAttr
->
window
.
skey
;
if
(
pCtx
[
k
].
fpSet
.
init
==
NULL
)
{
// it is a project query
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pResult
->
pDataBlock
,
k
);
memcpy
(
pColInfoData
->
pData
,
pCtx
[
k
].
input
.
pData
[
0
]
->
pData
,
colDataGetLength
(
pColInfoData
,
pCtx
[
k
].
input
.
numOfRows
));
}
else
{
// TODO: arithmetic and other process.
if
(
pCtx
[
k
].
functionId
<
0
)
{
// load the script and exec
// SUdfInfo* pUdfInfo = pRuntimeEnv->pUdfInfo;
// doInvokeUdf(pUdfInfo, &pCtx[k], 0, TSDB_UDF_FUNC_NORMAL);
// } else {
// aAggs[pCtx[k].functionId].xFunction(&pCtx[k]);
}
}
pResult
->
info
.
rows
=
pCtx
[
0
].
input
.
numOfRows
;
}
void
doTimeWindowInterpolation
(
SOperatorInfo
*
pOperator
,
SOptrBasicInfo
*
pInfo
,
SArray
*
pDataBlock
,
TSKEY
prevTs
,
...
...
@@ -2049,9 +2032,14 @@ static SqlFunctionCtx* createSqlFunctionCtx_rv(SArray* pExprInfo, int32_t** rowC
SExprBasicInfo
*
pFunct
=
&
pExpr
->
base
;
SqlFunctionCtx
*
pCtx
=
&
pFuncCtx
[
i
];
fmGetFuncExecFuncs
(
pExpr
->
pExpr
->
_function
.
pFunctNode
->
funcId
,
&
pCtx
->
fpSet
);
pCtx
->
input
.
numOfInputCols
=
pFunct
->
numOfParams
;
if
(
pExpr
->
pExpr
->
_function
.
pFunctNode
!=
NULL
)
{
SFuncExecEnv
env
=
{
0
};
fmGetFuncExecFuncs
(
pExpr
->
pExpr
->
_function
.
pFunctNode
->
funcId
,
&
pCtx
->
fpSet
);
pCtx
->
fpSet
.
getEnv
(
pExpr
->
pExpr
->
_function
.
pFunctNode
,
&
env
);
pCtx
->
resDataInfo
.
interBufSize
=
env
.
calcMemSize
;
}
pCtx
->
input
.
numOfInputCols
=
pFunct
->
numOfParams
;
pCtx
->
input
.
pData
=
calloc
(
pFunct
->
numOfParams
,
POINTER_BYTES
);
pCtx
->
input
.
pColumnDataAgg
=
calloc
(
pFunct
->
numOfParams
,
POINTER_BYTES
);
...
...
@@ -2061,10 +2049,6 @@ static SqlFunctionCtx* createSqlFunctionCtx_rv(SArray* pExprInfo, int32_t** rowC
pCtx
->
order
=
TSDB_ORDER_ASC
;
pCtx
->
start
.
key
=
INT64_MIN
;
pCtx
->
end
.
key
=
INT64_MIN
;
SFuncExecEnv
env
=
{
0
};
pCtx
->
fpSet
.
getEnv
(
pExpr
->
pExpr
->
_function
.
pFunctNode
,
&
env
);
pCtx
->
resDataInfo
.
interBufSize
=
env
.
calcMemSize
;
#if 0
for (int32_t j = 0; j < pCtx->numOfParams; ++j) {
// int16_t type = pFunct->param[j].nType;
...
...
@@ -5423,6 +5407,47 @@ static int32_t loadSysTableContentCb(void* param, const SDataBuf* pMsg, int32_t
tsem_post
(
&
pScanResInfo
->
ready
);
}
static
SSDataBlock
*
doFilterResult
(
SSysTableScanInfo
*
pInfo
)
{
if
(
pInfo
->
pCondition
==
NULL
)
{
return
pInfo
->
pRes
->
info
.
rows
==
0
?
NULL
:
pInfo
->
pRes
;
}
SFilterInfo
*
filter
=
NULL
;
int32_t
code
=
filterInitFromNode
(
pInfo
->
pCondition
,
&
filter
,
0
);
SFilterColumnParam
param1
=
{.
numOfCols
=
pInfo
->
pRes
->
info
.
numOfCols
,
.
pDataBlock
=
pInfo
->
pRes
->
pDataBlock
};
code
=
filterSetDataFromSlotId
(
filter
,
&
param1
);
int8_t
*
rowRes
=
NULL
;
bool
keep
=
filterExecute
(
filter
,
pInfo
->
pRes
,
&
rowRes
,
NULL
,
param1
.
numOfCols
);
SSDataBlock
*
px
=
createOneDataBlock
(
pInfo
->
pRes
);
blockDataEnsureCapacity
(
px
,
pInfo
->
pRes
->
info
.
rows
);
//TODO refactor
int32_t
numOfRow
=
0
;
for
(
int32_t
i
=
0
;
i
<
pInfo
->
pRes
->
info
.
numOfCols
;
++
i
)
{
SColumnInfoData
*
pDest
=
taosArrayGet
(
px
->
pDataBlock
,
i
);
SColumnInfoData
*
pSrc
=
taosArrayGet
(
pInfo
->
pRes
->
pDataBlock
,
i
);
numOfRow
=
0
;
for
(
int32_t
j
=
0
;
j
<
pInfo
->
pRes
->
info
.
rows
;
++
j
)
{
if
(
rowRes
[
j
]
==
0
)
{
continue
;
}
colDataAppend
(
pDest
,
numOfRow
,
colDataGetData
(
pSrc
,
j
),
false
);
numOfRow
+=
1
;
}
}
px
->
info
.
rows
=
numOfRow
;
pInfo
->
pRes
=
px
;
return
pInfo
->
pRes
->
info
.
rows
==
0
?
NULL
:
pInfo
->
pRes
;
}
static
SSDataBlock
*
doSysTableScan
(
void
*
param
,
bool
*
newgroup
)
{
// build message and send to mnode to fetch the content of system tables.
SOperatorInfo
*
pOperator
=
(
SOperatorInfo
*
)
param
;
...
...
@@ -5457,7 +5482,6 @@ static SSDataBlock* doSysTableScan(void* param, bool* newgroup) {
int64_t
startTs
=
taosGetTimestampUs
();
pInfo
->
req
.
type
=
pInfo
->
type
;
// tNameGetFullDbName(&pInfo->name, pInfo->req.db);
strncpy
(
pInfo
->
req
.
tb
,
tNameGetTableName
(
&
pInfo
->
name
),
tListLen
(
pInfo
->
req
.
tb
));
int32_t
contLen
=
tSerializeSRetrieveTableReq
(
NULL
,
0
,
&
pInfo
->
req
);
...
...
@@ -5496,42 +5520,7 @@ static SSDataBlock* doSysTableScan(void* param, bool* newgroup) {
setSDataBlockFromFetchRsp
(
pInfo
->
pRes
,
&
pInfo
->
loadInfo
,
pTableRsp
->
numOfRows
,
pTableRsp
->
data
,
pTableRsp
->
compLen
,
pOperator
->
numOfOutput
,
startTs
,
NULL
);
// do filter the qualified results
{
SFilterInfo
*
filter
=
NULL
;
code
=
filterInitFromNode
(
pInfo
->
pCondition
,
&
filter
,
0
);
SFilterColumnParam
param1
=
{.
numOfCols
=
pInfo
->
pRes
->
info
.
numOfCols
,
.
pDataBlock
=
pInfo
->
pRes
->
pDataBlock
};
code
=
filterSetDataFromSlotId
(
filter
,
&
param1
);
int8_t
*
rowRes
=
NULL
;
bool
keep
=
filterExecute
(
filter
,
pInfo
->
pRes
,
&
rowRes
,
NULL
,
param1
.
numOfCols
);
printf
(
"%d, %d
\n
"
,
rowRes
[
0
],
rowRes
[
1
]);
SSDataBlock
*
px
=
createOneDataBlock
(
pInfo
->
pRes
);
blockDataEnsureCapacity
(
px
,
pInfo
->
pRes
->
info
.
rows
);
int32_t
numOfRow
=
0
;
for
(
int32_t
i
=
0
;
i
<
pInfo
->
pRes
->
info
.
numOfCols
;
++
i
)
{
SColumnInfoData
*
pDest
=
taosArrayGet
(
px
->
pDataBlock
,
i
);
SColumnInfoData
*
pSrc
=
taosArrayGet
(
pInfo
->
pRes
->
pDataBlock
,
i
);
numOfRow
=
0
;
for
(
int32_t
j
=
0
;
j
<
pInfo
->
pRes
->
info
.
rows
;
++
j
)
{
if
(
rowRes
[
j
]
==
0
)
{
continue
;
}
colDataAppend
(
pDest
,
numOfRow
,
colDataGetData
(
pSrc
,
j
),
false
);
numOfRow
+=
1
;
}
}
px
->
info
.
rows
=
numOfRow
;
pInfo
->
pRes
=
px
;
}
return
pInfo
->
pRes
;
return
doFilterResult
(
pInfo
);
}
return
NULL
;
...
...
@@ -6331,54 +6320,50 @@ static SSDataBlock* doMultiTableAggregate(void* param, bool* newgroup) {
}
static
SSDataBlock
*
doProjectOperation
(
void
*
param
,
bool
*
newgroup
)
{
SOperatorInfo
*
pOperator
=
(
SOperatorInfo
*
)
param
;
SOperatorInfo
*
pOperator
=
param
;
SProjectOperatorInfo
*
pProjectInfo
=
pOperator
->
info
;
STaskRuntimeEnv
*
pRuntimeEnv
=
pOperator
->
pRuntimeEnv
;
SOptrBasicInfo
*
pInfo
=
&
pProjectInfo
->
binfo
;
SSDataBlock
*
pRes
=
pInfo
->
pRes
;
int32_t
order
=
pRuntimeEnv
->
pQueryAttr
->
order
.
order
;
pRes
->
info
.
rows
=
0
;
blockDataClearup
(
pRes
,
true
);
if
(
pProjectInfo
->
existDataBlock
)
{
// TODO refactor
STableQueryInfo
*
pTableQueryInfo
=
pRuntimeEnv
->
current
;
SSDataBlock
*
pBlock
=
pProjectInfo
->
existDataBlock
;
pProjectInfo
->
existDataBlock
=
NULL
;
*
newgroup
=
true
;
// todo dynamic set tags
if
(
pTableQueryInfo
!=
NULL
)
{
//
if (pTableQueryInfo != NULL) {
// setTagValue(pOperator, pTableQueryInfo->pTable, pInfo->pCtx, pOperator->numOfOutput);
}
//
}
// the pDataBlock are always the same one, no need to call this again
setInputDataBlock
(
pOperator
,
pInfo
->
pCtx
,
pBlock
,
order
);
updateOutputBuf
(
pInfo
,
&
pInfo
->
capacity
,
pBlock
->
info
.
rows
);
setInputDataBlock
(
pOperator
,
pInfo
->
pCtx
,
pBlock
,
TSDB_ORDER_ASC
);
projectApplyFunctions
(
pRuntimeEnv
,
pInfo
->
pCtx
,
pOperator
->
numOfOutput
);
blockDataEnsureCapacity
(
pInfo
->
pRes
,
pBlock
->
info
.
rows
);
projectApplyFunctions
(
pInfo
->
pRes
,
pInfo
->
pCtx
,
pOperator
->
numOfOutput
);
pRes
->
info
.
rows
=
getNumOfResult
(
pInfo
->
pCtx
,
pOperator
->
numOfOutput
,
NULL
);
if
(
pRes
->
info
.
rows
>=
p
RuntimeEnv
->
resultInfo
.
threshold
)
{
if
(
pRes
->
info
.
rows
>=
p
ProjectInfo
->
binfo
.
capacity
*
0
.
8
)
{
copyTsColoum
(
pRes
,
pInfo
->
pCtx
,
pOperator
->
numOfOutput
);
resetResultRowEntryResult
(
pInfo
->
pCtx
,
pOperator
->
numOfOutput
);
return
pRes
;
}
}
SOperatorInfo
*
downstream
=
pOperator
->
pDownstream
[
0
];
while
(
1
)
{
bool
prevVal
=
*
newgroup
;
// The downstream exec may change the value of the newgroup, so use a local variable instead.
publishOperatorProfEvent
(
pOperator
->
pDownstream
[
0
]
,
QUERY_PROF_BEFORE_OPERATOR_EXEC
);
SSDataBlock
*
pBlock
=
pOperator
->
pDownstream
[
0
]
->
nextDataFn
(
pOperator
->
pDownstream
[
0
]
,
newgroup
);
publishOperatorProfEvent
(
pOperator
->
pDownstream
[
0
]
,
QUERY_PROF_AFTER_OPERATOR_EXEC
);
publishOperatorProfEvent
(
downstream
,
QUERY_PROF_BEFORE_OPERATOR_EXEC
);
SSDataBlock
*
pBlock
=
downstream
->
nextDataFn
(
downstream
,
newgroup
);
publishOperatorProfEvent
(
downstream
,
QUERY_PROF_AFTER_OPERATOR_EXEC
);
if
(
pBlock
==
NULL
)
{
assert
(
*
newgroup
==
false
);
*
newgroup
=
prevVal
;
setTaskStatus
(
pOperator
->
pTaskInfo
,
TASK_COMPLETED
);
break
;
...
...
@@ -6397,25 +6382,25 @@ static SSDataBlock* doProjectOperation(void* param, bool* newgroup) {
}
}
STableQueryInfo
*
pTableQueryInfo
=
pRuntimeEnv
->
current
;
// todo dynamic set tags
if
(
pTableQueryInfo
!=
NULL
)
{
// setTagValue(pOperator, pTableQueryInfo->pTable, pInfo->pCtx, pOperator->numOfOutput);
}
// STableQueryInfo* pTableQueryInfo = pRuntimeEnv->current;
// if (pTableQueryInfo != NULL) {
// setTagValue(pOperator, pTableQueryInfo->pTable, pInfo->pCtx, pOperator->numOfOutput);
// }
// the pDataBlock are always the same one, no need to call this again
setInputDataBlock
(
pOperator
,
pInfo
->
pCtx
,
pBlock
,
order
);
setInputDataBlock
(
pOperator
,
pInfo
->
pCtx
,
pBlock
,
TSDB_ORDER_ASC
);
updateOutputBuf
(
pInfo
,
&
pInfo
->
capacity
,
pBlock
->
info
.
rows
);
projectApplyFunctions
(
pRuntimeEnv
,
pInfo
->
pCtx
,
pOperator
->
numOfOutput
);
pRes
->
info
.
rows
=
getNumOfResult
(
pInfo
->
pCtx
,
pOperator
->
numOfOutput
,
NULL
);
if
(
pRes
->
info
.
rows
>=
1000
/*pRuntimeEnv->resultInfo.threshold*/
)
{
projectApplyFunctions
(
pInfo
->
pRes
,
pInfo
->
pCtx
,
pOperator
->
numOfOutput
);
if
(
pRes
->
info
.
rows
>=
pProjectInfo
->
threshold
)
{
break
;
}
}
copyTsColoum
(
pRes
,
pInfo
->
pCtx
,
pOperator
->
numOfOutput
);
resetResultRowEntryResult
(
pInfo
->
pCtx
,
pOperator
->
numOfOutput
);
//
resetResultRowEntryResult(pInfo->pCtx, pOperator->numOfOutput);
return
(
pInfo
->
pRes
->
info
.
rows
>
0
)
?
pInfo
->
pRes
:
NULL
;
}
...
...
@@ -7317,16 +7302,22 @@ SOperatorInfo* createMultiTableAggOperatorInfo(SOperatorInfo* downstream, SArray
return
pOperator
;
}
SOperatorInfo
*
createProjectOperatorInfo
(
SOperatorInfo
*
downstream
,
SArray
*
pExprInfo
,
SExecTaskInfo
*
pTaskInfo
)
{
SOperatorInfo
*
createProjectOperatorInfo
(
SOperatorInfo
*
downstream
,
SArray
*
pExprInfo
,
S
SDataBlock
*
pResBlock
,
S
ExecTaskInfo
*
pTaskInfo
)
{
SProjectOperatorInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SProjectOperatorInfo
));
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
if
(
pInfo
==
NULL
||
pOperator
==
NULL
)
{
goto
_error
;
}
pInfo
->
binfo
.
capacity
=
4096
;
pInfo
->
binfo
.
pRes
=
createOutputBuf_rv
(
pExprInfo
,
pInfo
->
binfo
.
capacity
);
pInfo
->
binfo
.
pRes
=
pResBlock
;
pInfo
->
binfo
.
pCtx
=
createSqlFunctionCtx_rv
(
pExprInfo
,
&
pInfo
->
binfo
.
rowCellInfoOffset
);
if
(
pInfo
->
binfo
.
pCtx
==
NULL
)
{
goto
_error
;
}
// initResultRowInfo(&pBInfo->resultRowInfo, 8);
// setFunctionResultOutput(pBInfo, MAIN_SCAN);
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
pOperator
->
name
=
"ProjectOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_PROJECT
;
pOperator
->
blockingOptr
=
false
;
...
...
@@ -7336,11 +7327,19 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SArray* pExp
pOperator
->
numOfOutput
=
taosArrayGetSize
(
pExprInfo
);
pOperator
->
nextDataFn
=
doProjectOperation
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
closeFn
=
destroyProjectOperatorInfo
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
int32_t
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
return
pOperator
;
_error:
pTaskInfo
->
code
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
SColumnInfo
*
extractColumnFilterInfo
(
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
int32_t
*
numOfFilterCols
)
{
...
...
@@ -8047,11 +8046,11 @@ static SResSchema createResSchema(int32_t type, int32_t bytes, int32_t slotId, i
return
s
;
}
SArray
*
createExprInfo
(
S
AggPhysiNode
*
pPhyNode
)
{
int32_t
numOf
AggFuncs
=
LIST_LENGTH
(
pPhyNode
->
pAggFuncs
);
SArray
*
createExprInfo
(
S
NodeList
*
pNodeList
)
{
int32_t
numOf
Funcs
=
LIST_LENGTH
(
pNodeList
);
SArray
*
pArray
=
taosArrayInit
(
numOf
Agg
Funcs
,
POINTER_BYTES
);
for
(
int32_t
i
=
0
;
i
<
numOf
Agg
Funcs
;
++
i
)
{
SArray
*
pArray
=
taosArrayInit
(
numOfFuncs
,
POINTER_BYTES
);
for
(
int32_t
i
=
0
;
i
<
numOfFuncs
;
++
i
)
{
SExprInfo
*
pExp
=
calloc
(
1
,
sizeof
(
SExprInfo
));
pExp
->
pExpr
=
calloc
(
1
,
sizeof
(
tExprNode
));
...
...
@@ -8063,31 +8062,46 @@ SArray* createExprInfo(SAggPhysiNode* pPhyNode) {
pExp
->
base
.
pParam
[
0
].
pCol
=
calloc
(
1
,
sizeof
(
SColumn
));
SColumn
*
pCol
=
pExp
->
base
.
pParam
[
0
].
pCol
;
STargetNode
*
pTargetNode
=
(
STargetNode
*
)
nodesListGetNode
(
pPhyNode
->
pAggFuncs
,
i
);
STargetNode
*
pTargetNode
=
(
STargetNode
*
)
nodesListGetNode
(
pNodeList
,
i
);
ASSERT
(
pTargetNode
->
slotId
==
i
);
SFunctionNode
*
pFuncNode
=
(
SFunctionNode
*
)
pTargetNode
->
pExpr
;
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
int32_t
numOfParam
=
LIST_LENGTH
(
pFuncNode
->
pParameterList
);
for
(
int32_t
j
=
0
;
j
<
numOfParam
;
++
j
)
{
SNode
*
p1
=
nodesListGetNode
(
pFuncNode
->
pParameterList
,
j
);
SColumnNode
*
pcn
=
(
SColumnNode
*
)
p1
;
pCol
->
slotId
=
pcn
->
slotId
;
pCol
->
bytes
=
pcn
->
node
.
resType
.
bytes
;
pCol
->
type
=
pcn
->
node
.
resType
.
type
;
pCol
->
scale
=
pcn
->
node
.
resType
.
scale
;
pCol
->
precision
=
pcn
->
node
.
resType
.
precision
;
pCol
->
dataBlockId
=
pcn
->
dataBlockId
;
// it is a project query
if
(
nodeType
(
pTargetNode
->
pExpr
)
==
QUERY_NODE_COLUMN
)
{
SColumnNode
*
pColNode
=
(
SColumnNode
*
)
pTargetNode
->
pExpr
;
SDataType
*
pType
=
&
pColNode
->
node
.
resType
;
pExp
->
base
.
resSchema
=
createResSchema
(
pType
->
type
,
pType
->
bytes
,
pTargetNode
->
slotId
,
pType
->
scale
,
pType
->
precision
,
pColNode
->
colName
);
pCol
->
slotId
=
pColNode
->
slotId
;
pCol
->
bytes
=
pType
->
bytes
;
pCol
->
type
=
pType
->
type
;
pCol
->
scale
=
pType
->
scale
;
pCol
->
precision
=
pType
->
precision
;
}
else
{
SFunctionNode
*
pFuncNode
=
(
SFunctionNode
*
)
pTargetNode
->
pExpr
;
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
int32_t
numOfParam
=
LIST_LENGTH
(
pFuncNode
->
pParameterList
);
for
(
int32_t
j
=
0
;
j
<
numOfParam
;
++
j
)
{
SNode
*
p1
=
nodesListGetNode
(
pFuncNode
->
pParameterList
,
j
);
SColumnNode
*
pcn
=
(
SColumnNode
*
)
p1
;
pCol
->
slotId
=
pcn
->
slotId
;
pCol
->
bytes
=
pcn
->
node
.
resType
.
bytes
;
pCol
->
type
=
pcn
->
node
.
resType
.
type
;
pCol
->
scale
=
pcn
->
node
.
resType
.
scale
;
pCol
->
precision
=
pcn
->
node
.
resType
.
precision
;
pCol
->
dataBlockId
=
pcn
->
dataBlockId
;
}
}
taosArrayPush
(
pArray
,
&
pExp
);
}
...
...
@@ -8115,9 +8129,9 @@ static SArray* extractTableIdList(const STableGroupInfo* pTableGroupInfo);
static
SArray
*
extractScanColumnId
(
SNodeList
*
pNodeList
);
SOperatorInfo
*
doCreateOperatorTreeNode
(
SPhysiNode
*
pPhyNode
,
SExecTaskInfo
*
pTaskInfo
,
SReadHandle
*
pHandle
,
uint64_t
queryId
,
uint64_t
taskId
,
STableGroupInfo
*
pTableGroupInfo
)
{
if
(
nodeType
(
pPhyNode
)
==
QUERY_NODE_PHYSICAL_PLAN_PROJECT
)
{
// ignore the project node
pPhyNode
=
nodesListGetNode
(
pPhyNode
->
pChildren
,
0
);
}
//
if (nodeType(pPhyNode) == QUERY_NODE_PHYSICAL_PLAN_PROJECT) { // ignore the project node
//
pPhyNode = nodesListGetNode(pPhyNode->pChildren, 0);
//
}
if
(
pPhyNode
->
pChildren
==
NULL
||
LIST_LENGTH
(
pPhyNode
->
pChildren
)
==
0
)
{
if
(
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
==
nodeType
(
pPhyNode
))
{
...
...
@@ -8158,7 +8172,17 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTa
}
}
if
(
QUERY_NODE_PHYSICAL_PLAN_AGG
==
nodeType
(
pPhyNode
))
{
if
(
QUERY_NODE_PHYSICAL_PLAN_PROJECT
==
nodeType
(
pPhyNode
))
{
size_t
size
=
LIST_LENGTH
(
pPhyNode
->
pChildren
);
assert
(
size
==
1
);
SPhysiNode
*
pChildNode
=
(
SPhysiNode
*
)
nodesListGetNode
(
pPhyNode
->
pChildren
,
0
);
SOperatorInfo
*
op
=
doCreateOperatorTreeNode
(
pChildNode
,
pTaskInfo
,
pHandle
,
queryId
,
taskId
,
pTableGroupInfo
);
SArray
*
pExprInfo
=
createExprInfo
(((
SProjectPhysiNode
*
)
pPhyNode
)
->
pProjections
);
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pPhyNode
->
pOutputDataBlockDesc
);
return
createProjectOperatorInfo
(
op
,
pExprInfo
,
pResBlock
,
pTaskInfo
);
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_AGG
==
nodeType
(
pPhyNode
))
{
size_t
size
=
LIST_LENGTH
(
pPhyNode
->
pChildren
);
assert
(
size
==
1
);
...
...
@@ -8166,7 +8190,7 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTa
SPhysiNode
*
pChildNode
=
(
SPhysiNode
*
)
nodesListGetNode
(
pPhyNode
->
pChildren
,
i
);
SOperatorInfo
*
op
=
doCreateOperatorTreeNode
(
pChildNode
,
pTaskInfo
,
pHandle
,
queryId
,
taskId
,
pTableGroupInfo
);
SArray
*
pExprInfo
=
createExprInfo
((
SAggPhysiNode
*
)
pPhyNode
);
SArray
*
pExprInfo
=
createExprInfo
((
(
SAggPhysiNode
*
)
pPhyNode
)
->
pAggFuncs
);
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pPhyNode
->
pOutputDataBlockDesc
);
return
createAggregateOperatorInfo
(
op
,
pExprInfo
,
pResBlock
,
pTaskInfo
,
pTableGroupInfo
);
}
...
...
source/libs/executor/test/executorTests.cpp
浏览文件 @
46242e8a
...
...
@@ -201,9 +201,9 @@ SOperatorInfo* createDummyOperator(int32_t startVal, int32_t numOfBlocks, int32_
pOperator
->
name
=
"dummyInputOpertor4Test"
;
if
(
numOfCols
==
1
)
{
pOperator
->
getNext
Fn
=
getDummyBlock
;
pOperator
->
nextData
Fn
=
getDummyBlock
;
}
else
{
pOperator
->
getNext
Fn
=
get2ColsDummyBlock
;
pOperator
->
nextData
Fn
=
get2ColsDummyBlock
;
}
SDummyInputInfo
*
pInfo
=
(
SDummyInputInfo
*
)
calloc
(
1
,
sizeof
(
SDummyInputInfo
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录