Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
39361287
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看板
提交
39361287
编写于
12月 14, 2021
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-12034 Physical plan code.
上级
33a13ff5
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
101 addition
and
49 deletion
+101
-49
include/libs/planner/planner.h
include/libs/planner/planner.h
+0
-1
source/libs/planner/inc/plannerInt.h
source/libs/planner/inc/plannerInt.h
+21
-17
source/libs/planner/src/physicalPlan.c
source/libs/planner/src/physicalPlan.c
+72
-8
source/libs/planner/src/planner.c
source/libs/planner/src/planner.c
+8
-23
未找到文件。
include/libs/planner/planner.h
浏览文件 @
39361287
...
...
@@ -54,7 +54,6 @@ enum OPERATOR_TYPE_E {
};
struct
SEpSet
;
struct
SQueryPlanNode
;
struct
SPhyNode
;
struct
SQueryStmtInfo
;
...
...
source/libs/planner/inc/plannerInt.h
浏览文件 @
39361287
...
...
@@ -25,18 +25,20 @@ extern "C" {
#include "planner.h"
#include "taosmsg.h"
enum
LOGIC_PLAN_E
{
LP_SCAN
=
1
,
LP_SESSION
=
2
,
LP_STATE
=
3
,
LP_INTERVAL
=
4
,
LP_FILL
=
5
,
LP_AGG
=
6
,
LP_JOIN
=
7
,
LP_PROJECT
=
8
,
LP_DISTINCT
=
9
,
LP_ORDER
=
10
};
#define QNODE_TAGSCAN 1
#define QNODE_TABLESCAN 2
#define QNODE_PROJECT 3
#define QNODE_AGGREGATE 4
#define QNODE_GROUPBY 5
#define QNODE_LIMIT 6
#define QNODE_JOIN 7
#define QNODE_DISTINCT 8
#define QNODE_SORT 9
#define QNODE_UNION 10
#define QNODE_TIMEWINDOW 11
#define QNODE_SESSIONWINDOW 12
#define QNODE_STATEWINDOW 13
#define QNODE_FILL 14
typedef
struct
SQueryNodeBasicInfo
{
int32_t
type
;
// operator type
...
...
@@ -64,10 +66,10 @@ typedef struct SQueryPlanNode {
SArray
*
pExpr
;
// the query functions or sql aggregations
int32_t
numOfExpr
;
// number of result columns, which is also the number of pExprs
void
*
pExtInfo
;
// additional information
//
previous
operator to generated result for current node to process
//
children
operator to generated result for current node to process
// in case of join, multiple prev nodes exist.
SArray
*
p
PrevNodes
;
// upstream nodes
struct
SQueryPlanNode
*
nextNode
;
SArray
*
p
Children
;
// upstream nodes
struct
SQueryPlanNode
*
pParent
;
}
SQueryPlanNode
;
typedef
SSchema
SSlotSchema
;
...
...
@@ -86,11 +88,13 @@ typedef struct SPhyNode {
// children plan to generated result for current node to process
// in case of join, multiple plan nodes exist.
SArray
*
pChildren
;
struct
SPhyNode
*
pParent
;
}
SPhyNode
;
typedef
struct
SScanPhyNode
{
SPhyNode
node
;
uint64_t
uid
;
// unique id of the table
SPhyNode
node
;
STimeWindow
window
;
uint64_t
uid
;
// unique id of the table
}
SScanPhyNode
;
typedef
SScanPhyNode
STagScanPhyNode
;
...
...
source/libs/planner/src/physicalPlan.c
浏览文件 @
39361287
...
...
@@ -15,20 +15,84 @@
#include "plannerInt.h"
// typedef struct SQueryPlanNode {
// void *pExtInfo; // additional information
// SArray *pPrevNodes; // children
// struct SQueryPlanNode *nextNode; // parent
// } SQueryPlanNode;
// typedef struct SSubplan {
// int32_t type; // QUERY_TYPE_MERGE|QUERY_TYPE_PARTIAL|QUERY_TYPE_SCAN
// SArray *pDatasource; // the datasource subplan,from which to fetch the result
// struct SPhyNode *pNode; // physical plan of current subplan
// } SSubplan;
// typedef struct SQueryDag {
// SArray **pSubplans;
// } SQueryDag;
// typedef struct SScanPhyNode {
// SPhyNode node;
// STimeWindow window;
// uint64_t uid; // unique id of the table
// } SScanPhyNode;
// typedef SScanPhyNode STagScanPhyNode;
void
fillDataBlockSchema
(
SQueryPlanNode
*
pPlanNode
,
SDataBlockSchema
*
dataBlockSchema
)
{
dataBlockSchema
->
index
=
0
;
// todo
SWAP
(
dataBlockSchema
->
pSchema
,
pPlanNode
->
pSchema
,
SSchema
*
);
dataBlockSchema
->
numOfCols
=
pPlanNode
->
numOfCols
;
}
void
fillPhyNode
(
SQueryPlanNode
*
pPlanNode
,
int32_t
type
,
const
char
*
name
,
SPhyNode
*
node
)
{
node
->
info
.
type
=
type
;
node
->
info
.
name
=
name
;
SWAP
(
node
->
pTargets
,
pPlanNode
->
pExpr
,
SArray
*
);
fillDataBlockSchema
(
pPlanNode
,
&
(
node
->
targetSchema
));
}
SPhyNode
*
createTagScanNode
(
SQueryPlanNode
*
pPlanNode
)
{
STagScanPhyNode
*
node
=
calloc
(
1
,
sizeof
(
STagScanPhyNode
));
fillPhyNode
(
pPlanNode
,
OP_TagScan
,
"TagScan"
,
(
SPhyNode
*
)
node
);
return
(
SPhyNode
*
)
node
;
}
SPhyNode
*
createScanNode
(
SQueryPlanNode
*
pPlanNode
)
{
return
NULL
;
STagScanPhyNode
*
node
=
calloc
(
1
,
sizeof
(
STagScanPhyNode
));
fillPhyNode
(
pPlanNode
,
OP_TableScan
,
"SingleTableScan"
,
(
SPhyNode
*
)
node
);
return
(
SPhyNode
*
)
node
;
}
SPhyNode
*
createPhyNode
(
SQueryPlanNode
*
node
)
{
switch
(
node
->
info
.
type
)
{
case
LP_SCAN
:
return
createScanNode
(
node
);
SPhyNode
*
createPhyNode
(
SQueryPlanNode
*
pPlanNode
)
{
SPhyNode
*
node
=
NULL
;
switch
(
pPlanNode
->
info
.
type
)
{
case
QNODE_TAGSCAN
:
node
=
createTagScanNode
(
pPlanNode
);
break
;
case
QNODE_TABLESCAN
:
node
=
createScanNode
(
pPlanNode
);
break
;
default:
assert
(
false
);
}
if
(
pPlanNode
->
pChildren
!=
NULL
&&
taosArrayGetSize
(
pPlanNode
->
pChildren
)
>
0
)
{
node
->
pChildren
=
taosArrayInit
(
4
,
POINTER_BYTES
);
size_t
size
=
taosArrayGetSize
(
pPlanNode
->
pChildren
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SPhyNode
*
child
=
createPhyNode
(
taosArrayGet
(
pPlanNode
->
pChildren
,
i
));
child
->
pParent
=
node
;
taosArrayPush
(
node
->
pChildren
,
&
child
);
}
}
return
NULL
;
return
node
;
}
SPhyNode
*
createSubplan
(
SQueryPlanNode
*
pSubquery
)
{
return
NULL
;
SSubplan
*
createSubplan
(
SQueryPlanNode
*
pSubquery
)
{
SSubplan
*
subplan
=
calloc
(
1
,
sizeof
(
SSubplan
));
subplan
->
pNode
=
createPhyNode
(
pSubquery
);
// todo
return
subplan
;
}
int32_t
createDag
(
struct
SQueryPlanNode
*
pQueryNode
,
struct
SEpSet
*
pQnode
,
struct
SQueryDag
**
pDag
)
{
...
...
source/libs/planner/src/planner.c
浏览文件 @
39361287
...
...
@@ -18,21 +18,6 @@
#include "parser.h"
#include "plannerInt.h"
#define QNODE_TAGSCAN 1
#define QNODE_TABLESCAN 2
#define QNODE_PROJECT 3
#define QNODE_AGGREGATE 4
#define QNODE_GROUPBY 5
#define QNODE_LIMIT 6
#define QNODE_JOIN 7
#define QNODE_DISTINCT 8
#define QNODE_SORT 9
#define QNODE_UNION 10
#define QNODE_TIMEWINDOW 11
#define QNODE_SESSIONWINDOW 12
#define QNODE_STATEWINDOW 13
#define QNODE_FILL 14
typedef
struct
SFillEssInfo
{
int32_t
fillType
;
// fill type
int64_t
*
val
;
// fill value
...
...
@@ -104,9 +89,9 @@ static SQueryPlanNode* createQueryNode(int32_t type, const char* name, SQueryPla
taosArrayPush
(
pNode
->
pExpr
,
&
pExpr
[
i
]);
}
pNode
->
p
PrevNodes
=
taosArrayInit
(
4
,
POINTER_BYTES
);
pNode
->
p
Children
=
taosArrayInit
(
4
,
POINTER_BYTES
);
for
(
int32_t
i
=
0
;
i
<
numOfPrev
;
++
i
)
{
taosArrayPush
(
pNode
->
p
PrevNodes
,
&
prev
[
i
]);
taosArrayPush
(
pNode
->
p
Children
,
&
prev
[
i
]);
}
switch
(
type
)
{
...
...
@@ -386,14 +371,14 @@ static void doDestroyQueryNode(SQueryPlanNode* pQueryNode) {
tfree
(
pQueryNode
->
info
.
name
);
// dropAllExprInfo(pQueryNode->pExpr);
if
(
pQueryNode
->
p
PrevNodes
!=
NULL
)
{
int32_t
size
=
(
int32_t
)
taosArrayGetSize
(
pQueryNode
->
p
PrevNodes
);
if
(
pQueryNode
->
p
Children
!=
NULL
)
{
int32_t
size
=
(
int32_t
)
taosArrayGetSize
(
pQueryNode
->
p
Children
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SQueryPlanNode
*
p
=
taosArrayGetP
(
pQueryNode
->
p
PrevNodes
,
i
);
SQueryPlanNode
*
p
=
taosArrayGetP
(
pQueryNode
->
p
Children
,
i
);
doDestroyQueryNode
(
p
);
}
taosArrayDestroy
(
pQueryNode
->
p
PrevNodes
);
taosArrayDestroy
(
pQueryNode
->
p
Children
);
}
tfree
(
pQueryNode
);
...
...
@@ -607,8 +592,8 @@ int32_t printExprInfo(const char* buf, const SQueryPlanNode* pQueryNode, int32_t
int32_t
queryPlanToStringImpl
(
char
*
buf
,
SQueryPlanNode
*
pQueryNode
,
int32_t
level
,
int32_t
totalLen
)
{
int32_t
len
=
doPrintPlan
(
buf
,
pQueryNode
,
level
,
totalLen
);
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pQueryNode
->
p
PrevNodes
);
++
i
)
{
SQueryPlanNode
*
p1
=
taosArrayGetP
(
pQueryNode
->
p
PrevNodes
,
i
);
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pQueryNode
->
p
Children
);
++
i
)
{
SQueryPlanNode
*
p1
=
taosArrayGetP
(
pQueryNode
->
p
Children
,
i
);
int32_t
len1
=
queryPlanToStringImpl
(
buf
,
p1
,
level
+
1
,
len
);
len
=
len1
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录