Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
01447153
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
01447153
编写于
1月 09, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-12678 qSetSubplanExecutionNode interface implement
上级
3077a244
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
68 addition
and
29 deletion
+68
-29
include/libs/planner/planner.h
include/libs/planner/planner.h
+1
-1
source/libs/planner/inc/plannerInt.h
source/libs/planner/inc/plannerInt.h
+1
-1
source/libs/planner/src/physicalPlan.c
source/libs/planner/src/physicalPlan.c
+63
-24
source/libs/planner/src/planner.c
source/libs/planner/src/planner.c
+2
-2
source/libs/scheduler/src/scheduler.c
source/libs/scheduler/src/scheduler.c
+1
-1
未找到文件。
include/libs/planner/planner.h
浏览文件 @
01447153
...
...
@@ -155,7 +155,7 @@ int32_t qCreateQueryDag(const struct SQueryNode* pQueryInfo, struct SQueryDag**
// @subplan subplan to be schedule
// @templateId templateId of a group of datasource subplans of this @subplan
// @ep one execution location of this group of datasource subplans
int32_t
qSetSubplanExecutionNode
(
SSubplan
*
subplan
,
uint64_t
templateId
,
SQueryNodeAddr
*
ep
);
void
qSetSubplanExecutionNode
(
SSubplan
*
subplan
,
uint64_t
templateId
,
SQueryNodeAddr
*
ep
);
int32_t
qExplainQuery
(
const
struct
SQueryNode
*
pQueryInfo
,
struct
SEpSet
*
pQnode
,
char
**
str
);
...
...
source/libs/planner/inc/plannerInt.h
浏览文件 @
01447153
...
...
@@ -106,7 +106,7 @@ int32_t queryPlanToString(struct SQueryPlanNode* pQueryNode, char** str);
int32_t
queryPlanToSql
(
struct
SQueryPlanNode
*
pQueryNode
,
char
**
sql
);
int32_t
createDag
(
SQueryPlanNode
*
pQueryNode
,
struct
SCatalog
*
pCatalog
,
SQueryDag
**
pDag
,
uint64_t
requestId
);
int32_t
setSubplanExecutionNode
(
SSubplan
*
subplan
,
uint64_t
templateId
,
SQueryNodeAddr
*
ep
);
void
setSubplanExecutionNode
(
SSubplan
*
subplan
,
uint64_t
templateId
,
SQueryNodeAddr
*
ep
);
int32_t
subPlanToString
(
const
SSubplan
*
pPhyNode
,
char
**
str
,
int32_t
*
len
);
int32_t
stringToSubplan
(
const
char
*
str
,
SSubplan
**
subplan
);
...
...
source/libs/planner/src/physicalPlan.c
浏览文件 @
01447153
...
...
@@ -75,24 +75,16 @@ int32_t dsinkNameToDsinkType(const char* name) {
return
DSINK_Unknown
;
}
static
SDataSink
*
initDataSink
(
int32_t
type
,
int32_t
size
)
{
SDataSink
*
sink
=
(
SDataSink
*
)
validPointer
(
calloc
(
1
,
size
));
sink
->
info
.
type
=
type
;
sink
->
info
.
name
=
dsinkTypeToDsinkName
(
type
);
return
sink
;
}
static
SDataSink
*
createDataDispatcher
(
SPlanContext
*
pCxt
,
SQueryPlanNode
*
pPlanNode
)
{
SDataDispatcher
*
dispatcher
=
(
SDataDispatcher
*
)
initDataSink
(
DSINK_Dispatch
,
sizeof
(
SDataDispatcher
));
return
(
SDataSink
*
)
dispatcher
;
}
static
SDataSink
*
createDataInserter
(
SPlanContext
*
pCxt
,
SVgDataBlocks
*
pBlocks
)
{
SDataInserter
*
inserter
=
(
SDataInserter
*
)
initDataSink
(
DSINK_Insert
,
sizeof
(
SDataInserter
));
inserter
->
numOfTables
=
pBlocks
->
numOfTables
;
inserter
->
size
=
pBlocks
->
size
;
SWAP
(
inserter
->
pData
,
pBlocks
->
pData
,
char
*
);
return
(
SDataSink
*
)
inserter
;
static
bool
copySchema
(
SDataBlockSchema
*
dst
,
const
SDataBlockSchema
*
src
)
{
dst
->
pSchema
=
malloc
(
sizeof
(
SSlotSchema
)
*
src
->
numOfCols
);
if
(
NULL
==
dst
->
pSchema
)
{
return
false
;
}
memcpy
(
dst
->
pSchema
,
src
->
pSchema
,
sizeof
(
SSlotSchema
)
*
src
->
numOfCols
);
dst
->
numOfCols
=
src
->
numOfCols
;
dst
->
resultRowSize
=
src
->
resultRowSize
;
dst
->
precision
=
src
->
precision
;
return
true
;
}
static
bool
toDataBlockSchema
(
SQueryPlanNode
*
pPlanNode
,
SDataBlockSchema
*
dataBlockSchema
)
{
...
...
@@ -102,6 +94,10 @@ static bool toDataBlockSchema(SQueryPlanNode* pPlanNode, SDataBlockSchema* dataB
return
false
;
}
memcpy
(
dataBlockSchema
->
pSchema
,
pPlanNode
->
pSchema
,
sizeof
(
SSlotSchema
)
*
pPlanNode
->
numOfCols
);
dataBlockSchema
->
resultRowSize
=
0
;
for
(
int32_t
i
=
0
;
i
<
dataBlockSchema
->
numOfCols
;
++
i
)
{
dataBlockSchema
->
resultRowSize
+=
dataBlockSchema
->
pSchema
[
i
].
bytes
;
}
return
true
;
}
...
...
@@ -120,13 +116,37 @@ static bool cloneExprArray(SArray** dst, SArray* src) {
return
(
TSDB_CODE_SUCCESS
==
copyAllExprInfo
(
*
dst
,
src
,
true
)
?
true
:
false
);
}
static
SDataSink
*
initDataSink
(
int32_t
type
,
int32_t
size
,
const
SPhyNode
*
pRoot
)
{
SDataSink
*
sink
=
(
SDataSink
*
)
validPointer
(
calloc
(
1
,
size
));
sink
->
info
.
type
=
type
;
sink
->
info
.
name
=
dsinkTypeToDsinkName
(
type
);
if
(
NULL
!=
pRoot
&&
!
copySchema
(
&
sink
->
schema
,
&
pRoot
->
targetSchema
))
{
tfree
(
sink
);
THROW
(
TSDB_CODE_TSC_OUT_OF_MEMORY
);
}
return
sink
;
}
static
SDataSink
*
createDataInserter
(
SPlanContext
*
pCxt
,
SVgDataBlocks
*
pBlocks
,
const
SPhyNode
*
pRoot
)
{
SDataInserter
*
inserter
=
(
SDataInserter
*
)
initDataSink
(
DSINK_Insert
,
sizeof
(
SDataInserter
),
pRoot
);
inserter
->
numOfTables
=
pBlocks
->
numOfTables
;
inserter
->
size
=
pBlocks
->
size
;
SWAP
(
inserter
->
pData
,
pBlocks
->
pData
,
char
*
);
return
(
SDataSink
*
)
inserter
;
}
static
SDataSink
*
createDataDispatcher
(
SPlanContext
*
pCxt
,
SQueryPlanNode
*
pPlanNode
,
const
SPhyNode
*
pRoot
)
{
SDataDispatcher
*
dispatcher
=
(
SDataDispatcher
*
)
initDataSink
(
DSINK_Dispatch
,
sizeof
(
SDataDispatcher
),
pRoot
);
return
(
SDataSink
*
)
dispatcher
;
}
static
SPhyNode
*
initPhyNode
(
SQueryPlanNode
*
pPlanNode
,
int32_t
type
,
int32_t
size
)
{
SPhyNode
*
node
=
(
SPhyNode
*
)
validPointer
(
calloc
(
1
,
size
));
node
->
info
.
type
=
type
;
node
->
info
.
name
=
opTypeToOpName
(
type
);
if
(
!
cloneExprArray
(
&
node
->
pTargets
,
pPlanNode
->
pExpr
)
||
!
toDataBlockSchema
(
pPlanNode
,
&
(
node
->
targetSchema
)))
{
free
(
node
);
return
NULL
;
THROW
(
TSDB_CODE_TSC_OUT_OF_MEMORY
)
;
}
return
node
;
}
...
...
@@ -239,7 +259,7 @@ static uint64_t splitSubplanByTable(SPlanContext* pCxt, SQueryPlanNode* pPlanNod
SSubplan
*
subplan
=
initSubplan
(
pCxt
,
QUERY_TYPE_SCAN
);
vgroupMsgToEpSet
(
&
(
pTable
->
pMeta
->
vgroupList
->
vgroups
[
i
]),
&
subplan
->
execNode
);
subplan
->
pNode
=
createMultiTableScanNode
(
pPlanNode
,
pTable
);
subplan
->
pDataSink
=
createDataDispatcher
(
pCxt
,
pPlanNode
);
subplan
->
pDataSink
=
createDataDispatcher
(
pCxt
,
pPlanNode
,
subplan
->
pNode
);
RECOVERY_CURRENT_SUBPLAN
(
pCxt
);
}
return
pCxt
->
nextId
.
templateId
++
;
...
...
@@ -248,6 +268,7 @@ static uint64_t splitSubplanByTable(SPlanContext* pCxt, SQueryPlanNode* pPlanNod
static
SPhyNode
*
createExchangeNode
(
SPlanContext
*
pCxt
,
SQueryPlanNode
*
pPlanNode
,
uint64_t
srcTemplateId
)
{
SExchangePhyNode
*
node
=
(
SExchangePhyNode
*
)
initPhyNode
(
pPlanNode
,
OP_Exchange
,
sizeof
(
SExchangePhyNode
));
node
->
srcTemplateId
=
srcTemplateId
;
node
->
pSrcEndPoints
=
validPointer
(
taosArrayInit
(
TARRAY_MIN_SIZE
,
sizeof
(
SQueryNodeAddr
)));
return
(
SPhyNode
*
)
node
;
}
...
...
@@ -313,7 +334,7 @@ static void splitModificationOpSubPlan(SPlanContext* pCxt, SQueryPlanNode* pPlan
SVgDataBlocks
*
blocks
=
(
SVgDataBlocks
*
)
taosArrayGetP
(
pPayload
->
payload
,
i
);
vgroupInfoToEpSet
(
&
blocks
->
vg
,
&
subplan
->
execNode
);
subplan
->
pDataSink
=
createDataInserter
(
pCxt
,
blocks
);
subplan
->
pDataSink
=
createDataInserter
(
pCxt
,
blocks
,
NULL
);
subplan
->
pNode
=
NULL
;
subplan
->
type
=
QUERY_TYPE_MODIFY
;
subplan
->
msgType
=
pPayload
->
msgType
;
...
...
@@ -332,7 +353,7 @@ static void createSubplanByLevel(SPlanContext* pCxt, SQueryPlanNode* pRoot) {
subplan
->
msgType
=
TDMT_VND_QUERY
;
subplan
->
pNode
=
createPhyNode
(
pCxt
,
pRoot
);
subplan
->
pDataSink
=
createDataDispatcher
(
pCxt
,
pRoot
);
subplan
->
pDataSink
=
createDataDispatcher
(
pCxt
,
pRoot
,
subplan
->
pNode
);
}
// todo deal subquery
}
...
...
@@ -359,6 +380,24 @@ int32_t createDag(SQueryPlanNode* pQueryNode, struct SCatalog* pCatalog, SQueryD
return
TSDB_CODE_SUCCESS
;
}
int32_t
setSubplanExecutionNode
(
SSubplan
*
subplan
,
uint64_t
templateId
,
SQueryNodeAddr
*
ep
)
{
//todo
void
setExchangSourceNode
(
uint64_t
templateId
,
SQueryNodeAddr
*
pEp
,
SPhyNode
*
pNode
)
{
if
(
NULL
==
pNode
)
{
return
;
}
if
(
OP_Exchange
==
pNode
->
info
.
type
)
{
SExchangePhyNode
*
pExchange
=
(
SExchangePhyNode
*
)
pNode
;
if
(
templateId
==
pExchange
->
srcTemplateId
)
{
taosArrayPush
(
pExchange
->
pSrcEndPoints
,
pEp
);
}
}
if
(
pNode
->
pChildren
!=
NULL
)
{
size_t
size
=
taosArrayGetSize
(
pNode
->
pChildren
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
setExchangSourceNode
(
templateId
,
pEp
,
taosArrayGetP
(
pNode
->
pChildren
,
i
));
}
}
}
void
setSubplanExecutionNode
(
SSubplan
*
subplan
,
uint64_t
templateId
,
SQueryNodeAddr
*
pEp
)
{
setExchangSourceNode
(
templateId
,
pEp
,
subplan
->
pNode
);
}
source/libs/planner/src/planner.c
浏览文件 @
01447153
...
...
@@ -88,8 +88,8 @@ int32_t qCreateQueryDag(const struct SQueryNode* pNode, struct SQueryDag** pDag,
return
TSDB_CODE_SUCCESS
;
}
int32_t
qSetSubplanExecutionNode
(
SSubplan
*
subplan
,
uint64_t
templateId
,
SQueryNodeAddr
*
ep
)
{
return
setSubplanExecutionNode
(
subplan
,
templateId
,
ep
);
void
qSetSubplanExecutionNode
(
SSubplan
*
subplan
,
uint64_t
templateId
,
SQueryNodeAddr
*
ep
)
{
setSubplanExecutionNode
(
subplan
,
templateId
,
ep
);
}
int32_t
qSubPlanToString
(
const
SSubplan
*
subplan
,
char
**
str
,
int32_t
*
len
)
{
...
...
source/libs/scheduler/src/scheduler.c
浏览文件 @
01447153
...
...
@@ -522,7 +522,7 @@ int32_t schProcessOnTaskSuccess(SSchJob *pJob, SSchTask *pTask) {
atomic_add_fetch_32
(
&
par
->
childReady
,
1
);
SCH_ERR_RET
(
qSetSubplanExecutionNode
(
par
->
plan
,
pTask
->
plan
->
id
.
templateId
,
&
pTask
->
execAddr
)
);
qSetSubplanExecutionNode
(
par
->
plan
,
pTask
->
plan
->
id
.
templateId
,
&
pTask
->
execAddr
);
if
(
SCH_TASK_READY_TO_LUNCH
(
par
))
{
SCH_ERR_RET
(
schLaunchTask
(
pJob
,
par
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录