Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1ce9487f
T
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1180
Star
22014
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,发现更多精彩内容 >>
未验证
提交
1ce9487f
编写于
12月 23, 2021
作者:
S
Shengliang Guan
提交者:
GitHub
12月 23, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #9308 from taosdata/feature/3.0_wxy
TD-12451 insert physical plan serialization
上级
6180823d
fa861e8d
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
117 addition
and
11 deletion
+117
-11
include/libs/planner/planner.h
include/libs/planner/planner.h
+3
-3
source/libs/planner/inc/plannerInt.h
source/libs/planner/inc/plannerInt.h
+4
-1
source/libs/planner/src/physicalPlan.c
source/libs/planner/src/physicalPlan.c
+23
-1
source/libs/planner/src/physicalPlanJson.c
source/libs/planner/src/physicalPlanJson.c
+81
-1
source/libs/planner/src/planner.c
source/libs/planner/src/planner.c
+2
-2
source/libs/planner/test/phyPlanTests.cpp
source/libs/planner/test/phyPlanTests.cpp
+2
-1
source/libs/scheduler/src/scheduler.c
source/libs/scheduler/src/scheduler.c
+2
-2
未找到文件。
include/libs/planner/planner.h
浏览文件 @
1ce9487f
...
...
@@ -119,9 +119,9 @@ typedef struct SSubplanId {
typedef
struct
SSubplan
{
SSubplanId
id
;
// unique id of the subplan
int32_t
type
;
// QUERY_TYPE_MERGE|QUERY_TYPE_PARTIAL|QUERY_TYPE_SCAN
int32_t
type
;
// QUERY_TYPE_MERGE|QUERY_TYPE_PARTIAL|QUERY_TYPE_SCAN
|QUERY_TYPE_MODIFY
int32_t
level
;
// the execution level of current subplan, starting from 0.
SEpSet
execEpSet
;
// for the scan
sub
plan, the optional execution node
SEpSet
execEpSet
;
// for the scan
/modify sub
plan, the optional execution node
SArray
*
pChildern
;
// the datasource subplan,from which to fetch the result
SArray
*
pParents
;
// the data destination subplan, get data from current subplan
SPhyNode
*
pNode
;
// physical plan of current subplan
...
...
@@ -152,7 +152,7 @@ int32_t qExplainQuery(const struct SQueryNode* pQueryInfo, struct SEpSet* pQnode
/**
* Convert to subplan to string for the scheduler to send to the executor
*/
int32_t
qSubPlanToString
(
const
SSubplan
*
subplan
,
char
**
str
);
int32_t
qSubPlanToString
(
const
SSubplan
*
subplan
,
char
**
str
,
int32_t
*
len
);
int32_t
qStringToSubplan
(
const
char
*
str
,
SSubplan
**
subplan
);
...
...
source/libs/planner/inc/plannerInt.h
浏览文件 @
1ce9487f
...
...
@@ -102,7 +102,7 @@ int32_t queryPlanToSql(struct SQueryPlanNode* pQueryNode, char** sql);
int32_t
createDag
(
SQueryPlanNode
*
pQueryNode
,
struct
SCatalog
*
pCatalog
,
SQueryDag
**
pDag
);
int32_t
setSubplanExecutionNode
(
SSubplan
*
subplan
,
uint64_t
templateId
,
SEpAddr
*
ep
);
int32_t
subPlanToString
(
const
SSubplan
*
pPhyNode
,
char
**
str
);
int32_t
subPlanToString
(
const
SSubplan
*
pPhyNode
,
char
**
str
,
int32_t
*
len
);
int32_t
stringToSubplan
(
const
char
*
str
,
SSubplan
**
subplan
);
/**
...
...
@@ -121,6 +121,9 @@ void* destroyQueryPhyPlan(struct SPhyNode* pQueryPhyNode);
const
char
*
opTypeToOpName
(
int32_t
type
);
int32_t
opNameToOpType
(
const
char
*
name
);
const
char
*
dsinkTypeToDsinkName
(
int32_t
type
);
int32_t
dsinkNameToDsinkType
(
const
char
*
name
);
#ifdef __cplusplus
}
#endif
...
...
source/libs/planner/src/physicalPlan.c
浏览文件 @
1ce9487f
...
...
@@ -47,16 +47,38 @@ const char* opTypeToOpName(int32_t type) {
int32_t
opNameToOpType
(
const
char
*
name
)
{
for
(
int32_t
i
=
1
;
i
<
sizeof
(
gOpName
)
/
sizeof
(
gOpName
[
0
]);
++
i
)
{
if
(
strcmp
(
name
,
gOpName
[
i
]))
{
if
(
0
==
strcmp
(
name
,
gOpName
[
i
]))
{
return
i
;
}
}
return
OP_Unknown
;
}
const
char
*
dsinkTypeToDsinkName
(
int32_t
type
)
{
switch
(
type
)
{
case
DSINK_Dispatch
:
return
"Dispatch"
;
case
DSINK_Insert
:
return
"Insert"
;
default:
break
;
}
return
"Unknown"
;
}
int32_t
dsinkNameToDsinkType
(
const
char
*
name
)
{
if
(
0
==
strcmp
(
name
,
"Dispatch"
))
{
return
DSINK_Dispatch
;
}
else
if
(
0
==
strcmp
(
name
,
"Insert"
))
{
return
DSINK_Insert
;
}
return
DSINK_Unknown
;
}
static
SDataSink
*
initDataSink
(
int32_t
type
,
int32_t
size
)
{
SDataSink
*
sink
=
(
SDataSink
*
)
vailidPointer
(
calloc
(
1
,
size
));
sink
->
info
.
type
=
type
;
sink
->
info
.
name
=
dsinkTypeToDsinkName
(
type
);
return
sink
;
}
...
...
source/libs/planner/src/physicalPlanJson.c
浏览文件 @
1ce9487f
...
...
@@ -695,6 +695,70 @@ static bool phyNodeFromJson(const cJSON* json, void* obj) {
return
res
;
}
static
const
char
*
jkInserterNumOfTables
=
"NumOfTables"
;
static
const
char
*
jkInserterDataSize
=
"DataSize"
;
static
bool
inserterToJson
(
const
void
*
obj
,
cJSON
*
json
)
{
const
SDataInserter
*
inserter
=
(
const
SDataInserter
*
)
obj
;
bool
res
=
cJSON_AddNumberToObject
(
json
,
jkInserterNumOfTables
,
inserter
->
numOfTables
);
if
(
res
)
{
res
=
cJSON_AddNumberToObject
(
json
,
jkInserterDataSize
,
inserter
->
size
);
}
// todo pData
return
res
;
}
static
bool
inserterFromJson
(
const
cJSON
*
json
,
void
*
obj
)
{
SDataInserter
*
inserter
=
(
SDataInserter
*
)
obj
;
inserter
->
numOfTables
=
getNumber
(
json
,
jkInserterNumOfTables
);
inserter
->
size
=
getNumber
(
json
,
jkInserterDataSize
);
// todo pData
}
static
bool
specificDataSinkToJson
(
const
void
*
obj
,
cJSON
*
json
)
{
const
SDataSink
*
dsink
=
(
const
SDataSink
*
)
obj
;
switch
(
dsink
->
info
.
type
)
{
case
DSINK_Dispatch
:
return
true
;
case
DSINK_Insert
:
return
inserterToJson
(
obj
,
json
);
default:
break
;
}
return
false
;
}
static
bool
specificDataSinkFromJson
(
const
cJSON
*
json
,
void
*
obj
)
{
SDataSink
*
dsink
=
(
SDataSink
*
)
obj
;
switch
(
dsink
->
info
.
type
)
{
case
DSINK_Dispatch
:
return
true
;
case
DSINK_Insert
:
return
inserterFromJson
(
json
,
obj
);
default:
break
;
}
return
false
;
}
static
const
char
*
jkDataSinkName
=
"Name"
;
static
bool
dataSinkToJson
(
const
void
*
obj
,
cJSON
*
json
)
{
const
SDataSink
*
dsink
=
(
const
SDataSink
*
)
obj
;
bool
res
=
cJSON_AddStringToObject
(
json
,
jkDataSinkName
,
dsink
->
info
.
name
);
if
(
res
)
{
res
=
addObject
(
json
,
dsink
->
info
.
name
,
specificDataSinkToJson
,
dsink
);
}
return
res
;
}
static
bool
dataSinkFromJson
(
const
cJSON
*
json
,
void
*
obj
)
{
SDataSink
*
dsink
=
(
SDataSink
*
)
obj
;
dsink
->
info
.
name
=
getString
(
json
,
jkDataSinkName
);
dsink
->
info
.
type
=
dsinkNameToDsinkType
(
dsink
->
info
.
name
);
return
fromObject
(
json
,
dsink
->
info
.
name
,
specificDataSinkFromJson
,
dsink
,
true
);
}
static
const
char
*
jkIdQueryId
=
"QueryId"
;
static
const
char
*
jkIdTemplateId
=
"TemplateId"
;
static
const
char
*
jkIdSubplanId
=
"SubplanId"
;
...
...
@@ -721,6 +785,7 @@ static bool subplanIdFromJson(const cJSON* json, void* obj) {
static
const
char
*
jkSubplanId
=
"Id"
;
static
const
char
*
jkSubplanNode
=
"Node"
;
static
const
char
*
jkSubplanDataSink
=
"DataSink"
;
static
cJSON
*
subplanToJson
(
const
SSubplan
*
subplan
)
{
cJSON
*
jSubplan
=
cJSON_CreateObject
();
...
...
@@ -734,6 +799,9 @@ static cJSON* subplanToJson(const SSubplan* subplan) {
if
(
res
)
{
res
=
addObject
(
jSubplan
,
jkSubplanNode
,
phyNodeToJson
,
subplan
->
pNode
);
}
if
(
res
)
{
res
=
addObject
(
jSubplan
,
jkSubplanDataSink
,
dataSinkToJson
,
subplan
->
pDataSink
);
}
if
(
!
res
)
{
cJSON_Delete
(
jSubplan
);
...
...
@@ -751,6 +819,9 @@ static SSubplan* subplanFromJson(const cJSON* json) {
if
(
res
)
{
res
=
fromObjectWithAlloc
(
json
,
jkSubplanNode
,
phyNodeFromJson
,
(
void
**
)
&
subplan
->
pNode
,
sizeof
(
SPhyNode
),
false
);
}
if
(
res
)
{
res
=
fromObjectWithAlloc
(
json
,
jkSubplanDataSink
,
dataSinkFromJson
,
(
void
**
)
&
subplan
->
pDataSink
,
sizeof
(
SDataSink
),
false
);
}
if
(
!
res
)
{
qDestroySubplan
(
subplan
);
...
...
@@ -759,13 +830,22 @@ static SSubplan* subplanFromJson(const cJSON* json) {
return
subplan
;
}
int32_t
subPlanToString
(
const
SSubplan
*
subplan
,
char
**
str
)
{
int32_t
subPlanToString
(
const
SSubplan
*
subplan
,
char
**
str
,
int32_t
*
len
)
{
if
(
QUERY_TYPE_MODIFY
==
subplan
->
type
)
{
SDataInserter
*
insert
=
(
SDataInserter
*
)(
subplan
->
pDataSink
);
*
len
=
insert
->
size
;
*
str
=
insert
->
pData
;
insert
->
pData
==
NULL
;
return
TSDB_CODE_SUCCESS
;
}
cJSON
*
json
=
subplanToJson
(
subplan
);
if
(
NULL
==
json
)
{
terrno
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
TSDB_CODE_FAILED
;
}
*
str
=
cJSON_Print
(
json
);
*
len
=
strlen
(
*
str
);
return
TSDB_CODE_SUCCESS
;
}
...
...
source/libs/planner/src/planner.c
浏览文件 @
1ce9487f
...
...
@@ -50,8 +50,8 @@ int32_t qSetSubplanExecutionNode(SSubplan* subplan, uint64_t templateId, SEpAddr
return
setSubplanExecutionNode
(
subplan
,
templateId
,
ep
);
}
int32_t
qSubPlanToString
(
const
SSubplan
*
subplan
,
char
**
str
)
{
return
subPlanToString
(
subplan
,
str
);
int32_t
qSubPlanToString
(
const
SSubplan
*
subplan
,
char
**
str
,
int32_t
*
len
)
{
return
subPlanToString
(
subplan
,
str
,
len
);
}
int32_t
qStringToSubplan
(
const
char
*
str
,
SSubplan
**
subplan
)
{
...
...
source/libs/planner/test/phyPlanTests.cpp
浏览文件 @
1ce9487f
...
...
@@ -62,8 +62,9 @@ protected:
size_t
num
=
taosArrayGetSize
(
subplans
);
for
(
size_t
j
=
0
;
j
<
num
;
++
j
)
{
std
::
cout
<<
"no "
<<
j
<<
":"
<<
std
::
endl
;
int32_t
len
=
0
;
char
*
str
=
nullptr
;
ASSERT_EQ
(
TSDB_CODE_SUCCESS
,
qSubPlanToString
((
const
SSubplan
*
)
taosArrayGetP
(
subplans
,
j
),
&
str
));
ASSERT_EQ
(
TSDB_CODE_SUCCESS
,
qSubPlanToString
((
const
SSubplan
*
)
taosArrayGetP
(
subplans
,
j
),
&
str
,
&
len
));
std
::
cout
<<
str
<<
std
::
endl
;
free
(
str
);
}
...
...
source/libs/scheduler/src/scheduler.c
浏览文件 @
1ce9487f
...
...
@@ -521,8 +521,8 @@ _return:
int32_t
schLaunchTask
(
SQueryJob
*
job
,
SQueryTask
*
task
)
{
SSubplan
*
plan
=
task
->
plan
;
SCH_ERR_RET
(
qSubPlanToString
(
plan
,
&
task
->
msg
));
int32_t
len
=
0
;
SCH_ERR_RET
(
qSubPlanToString
(
plan
,
&
task
->
msg
,
&
len
));
if
(
plan
->
execEpSet
.
numOfEps
<=
0
)
{
SCH_ERR_RET
(
schSetTaskExecEpSet
(
job
,
&
plan
->
execEpSet
));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录