Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3e455e37
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
3e455e37
编写于
3月 24, 2022
作者:
L
Liu Jicong
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'feature/shm' into feature/tq
上级
d3e62358
44faa52a
变更
45
显示空白变更内容
内联
并排
Showing
45 changed file
with
1809 addition
and
1015 deletion
+1809
-1015
include/common/taosdef.h
include/common/taosdef.h
+0
-2
include/common/tmsg.h
include/common/tmsg.h
+20
-4
include/libs/function/function.h
include/libs/function/function.h
+1
-1
include/libs/nodes/nodes.h
include/libs/nodes/nodes.h
+2
-0
include/libs/nodes/plannodes.h
include/libs/nodes/plannodes.h
+13
-3
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+1
-1
source/common/src/tmsg.c
source/common/src/tmsg.c
+97
-4
source/dnode/mgmt/test/vnode/vnode.cpp
source/dnode/mgmt/test/vnode/vnode.cpp
+2
-0
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+5
-0
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+31
-0
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+90
-18
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+2
-0
source/dnode/mnode/impl/test/sma/sma.cpp
source/dnode/mnode/impl/test/sma/sma.cpp
+94
-37
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+3
-44
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+15
-13
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+92
-79
source/libs/function/inc/tfill.h
source/libs/function/inc/tfill.h
+1
-1
source/libs/function/src/tfill.c
source/libs/function/src/tfill.c
+2
-2
source/libs/nodes/src/nodesCloneFuncs.c
source/libs/nodes/src/nodesCloneFuncs.c
+5
-2
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+140
-21
source/libs/nodes/src/nodesTraverseFuncs.c
source/libs/nodes/src/nodesTraverseFuncs.c
+7
-2
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+15
-1
source/libs/parser/inc/parAst.h
source/libs/parser/inc/parAst.h
+1
-1
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+1
-1
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+2
-2
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+23
-8
source/libs/parser/src/parUtil.c
source/libs/parser/src/parUtil.c
+1
-0
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+184
-185
source/libs/parser/test/parserAstTest.cpp
source/libs/parser/test/parserAstTest.cpp
+73
-21
source/libs/planner/inc/planInt.h
source/libs/planner/inc/planInt.h
+4
-3
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+38
-23
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+20
-0
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+416
-400
source/libs/planner/src/planScaleOut.c
source/libs/planner/src/planScaleOut.c
+203
-0
source/libs/planner/src/planSpliter.c
source/libs/planner/src/planSpliter.c
+50
-8
source/libs/planner/src/planner.c
source/libs/planner/src/planner.c
+15
-6
source/libs/planner/test/plannerTest.cpp
source/libs/planner/test/plannerTest.cpp
+42
-35
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+3
-0
tests/script/tsim/db/basic7.sim
tests/script/tsim/db/basic7.sim
+1
-0
tests/script/tsim/insert/backquote.sim
tests/script/tsim/insert/backquote.sim
+58
-49
tests/script/tsim/insert/basic1.sim
tests/script/tsim/insert/basic1.sim
+4
-3
tests/script/tsim/testCaseSuite.sim
tests/script/tsim/testCaseSuite.sim
+3
-3
tools/shell/src/shellMain.c
tools/shell/src/shellMain.c
+1
-1
tools/shell/src/tnettest.c
tools/shell/src/tnettest.c
+27
-30
tools/taos-tools
tools/taos-tools
+1
-1
未找到文件。
include/common/taosdef.h
浏览文件 @
3e455e37
...
@@ -78,8 +78,6 @@ typedef enum {
...
@@ -78,8 +78,6 @@ typedef enum {
extern
char
*
qtypeStr
[];
extern
char
*
qtypeStr
[];
#define TSDB_PORT_DNODEDNODE 5
#define TSDB_PORT_SYNC 10
#define TSDB_PORT_HTTP 11
#define TSDB_PORT_HTTP 11
#ifdef __cplusplus
#ifdef __cplusplus
...
...
include/common/tmsg.h
浏览文件 @
3e455e37
...
@@ -184,6 +184,13 @@ typedef struct SField {
...
@@ -184,6 +184,13 @@ typedef struct SField {
int32_t
bytes
;
int32_t
bytes
;
}
SField
;
}
SField
;
typedef
struct
SRetention
{
int32_t
freq
;
int32_t
keep
;
int8_t
freqUnit
;
int8_t
keepUnit
;
}
SRetention
;
#pragma pack(push, 1)
#pragma pack(push, 1)
// null-terminated string instead of char array to avoid too many memory consumption in case of more than 1M tableMeta
// null-terminated string instead of char array to avoid too many memory consumption in case of more than 1M tableMeta
...
@@ -272,11 +279,14 @@ typedef struct {
...
@@ -272,11 +279,14 @@ typedef struct {
float
xFilesFactor
;
float
xFilesFactor
;
int32_t
aggregationMethod
;
int32_t
aggregationMethod
;
int32_t
delay
;
int32_t
delay
;
int32_t
ttl
;
int32_t
numOfColumns
;
int32_t
numOfColumns
;
int32_t
numOfTags
;
int32_t
numOfTags
;
int32_t
numOfSmas
;
int32_t
commentLen
;
int32_t
commentLen
;
SArray
*
pColumns
;
SArray
*
pColumns
;
// array of SField
SArray
*
pTags
;
SArray
*
pTags
;
// array of SField
SArray
*
pSmas
;
// array of SField
char
*
comment
;
char
*
comment
;
}
SMCreateStbReq
;
}
SMCreateStbReq
;
...
@@ -467,7 +477,8 @@ typedef struct {
...
@@ -467,7 +477,8 @@ typedef struct {
int32_t
tz
;
// query client timezone
int32_t
tz
;
// query client timezone
char
intervalUnit
;
char
intervalUnit
;
char
slidingUnit
;
char
slidingUnit
;
char
offsetUnit
;
char
offsetUnit
;
// TODO Remove it, the offset is the number of precision tickle, and it must be a immutable duration.
int8_t
precision
;
int64_t
interval
;
int64_t
interval
;
int64_t
sliding
;
int64_t
sliding
;
int64_t
offset
;
int64_t
offset
;
...
@@ -503,10 +514,13 @@ typedef struct {
...
@@ -503,10 +514,13 @@ typedef struct {
int8_t
cacheLastRow
;
int8_t
cacheLastRow
;
int8_t
ignoreExist
;
int8_t
ignoreExist
;
int8_t
streamMode
;
int8_t
streamMode
;
int32_t
numOfRetensions
;
SArray
*
pRetensions
;
// SRetention
}
SCreateDbReq
;
}
SCreateDbReq
;
int32_t
tSerializeSCreateDbReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateDbReq
*
pReq
);
int32_t
tSerializeSCreateDbReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateDbReq
*
pReq
);
int32_t
tDeserializeSCreateDbReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateDbReq
*
pReq
);
int32_t
tDeserializeSCreateDbReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateDbReq
*
pReq
);
void
tFreeSCreateDbReq
(
SCreateDbReq
*
pReq
);
typedef
struct
{
typedef
struct
{
char
db
[
TSDB_DB_FNAME_LEN
];
char
db
[
TSDB_DB_FNAME_LEN
];
...
@@ -751,11 +765,13 @@ typedef struct {
...
@@ -751,11 +765,13 @@ typedef struct {
int8_t
selfIndex
;
int8_t
selfIndex
;
int8_t
streamMode
;
int8_t
streamMode
;
SReplica
replicas
[
TSDB_MAX_REPLICA
];
SReplica
replicas
[
TSDB_MAX_REPLICA
];
int32_t
numOfRetensions
;
SArray
*
pRetensions
;
// SRetention
}
SCreateVnodeReq
,
SAlterVnodeReq
;
}
SCreateVnodeReq
,
SAlterVnodeReq
;
int32_t
tSerializeSCreateVnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateVnodeReq
*
pReq
);
int32_t
tSerializeSCreateVnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateVnodeReq
*
pReq
);
int32_t
tDeserializeSCreateVnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateVnodeReq
*
pReq
);
int32_t
tDeserializeSCreateVnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SCreateVnodeReq
*
pReq
);
int32_t
tFreeSCreateVnodeReq
(
SCreateVnodeReq
*
pReq
);
typedef
struct
{
typedef
struct
{
int32_t
vgId
;
int32_t
vgId
;
...
...
include/libs/function/function.h
浏览文件 @
3e455e37
...
@@ -327,7 +327,7 @@ bool taosFillHasMoreResults(struct SFillInfo* pFillInfo);
...
@@ -327,7 +327,7 @@ bool taosFillHasMoreResults(struct SFillInfo* pFillInfo);
struct
SFillInfo
*
taosCreateFillInfo
(
int32_t
order
,
TSKEY
skey
,
int32_t
numOfTags
,
int32_t
capacity
,
int32_t
numOfCols
,
struct
SFillInfo
*
taosCreateFillInfo
(
int32_t
order
,
TSKEY
skey
,
int32_t
numOfTags
,
int32_t
capacity
,
int32_t
numOfCols
,
int64_t
slidingTime
,
int8_t
slidingUnit
,
int8_t
precision
,
int32_t
fillType
,
int64_t
slidingTime
,
int8_t
slidingUnit
,
int8_t
precision
,
int32_t
fillType
,
struct
SFillColInfo
*
pFillCol
,
void
*
handle
);
struct
SFillColInfo
*
pFillCol
,
const
char
*
id
);
void
*
taosDestroyFillInfo
(
struct
SFillInfo
*
pFillInfo
);
void
*
taosDestroyFillInfo
(
struct
SFillInfo
*
pFillInfo
);
int64_t
taosFillResultDataBlock
(
struct
SFillInfo
*
pFillInfo
,
void
**
output
,
int32_t
capacity
);
int64_t
taosFillResultDataBlock
(
struct
SFillInfo
*
pFillInfo
,
void
**
output
,
int32_t
capacity
);
...
...
include/libs/nodes/nodes.h
浏览文件 @
3e455e37
...
@@ -135,6 +135,7 @@ typedef enum ENodeType {
...
@@ -135,6 +135,7 @@ typedef enum ENodeType {
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
,
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
,
QUERY_NODE_PHYSICAL_PLAN_SORT
,
QUERY_NODE_PHYSICAL_PLAN_SORT
,
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
,
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
,
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW
,
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
,
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
,
QUERY_NODE_PHYSICAL_PLAN_INSERT
,
QUERY_NODE_PHYSICAL_PLAN_INSERT
,
QUERY_NODE_PHYSICAL_SUBPLAN
,
QUERY_NODE_PHYSICAL_SUBPLAN
,
...
@@ -169,6 +170,7 @@ void nodesDestroyNode(SNodeptr pNode);
...
@@ -169,6 +170,7 @@ void nodesDestroyNode(SNodeptr pNode);
SNodeList
*
nodesMakeList
();
SNodeList
*
nodesMakeList
();
int32_t
nodesListAppend
(
SNodeList
*
pList
,
SNodeptr
pNode
);
int32_t
nodesListAppend
(
SNodeList
*
pList
,
SNodeptr
pNode
);
int32_t
nodesListStrictAppend
(
SNodeList
*
pList
,
SNodeptr
pNode
);
int32_t
nodesListStrictAppend
(
SNodeList
*
pList
,
SNodeptr
pNode
);
int32_t
nodesListMakeAppend
(
SNodeList
**
pList
,
SNodeptr
pNode
);
int32_t
nodesListAppendList
(
SNodeList
*
pTarget
,
SNodeList
*
pSrc
);
int32_t
nodesListAppendList
(
SNodeList
*
pTarget
,
SNodeList
*
pSrc
);
int32_t
nodesListStrictAppendList
(
SNodeList
*
pTarget
,
SNodeList
*
pSrc
);
int32_t
nodesListStrictAppendList
(
SNodeList
*
pTarget
,
SNodeList
*
pSrc
);
SListCell
*
nodesListErase
(
SNodeList
*
pList
,
SListCell
*
pCell
);
SListCell
*
nodesListErase
(
SNodeList
*
pList
,
SListCell
*
pCell
);
...
...
include/libs/nodes/plannodes.h
浏览文件 @
3e455e37
...
@@ -95,6 +95,7 @@ typedef struct SWindowLogicNode {
...
@@ -95,6 +95,7 @@ typedef struct SWindowLogicNode {
int8_t
intervalUnit
;
int8_t
intervalUnit
;
int8_t
slidingUnit
;
int8_t
slidingUnit
;
SFillNode
*
pFill
;
SFillNode
*
pFill
;
int64_t
sessionGap
;
}
SWindowLogicNode
;
}
SWindowLogicNode
;
typedef
enum
ESubplanType
{
typedef
enum
ESubplanType
{
...
@@ -110,7 +111,7 @@ typedef struct SSubplanId {
...
@@ -110,7 +111,7 @@ typedef struct SSubplanId {
int32_t
subplanId
;
int32_t
subplanId
;
}
SSubplanId
;
}
SSubplanId
;
typedef
struct
S
SubLogicP
lan
{
typedef
struct
S
LogicSubp
lan
{
ENodeType
type
;
ENodeType
type
;
SSubplanId
id
;
SSubplanId
id
;
SNodeList
*
pChildren
;
SNodeList
*
pChildren
;
...
@@ -120,7 +121,7 @@ typedef struct SSubLogicPlan {
...
@@ -120,7 +121,7 @@ typedef struct SSubLogicPlan {
SVgroupsInfo
*
pVgroupList
;
SVgroupsInfo
*
pVgroupList
;
int32_t
level
;
int32_t
level
;
int32_t
splitFlag
;
int32_t
splitFlag
;
}
S
SubLogicP
lan
;
}
S
LogicSubp
lan
;
typedef
struct
SQueryLogicPlan
{
typedef
struct
SQueryLogicPlan
{
ENodeType
type
;
ENodeType
type
;
...
@@ -213,10 +214,14 @@ typedef struct SExchangePhysiNode {
...
@@ -213,10 +214,14 @@ typedef struct SExchangePhysiNode {
SNodeList
*
pSrcEndPoints
;
// element is SDownstreamSource, scheduler fill by calling qSetSuplanExecutionNode
SNodeList
*
pSrcEndPoints
;
// element is SDownstreamSource, scheduler fill by calling qSetSuplanExecutionNode
}
SExchangePhysiNode
;
}
SExchangePhysiNode
;
typedef
struct
S
Interval
PhysiNode
{
typedef
struct
S
Winodw
PhysiNode
{
SPhysiNode
node
;
SPhysiNode
node
;
SNodeList
*
pExprs
;
// these are expression list of parameter expression of function
SNodeList
*
pExprs
;
// these are expression list of parameter expression of function
SNodeList
*
pFuncs
;
SNodeList
*
pFuncs
;
}
SWinodwPhysiNode
;
typedef
struct
SIntervalPhysiNode
{
SWinodwPhysiNode
window
;
int64_t
interval
;
int64_t
interval
;
int64_t
offset
;
int64_t
offset
;
int64_t
sliding
;
int64_t
sliding
;
...
@@ -225,6 +230,11 @@ typedef struct SIntervalPhysiNode {
...
@@ -225,6 +230,11 @@ typedef struct SIntervalPhysiNode {
SFillNode
*
pFill
;
SFillNode
*
pFill
;
}
SIntervalPhysiNode
;
}
SIntervalPhysiNode
;
typedef
struct
SSessionWinodwPhysiNode
{
SWinodwPhysiNode
window
;
int64_t
gap
;
}
SSessionWinodwPhysiNode
;
typedef
struct
SDataSinkNode
{
typedef
struct
SDataSinkNode
{
ENodeType
type
;
ENodeType
type
;
SDataBlockDescNode
*
pInputDataBlockDesc
;
SDataBlockDescNode
*
pInputDataBlockDesc
;
...
...
include/libs/nodes/querynodes.h
浏览文件 @
3e455e37
...
@@ -191,8 +191,8 @@ typedef struct SStateWindowNode {
...
@@ -191,8 +191,8 @@ typedef struct SStateWindowNode {
typedef
struct
SSessionWindowNode
{
typedef
struct
SSessionWindowNode
{
ENodeType
type
;
// QUERY_NODE_SESSION_WINDOW
ENodeType
type
;
// QUERY_NODE_SESSION_WINDOW
int64_t
gap
;
// gap between two session window(in microseconds)
SNode
*
pCol
;
SNode
*
pCol
;
SNode
*
pGap
;
// gap between two session window(in microseconds)
}
SSessionWindowNode
;
}
SSessionWindowNode
;
typedef
struct
SIntervalWindowNode
{
typedef
struct
SIntervalWindowNode
{
...
...
source/common/src/tmsg.c
浏览文件 @
3e455e37
...
@@ -287,6 +287,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
...
@@ -287,6 +287,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
int32_t
tlen
=
0
;
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
ver
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pReq
->
ver
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
dbFName
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
name
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
name
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pReq
->
ttl
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pReq
->
ttl
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pReq
->
keep
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pReq
->
keep
);
...
@@ -360,6 +361,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
...
@@ -360,6 +361,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
void
*
tDeserializeSVCreateTbReq
(
void
*
buf
,
SVCreateTbReq
*
pReq
)
{
void
*
tDeserializeSVCreateTbReq
(
void
*
buf
,
SVCreateTbReq
*
pReq
)
{
buf
=
taosDecodeFixedI64
(
buf
,
&
(
pReq
->
ver
));
buf
=
taosDecodeFixedI64
(
buf
,
&
(
pReq
->
ver
));
buf
=
taosDecodeString
(
buf
,
&
(
pReq
->
dbFName
));
buf
=
taosDecodeString
(
buf
,
&
(
pReq
->
name
));
buf
=
taosDecodeString
(
buf
,
&
(
pReq
->
name
));
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pReq
->
ttl
));
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pReq
->
ttl
));
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pReq
->
keep
));
buf
=
taosDecodeFixedU32
(
buf
,
&
(
pReq
->
keep
));
...
@@ -478,7 +480,7 @@ void *tDeserializeSVCreateTbBatchReq(void *buf, SVCreateTbBatchReq *pReq) {
...
@@ -478,7 +480,7 @@ void *tDeserializeSVCreateTbBatchReq(void *buf, SVCreateTbBatchReq *pReq) {
buf
=
taosDecodeFixedU32
(
buf
,
&
nsize
);
buf
=
taosDecodeFixedU32
(
buf
,
&
nsize
);
pReq
->
pArray
=
taosArrayInit
(
nsize
,
sizeof
(
SVCreateTbReq
));
pReq
->
pArray
=
taosArrayInit
(
nsize
,
sizeof
(
SVCreateTbReq
));
for
(
size_t
i
=
0
;
i
<
nsize
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
nsize
;
i
++
)
{
SVCreateTbReq
req
;
SVCreateTbReq
req
=
{
0
}
;
buf
=
tDeserializeSVCreateTbReq
(
buf
,
&
req
);
buf
=
tDeserializeSVCreateTbReq
(
buf
,
&
req
);
taosArrayPush
(
pReq
->
pArray
,
&
req
);
taosArrayPush
(
pReq
->
pArray
,
&
req
);
}
}
...
@@ -511,8 +513,10 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
...
@@ -511,8 +513,10 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
if
(
tEncodeFloat
(
&
encoder
,
pReq
->
xFilesFactor
)
<
0
)
return
-
1
;
if
(
tEncodeFloat
(
&
encoder
,
pReq
->
xFilesFactor
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
aggregationMethod
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
aggregationMethod
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
delay
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
delay
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
ttl
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfColumns
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfColumns
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfTags
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfTags
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfSmas
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
commentLen
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
commentLen
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfColumns
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfColumns
;
++
i
)
{
...
@@ -529,7 +533,16 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
...
@@ -529,7 +533,16 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq
if
(
tEncodeCStr
(
&
encoder
,
pField
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pField
->
name
)
<
0
)
return
-
1
;
}
}
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfSmas
;
++
i
)
{
SField
*
pField
=
taosArrayGet
(
pReq
->
pSmas
,
i
);
if
(
tEncodeI8
(
&
encoder
,
pField
->
type
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pField
->
bytes
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pField
->
name
)
<
0
)
return
-
1
;
}
if
(
pReq
->
commentLen
>
0
)
{
if
(
tEncodeBinary
(
&
encoder
,
pReq
->
comment
,
pReq
->
commentLen
)
<
0
)
return
-
1
;
if
(
tEncodeBinary
(
&
encoder
,
pReq
->
comment
,
pReq
->
commentLen
)
<
0
)
return
-
1
;
}
tEndEncode
(
&
encoder
);
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
int32_t
tlen
=
encoder
.
pos
;
...
@@ -547,13 +560,16 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
...
@@ -547,13 +560,16 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
if
(
tDecodeFloat
(
&
decoder
,
&
pReq
->
xFilesFactor
)
<
0
)
return
-
1
;
if
(
tDecodeFloat
(
&
decoder
,
&
pReq
->
xFilesFactor
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
aggregationMethod
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
aggregationMethod
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
delay
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
delay
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
ttl
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfColumns
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfColumns
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfTags
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfTags
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfSmas
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
commentLen
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
commentLen
)
<
0
)
return
-
1
;
pReq
->
pColumns
=
taosArrayInit
(
pReq
->
numOfColumns
,
sizeof
(
SField
));
pReq
->
pColumns
=
taosArrayInit
(
pReq
->
numOfColumns
,
sizeof
(
SField
));
pReq
->
pTags
=
taosArrayInit
(
pReq
->
numOfTags
,
sizeof
(
SField
));
pReq
->
pTags
=
taosArrayInit
(
pReq
->
numOfTags
,
sizeof
(
SField
));
if
(
pReq
->
pColumns
==
NULL
||
pReq
->
pTags
==
NULL
)
{
pReq
->
pSmas
=
taosArrayInit
(
pReq
->
numOfSmas
,
sizeof
(
SField
));
if
(
pReq
->
pColumns
==
NULL
||
pReq
->
pTags
==
NULL
||
pReq
->
pSmas
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
...
@@ -580,13 +596,23 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
...
@@ -580,13 +596,23 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
}
}
}
}
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfSmas
;
++
i
)
{
SField
field
=
{
0
};
if
(
tDecodeI8
(
&
decoder
,
&
field
.
type
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
field
.
bytes
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
field
.
name
)
<
0
)
return
-
1
;
if
(
taosArrayPush
(
pReq
->
pSmas
,
&
field
)
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
}
if
(
pReq
->
commentLen
>
0
)
{
if
(
pReq
->
commentLen
>
0
)
{
pReq
->
comment
=
malloc
(
pReq
->
commentLen
);
pReq
->
comment
=
malloc
(
pReq
->
commentLen
);
if
(
pReq
->
comment
==
NULL
)
return
-
1
;
if
(
pReq
->
comment
==
NULL
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
comment
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
comment
)
<
0
)
return
-
1
;
}
}
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
comment
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tEndDecode
(
&
decoder
);
tCoderClear
(
&
decoder
);
tCoderClear
(
&
decoder
);
...
@@ -596,8 +622,11 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
...
@@ -596,8 +622,11 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR
void
tFreeSMCreateStbReq
(
SMCreateStbReq
*
pReq
)
{
void
tFreeSMCreateStbReq
(
SMCreateStbReq
*
pReq
)
{
taosArrayDestroy
(
pReq
->
pColumns
);
taosArrayDestroy
(
pReq
->
pColumns
);
taosArrayDestroy
(
pReq
->
pTags
);
taosArrayDestroy
(
pReq
->
pTags
);
taosArrayDestroy
(
pReq
->
pSmas
);
tfree
(
pReq
->
comment
);
pReq
->
pColumns
=
NULL
;
pReq
->
pColumns
=
NULL
;
pReq
->
pTags
=
NULL
;
pReq
->
pTags
=
NULL
;
pReq
->
pSmas
=
NULL
;
}
}
int32_t
tSerializeSMDropStbReq
(
void
*
buf
,
int32_t
bufLen
,
SMDropStbReq
*
pReq
)
{
int32_t
tSerializeSMDropStbReq
(
void
*
buf
,
int32_t
bufLen
,
SMDropStbReq
*
pReq
)
{
...
@@ -1515,6 +1544,14 @@ int32_t tSerializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) {
...
@@ -1515,6 +1544,14 @@ int32_t tSerializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) {
if
(
tEncodeI8
(
&
encoder
,
pReq
->
cacheLastRow
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
cacheLastRow
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
ignoreExist
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
ignoreExist
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
streamMode
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
streamMode
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfRetensions
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfRetensions
;
++
i
)
{
SRetention
*
pRetension
=
taosArrayGet
(
pReq
->
pRetensions
,
i
);
if
(
tEncodeI32
(
&
encoder
,
pRetension
->
freq
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pRetension
->
keep
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pRetension
->
freqUnit
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pRetension
->
keepUnit
)
<
0
)
return
-
1
;
}
tEndEncode
(
&
encoder
);
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
int32_t
tlen
=
encoder
.
pos
;
...
@@ -1548,12 +1585,36 @@ int32_t tDeserializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq)
...
@@ -1548,12 +1585,36 @@ int32_t tDeserializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq)
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
cacheLastRow
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
cacheLastRow
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
ignoreExist
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
ignoreExist
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
streamMode
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
streamMode
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfRetensions
)
<
0
)
return
-
1
;
pReq
->
pRetensions
=
taosArrayInit
(
pReq
->
numOfRetensions
,
sizeof
(
SRetention
));
if
(
pReq
->
pRetensions
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfRetensions
;
++
i
)
{
SRetention
rentension
=
{
0
};
if
(
tDecodeI32
(
&
decoder
,
&
rentension
.
freq
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
rentension
.
keep
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
rentension
.
freqUnit
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
rentension
.
keepUnit
)
<
0
)
return
-
1
;
if
(
taosArrayPush
(
pReq
->
pRetensions
,
&
rentension
)
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
}
tEndDecode
(
&
decoder
);
tEndDecode
(
&
decoder
);
tCoderClear
(
&
decoder
);
tCoderClear
(
&
decoder
);
return
0
;
return
0
;
}
}
void
tFreeSCreateDbReq
(
SCreateDbReq
*
pReq
)
{
taosArrayDestroy
(
pReq
->
pRetensions
);
pReq
->
pRetensions
=
NULL
;
}
int32_t
tSerializeSAlterDbReq
(
void
*
buf
,
int32_t
bufLen
,
SAlterDbReq
*
pReq
)
{
int32_t
tSerializeSAlterDbReq
(
void
*
buf
,
int32_t
bufLen
,
SAlterDbReq
*
pReq
)
{
SCoder
encoder
=
{
0
};
SCoder
encoder
=
{
0
};
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
...
@@ -2431,6 +2492,14 @@ int32_t tSerializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *pR
...
@@ -2431,6 +2492,14 @@ int32_t tSerializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *pR
SReplica
*
pReplica
=
&
pReq
->
replicas
[
i
];
SReplica
*
pReplica
=
&
pReq
->
replicas
[
i
];
if
(
tEncodeSReplica
(
&
encoder
,
pReplica
)
<
0
)
return
-
1
;
if
(
tEncodeSReplica
(
&
encoder
,
pReplica
)
<
0
)
return
-
1
;
}
}
if
(
tEncodeI32
(
&
encoder
,
pReq
->
numOfRetensions
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfRetensions
;
++
i
)
{
SRetention
*
pRetension
=
taosArrayGet
(
pReq
->
pRetensions
,
i
);
if
(
tEncodeI32
(
&
encoder
,
pRetension
->
freq
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
&
encoder
,
pRetension
->
keep
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pRetension
->
freqUnit
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pRetension
->
keepUnit
)
<
0
)
return
-
1
;
}
tEndEncode
(
&
encoder
);
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
int32_t
tlen
=
encoder
.
pos
;
...
@@ -2475,11 +2544,35 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *
...
@@ -2475,11 +2544,35 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *
if
(
tDecodeSReplica
(
&
decoder
,
pReplica
)
<
0
)
return
-
1
;
if
(
tDecodeSReplica
(
&
decoder
,
pReplica
)
<
0
)
return
-
1
;
}
}
if
(
tDecodeI32
(
&
decoder
,
&
pReq
->
numOfRetensions
)
<
0
)
return
-
1
;
pReq
->
pRetensions
=
taosArrayInit
(
pReq
->
numOfRetensions
,
sizeof
(
SRetention
));
if
(
pReq
->
pRetensions
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
for
(
int32_t
i
=
0
;
i
<
pReq
->
numOfRetensions
;
++
i
)
{
SRetention
rentension
=
{
0
};
if
(
tDecodeI32
(
&
decoder
,
&
rentension
.
freq
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
rentension
.
keep
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
rentension
.
freqUnit
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
rentension
.
keepUnit
)
<
0
)
return
-
1
;
if
(
taosArrayPush
(
pReq
->
pRetensions
,
&
rentension
)
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
}
tEndDecode
(
&
decoder
);
tEndDecode
(
&
decoder
);
tCoderClear
(
&
decoder
);
tCoderClear
(
&
decoder
);
return
0
;
return
0
;
}
}
int32_t
tFreeSCreateVnodeReq
(
SCreateVnodeReq
*
pReq
)
{
taosArrayDestroy
(
pReq
->
pRetensions
);
pReq
->
pRetensions
=
NULL
;
}
int32_t
tSerializeSDropVnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SDropVnodeReq
*
pReq
)
{
int32_t
tSerializeSDropVnodeReq
(
void
*
buf
,
int32_t
bufLen
,
SDropVnodeReq
*
pReq
)
{
SCoder
encoder
=
{
0
};
SCoder
encoder
=
{
0
};
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
tCoderInit
(
&
encoder
,
TD_LITTLE_ENDIAN
,
buf
,
bufLen
,
TD_ENCODER
);
...
...
source/dnode/mgmt/test/vnode/vnode.cpp
浏览文件 @
3e455e37
...
@@ -158,6 +158,7 @@ TEST_F(DndTestVnode, 03_Create_Stb) {
...
@@ -158,6 +158,7 @@ TEST_F(DndTestVnode, 03_Create_Stb) {
for
(
int
i
=
0
;
i
<
1
;
++
i
)
{
for
(
int
i
=
0
;
i
<
1
;
++
i
)
{
SVCreateTbReq
req
=
{
0
};
SVCreateTbReq
req
=
{
0
};
req
.
ver
=
0
;
req
.
ver
=
0
;
req
.
dbFName
=
(
char
*
)
"1.db1"
;
req
.
name
=
(
char
*
)
"stb1"
;
req
.
name
=
(
char
*
)
"stb1"
;
req
.
ttl
=
0
;
req
.
ttl
=
0
;
req
.
keep
=
0
;
req
.
keep
=
0
;
...
@@ -229,6 +230,7 @@ TEST_F(DndTestVnode, 04_Alter_Stb) {
...
@@ -229,6 +230,7 @@ TEST_F(DndTestVnode, 04_Alter_Stb) {
for
(
int
i
=
0
;
i
<
1
;
++
i
)
{
for
(
int
i
=
0
;
i
<
1
;
++
i
)
{
SVCreateTbReq
req
=
{
0
};
SVCreateTbReq
req
=
{
0
};
req
.
ver
=
0
;
req
.
ver
=
0
;
req
.
dbFName
=
(
char
*
)
"1.db1"
;
req
.
name
=
(
char
*
)
"stb1"
;
req
.
name
=
(
char
*
)
"stb1"
;
req
.
ttl
=
0
;
req
.
ttl
=
0
;
req
.
keep
=
0
;
req
.
keep
=
0
;
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
3e455e37
...
@@ -267,6 +267,8 @@ typedef struct {
...
@@ -267,6 +267,8 @@ typedef struct {
int8_t
update
;
int8_t
update
;
int8_t
cacheLastRow
;
int8_t
cacheLastRow
;
int8_t
streamMode
;
int8_t
streamMode
;
int32_t
numOfRetensions
;
SArray
*
pRetensions
;
}
SDbCfg
;
}
SDbCfg
;
typedef
struct
{
typedef
struct
{
...
@@ -344,11 +346,14 @@ typedef struct {
...
@@ -344,11 +346,14 @@ typedef struct {
float
xFilesFactor
;
float
xFilesFactor
;
int32_t
aggregationMethod
;
int32_t
aggregationMethod
;
int32_t
delay
;
int32_t
delay
;
int32_t
ttl
;
int32_t
numOfColumns
;
int32_t
numOfColumns
;
int32_t
numOfTags
;
int32_t
numOfTags
;
int32_t
numOfSmas
;
int32_t
commentLen
;
int32_t
commentLen
;
SSchema
*
pColumns
;
SSchema
*
pColumns
;
SSchema
*
pTags
;
SSchema
*
pTags
;
SSchema
*
pSmas
;
char
*
comment
;
char
*
comment
;
SRWLatch
lock
;
SRWLatch
lock
;
}
SStbObj
;
}
SStbObj
;
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
3e455e37
...
@@ -100,6 +100,15 @@ static SSdbRaw *mndDbActionEncode(SDbObj *pDb) {
...
@@ -100,6 +100,15 @@ static SSdbRaw *mndDbActionEncode(SDbObj *pDb) {
SDB_SET_INT8
(
pRaw
,
dataPos
,
pDb
->
cfg
.
quorum
,
DB_ENCODE_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pDb
->
cfg
.
quorum
,
DB_ENCODE_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pDb
->
cfg
.
update
,
DB_ENCODE_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pDb
->
cfg
.
update
,
DB_ENCODE_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pDb
->
cfg
.
cacheLastRow
,
DB_ENCODE_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pDb
->
cfg
.
cacheLastRow
,
DB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pDb
->
cfg
.
numOfRetensions
,
DB_ENCODE_OVER
)
for
(
int32_t
i
=
0
;
i
<
pDb
->
cfg
.
numOfRetensions
;
++
i
)
{
SRetention
*
pRetension
=
taosArrayGet
(
pDb
->
cfg
.
pRetensions
,
i
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pRetension
->
freq
,
DB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pRetension
->
keep
,
DB_ENCODE_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pRetension
->
freqUnit
,
DB_ENCODE_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pRetension
->
keepUnit
,
DB_ENCODE_OVER
)
}
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
TSDB_DB_RESERVE_SIZE
,
DB_ENCODE_OVER
)
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
TSDB_DB_RESERVE_SIZE
,
DB_ENCODE_OVER
)
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
DB_ENCODE_OVER
)
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
DB_ENCODE_OVER
)
...
@@ -161,6 +170,22 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) {
...
@@ -161,6 +170,22 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pDb
->
cfg
.
quorum
,
DB_DECODE_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pDb
->
cfg
.
quorum
,
DB_DECODE_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pDb
->
cfg
.
update
,
DB_DECODE_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pDb
->
cfg
.
update
,
DB_DECODE_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pDb
->
cfg
.
cacheLastRow
,
DB_DECODE_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pDb
->
cfg
.
cacheLastRow
,
DB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pDb
->
cfg
.
numOfRetensions
,
DB_DECODE_OVER
)
if
(
pDb
->
cfg
.
numOfRetensions
>
0
)
{
pDb
->
cfg
.
pRetensions
=
taosArrayInit
(
pDb
->
cfg
.
numOfRetensions
,
sizeof
(
SRetention
));
if
(
pDb
->
cfg
.
pRetensions
==
NULL
)
goto
DB_DECODE_OVER
;
for
(
int32_t
i
=
0
;
i
<
pDb
->
cfg
.
numOfRetensions
;
++
i
)
{
SRetention
retension
=
{
0
};
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
retension
.
freq
,
DB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
retension
.
keep
,
DB_DECODE_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
retension
.
freqUnit
,
DB_DECODE_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
retension
.
keepUnit
,
DB_DECODE_OVER
)
if
(
taosArrayPush
(
pDb
->
cfg
.
pRetensions
,
&
retension
)
==
NULL
)
{
goto
DB_DECODE_OVER
;
}
}
}
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
TSDB_DB_RESERVE_SIZE
,
DB_DECODE_OVER
)
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
TSDB_DB_RESERVE_SIZE
,
DB_DECODE_OVER
)
terrno
=
0
;
terrno
=
0
;
...
@@ -183,6 +208,7 @@ static int32_t mndDbActionInsert(SSdb *pSdb, SDbObj *pDb) {
...
@@ -183,6 +208,7 @@ static int32_t mndDbActionInsert(SSdb *pSdb, SDbObj *pDb) {
static
int32_t
mndDbActionDelete
(
SSdb
*
pSdb
,
SDbObj
*
pDb
)
{
static
int32_t
mndDbActionDelete
(
SSdb
*
pSdb
,
SDbObj
*
pDb
)
{
mTrace
(
"db:%s, perform delete action, row:%p"
,
pDb
->
name
,
pDb
);
mTrace
(
"db:%s, perform delete action, row:%p"
,
pDb
->
name
,
pDb
);
taosArrayDestroy
(
pDb
->
cfg
.
pRetensions
);
return
0
;
return
0
;
}
}
...
@@ -417,6 +443,10 @@ static int32_t mndCreateDb(SMnode *pMnode, SNodeMsg *pReq, SCreateDbReq *pCreate
...
@@ -417,6 +443,10 @@ static int32_t mndCreateDb(SMnode *pMnode, SNodeMsg *pReq, SCreateDbReq *pCreate
.
streamMode
=
pCreate
->
streamMode
,
.
streamMode
=
pCreate
->
streamMode
,
};
};
dbObj
.
cfg
.
numOfRetensions
=
pCreate
->
numOfRetensions
;
dbObj
.
cfg
.
pRetensions
=
pCreate
->
pRetensions
;
pCreate
=
NULL
;
mndSetDefaultDbCfg
(
&
dbObj
.
cfg
);
mndSetDefaultDbCfg
(
&
dbObj
.
cfg
);
if
(
mndCheckDbName
(
dbObj
.
name
,
pUser
)
!=
0
)
{
if
(
mndCheckDbName
(
dbObj
.
name
,
pUser
)
!=
0
)
{
...
@@ -505,6 +535,7 @@ CREATE_DB_OVER:
...
@@ -505,6 +535,7 @@ CREATE_DB_OVER:
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseDb
(
pMnode
,
pDb
);
mndReleaseUser
(
pMnode
,
pUser
);
mndReleaseUser
(
pMnode
,
pUser
);
tFreeSCreateDbReq
(
&
createReq
);
return
code
;
return
code
;
}
}
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
3e455e37
...
@@ -72,7 +72,8 @@ void mndCleanupStb(SMnode *pMnode) {}
...
@@ -72,7 +72,8 @@ void mndCleanupStb(SMnode *pMnode) {}
SSdbRaw
*
mndStbActionEncode
(
SStbObj
*
pStb
)
{
SSdbRaw
*
mndStbActionEncode
(
SStbObj
*
pStb
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
int32_t
size
=
sizeof
(
SStbObj
)
+
(
pStb
->
numOfColumns
+
pStb
->
numOfTags
)
*
sizeof
(
SSchema
)
+
TSDB_STB_RESERVE_SIZE
;
int32_t
size
=
sizeof
(
SStbObj
)
+
(
pStb
->
numOfColumns
+
pStb
->
numOfTags
+
pStb
->
numOfSmas
)
*
sizeof
(
SSchema
)
+
TSDB_STB_RESERVE_SIZE
;
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_STB
,
TSDB_STB_VER_NUMBER
,
size
);
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_STB
,
TSDB_STB_VER_NUMBER
,
size
);
if
(
pRaw
==
NULL
)
goto
STB_ENCODE_OVER
;
if
(
pRaw
==
NULL
)
goto
STB_ENCODE_OVER
;
...
@@ -88,8 +89,10 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
...
@@ -88,8 +89,10 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
SDB_SET_INT32
(
pRaw
,
dataPos
,
(
int32_t
)(
pStb
->
xFilesFactor
*
10000
),
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
(
int32_t
)(
pStb
->
xFilesFactor
*
10000
),
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
aggregationMethod
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
aggregationMethod
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
delay
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
delay
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
ttl
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
numOfColumns
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
numOfColumns
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
numOfTags
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
numOfTags
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
numOfSmas
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
commentLen
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
commentLen
,
STB_ENCODE_OVER
)
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfColumns
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfColumns
;
++
i
)
{
...
@@ -108,7 +111,17 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
...
@@ -108,7 +111,17 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
STB_ENCODE_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
STB_ENCODE_OVER
)
}
}
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfSmas
;
++
i
)
{
SSchema
*
pSchema
=
&
pStb
->
pSmas
[
i
];
SDB_SET_INT8
(
pRaw
,
dataPos
,
pSchema
->
type
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pSchema
->
colId
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pSchema
->
bytes
,
STB_ENCODE_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
STB_ENCODE_OVER
)
}
if
(
pStb
->
commentLen
>
0
)
{
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pStb
->
comment
,
pStb
->
commentLen
,
STB_ENCODE_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pStb
->
comment
,
pStb
->
commentLen
,
STB_ENCODE_OVER
)
}
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
TSDB_STB_RESERVE_SIZE
,
STB_ENCODE_OVER
)
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
TSDB_STB_RESERVE_SIZE
,
STB_ENCODE_OVER
)
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
STB_ENCODE_OVER
)
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
STB_ENCODE_OVER
)
...
@@ -156,13 +169,16 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
...
@@ -156,13 +169,16 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
pStb
->
xFilesFactor
=
xFilesFactor
/
10000
.
0
f
;
pStb
->
xFilesFactor
=
xFilesFactor
/
10000
.
0
f
;
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
aggregationMethod
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
aggregationMethod
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
delay
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
delay
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
ttl
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
numOfColumns
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
numOfColumns
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
numOfTags
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
numOfTags
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
numOfSmas
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
commentLen
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
commentLen
,
STB_DECODE_OVER
)
pStb
->
pColumns
=
calloc
(
pStb
->
numOfColumns
,
sizeof
(
SSchema
));
pStb
->
pColumns
=
calloc
(
pStb
->
numOfColumns
,
sizeof
(
SSchema
));
pStb
->
pTags
=
calloc
(
pStb
->
numOfTags
,
sizeof
(
SSchema
));
pStb
->
pTags
=
calloc
(
pStb
->
numOfTags
,
sizeof
(
SSchema
));
if
(
pStb
->
pColumns
==
NULL
||
pStb
->
pTags
==
NULL
)
{
pStb
->
pSmas
=
calloc
(
pStb
->
numOfSmas
,
sizeof
(
SSchema
));
if
(
pStb
->
pColumns
==
NULL
||
pStb
->
pTags
==
NULL
||
pStb
->
pSmas
==
NULL
)
{
goto
STB_DECODE_OVER
;
goto
STB_DECODE_OVER
;
}
}
...
@@ -182,6 +198,14 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
...
@@ -182,6 +198,14 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
STB_DECODE_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
STB_DECODE_OVER
)
}
}
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfSmas
;
++
i
)
{
SSchema
*
pSchema
=
&
pStb
->
pSmas
[
i
];
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pSchema
->
type
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pSchema
->
colId
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pSchema
->
bytes
,
STB_DECODE_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
STB_DECODE_OVER
)
}
if
(
pStb
->
commentLen
>
0
)
{
if
(
pStb
->
commentLen
>
0
)
{
pStb
->
comment
=
calloc
(
pStb
->
commentLen
,
1
);
pStb
->
comment
=
calloc
(
pStb
->
commentLen
,
1
);
if
(
pStb
->
comment
==
NULL
)
goto
STB_DECODE_OVER
;
if
(
pStb
->
comment
==
NULL
)
goto
STB_DECODE_OVER
;
...
@@ -247,6 +271,30 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
...
@@ -247,6 +271,30 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
}
}
}
}
if
(
pOld
->
numOfSmas
<
pNew
->
numOfSmas
)
{
void
*
pSmas
=
malloc
(
pNew
->
numOfSmas
*
sizeof
(
SSchema
));
if
(
pSmas
!=
NULL
)
{
free
(
pOld
->
pSmas
);
pOld
->
pSmas
=
pSmas
;
}
else
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
mTrace
(
"stb:%s, failed to perform update action since %s"
,
pOld
->
name
,
terrstr
());
taosWUnLockLatch
(
&
pOld
->
lock
);
}
}
if
(
pOld
->
commentLen
<
pNew
->
commentLen
)
{
void
*
comment
=
malloc
(
pNew
->
commentLen
);
if
(
comment
!=
NULL
)
{
free
(
pOld
->
comment
);
pOld
->
comment
=
comment
;
}
else
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
mTrace
(
"stb:%s, failed to perform update action since %s"
,
pOld
->
name
,
terrstr
());
taosWUnLockLatch
(
&
pOld
->
lock
);
}
}
pOld
->
updateTime
=
pNew
->
updateTime
;
pOld
->
updateTime
=
pNew
->
updateTime
;
pOld
->
version
=
pNew
->
version
;
pOld
->
version
=
pNew
->
version
;
pOld
->
nextColId
=
pNew
->
nextColId
;
pOld
->
nextColId
=
pNew
->
nextColId
;
...
@@ -254,7 +302,9 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
...
@@ -254,7 +302,9 @@ static int32_t mndStbActionUpdate(SSdb *pSdb, SStbObj *pOld, SStbObj *pNew) {
pOld
->
numOfTags
=
pNew
->
numOfTags
;
pOld
->
numOfTags
=
pNew
->
numOfTags
;
memcpy
(
pOld
->
pColumns
,
pNew
->
pColumns
,
pOld
->
numOfColumns
*
sizeof
(
SSchema
));
memcpy
(
pOld
->
pColumns
,
pNew
->
pColumns
,
pOld
->
numOfColumns
*
sizeof
(
SSchema
));
memcpy
(
pOld
->
pTags
,
pNew
->
pTags
,
pOld
->
numOfTags
*
sizeof
(
SSchema
));
memcpy
(
pOld
->
pTags
,
pNew
->
pTags
,
pOld
->
numOfTags
*
sizeof
(
SSchema
));
if
(
pNew
->
commentLen
!=
0
)
{
memcpy
(
pOld
->
comment
,
pNew
->
comment
,
TSDB_STB_COMMENT_LEN
);
memcpy
(
pOld
->
comment
,
pNew
->
comment
,
TSDB_STB_COMMENT_LEN
);
}
taosWUnLockLatch
(
&
pOld
->
lock
);
taosWUnLockLatch
(
&
pOld
->
lock
);
return
0
;
return
0
;
}
}
...
@@ -286,9 +336,12 @@ static SDbObj *mndAcquireDbByStb(SMnode *pMnode, const char *stbName) {
...
@@ -286,9 +336,12 @@ static SDbObj *mndAcquireDbByStb(SMnode *pMnode, const char *stbName) {
static
void
*
mndBuildVCreateStbReq
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
,
SStbObj
*
pStb
,
int32_t
*
pContLen
)
{
static
void
*
mndBuildVCreateStbReq
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
,
SStbObj
*
pStb
,
int32_t
*
pContLen
)
{
SName
name
=
{
0
};
SName
name
=
{
0
};
tNameFromString
(
&
name
,
pStb
->
name
,
T_NAME_ACCT
|
T_NAME_DB
|
T_NAME_TABLE
);
tNameFromString
(
&
name
,
pStb
->
name
,
T_NAME_ACCT
|
T_NAME_DB
|
T_NAME_TABLE
);
char
dbFName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
tNameGetFullDbName
(
&
name
,
dbFName
);
SVCreateTbReq
req
=
{
0
};
SVCreateTbReq
req
=
{
0
};
req
.
ver
=
0
;
req
.
ver
=
0
;
req
.
dbFName
=
dbFName
;
req
.
name
=
(
char
*
)
tNameGetTableName
(
&
name
);
req
.
name
=
(
char
*
)
tNameGetTableName
(
&
name
);
req
.
ttl
=
0
;
req
.
ttl
=
0
;
req
.
keep
=
0
;
req
.
keep
=
0
;
...
@@ -505,6 +558,16 @@ static int32_t mndSetCreateStbUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj
...
@@ -505,6 +558,16 @@ static int32_t mndSetCreateStbUndoActions(SMnode *pMnode, STrans *pTrans, SDbObj
return
0
;
return
0
;
}
}
static
SSchema
*
mndFindStbColumns
(
const
SStbObj
*
pStb
,
const
char
*
colName
)
{
for
(
int32_t
col
=
0
;
col
<
pStb
->
numOfColumns
;
col
++
)
{
SSchema
*
pSchema
=
&
pStb
->
pColumns
[
col
];
if
(
strcasecmp
(
pStb
->
pColumns
[
col
].
name
,
colName
)
==
0
)
{
return
pSchema
;
}
}
return
NULL
;
}
static
int32_t
mndCreateStb
(
SMnode
*
pMnode
,
SNodeMsg
*
pReq
,
SMCreateStbReq
*
pCreate
,
SDbObj
*
pDb
)
{
static
int32_t
mndCreateStb
(
SMnode
*
pMnode
,
SNodeMsg
*
pReq
,
SMCreateStbReq
*
pCreate
,
SDbObj
*
pDb
)
{
SStbObj
stbObj
=
{
0
};
SStbObj
stbObj
=
{
0
};
memcpy
(
stbObj
.
name
,
pCreate
->
name
,
TSDB_TABLE_FNAME_LEN
);
memcpy
(
stbObj
.
name
,
pCreate
->
name
,
TSDB_TABLE_FNAME_LEN
);
...
@@ -515,19 +578,24 @@ static int32_t mndCreateStb(SMnode *pMnode, SNodeMsg *pReq, SMCreateStbReq *pCre
...
@@ -515,19 +578,24 @@ static int32_t mndCreateStb(SMnode *pMnode, SNodeMsg *pReq, SMCreateStbReq *pCre
stbObj
.
dbUid
=
pDb
->
uid
;
stbObj
.
dbUid
=
pDb
->
uid
;
stbObj
.
version
=
1
;
stbObj
.
version
=
1
;
stbObj
.
nextColId
=
1
;
stbObj
.
nextColId
=
1
;
stbObj
.
ttl
=
pCreate
->
ttl
;
stbObj
.
numOfColumns
=
pCreate
->
numOfColumns
;
stbObj
.
numOfColumns
=
pCreate
->
numOfColumns
;
stbObj
.
numOfTags
=
pCreate
->
numOfTags
;
stbObj
.
numOfTags
=
pCreate
->
numOfTags
;
stbObj
.
numOfSmas
=
pCreate
->
numOfSmas
;
stbObj
.
commentLen
=
pCreate
->
commentLen
;
stbObj
.
commentLen
=
pCreate
->
commentLen
;
if
(
stbObj
.
commentLen
>
0
)
{
stbObj
.
comment
=
calloc
(
stbObj
.
commentLen
,
1
);
stbObj
.
comment
=
calloc
(
stbObj
.
commentLen
,
1
);
if
(
stbObj
.
comment
==
NULL
)
{
if
(
stbObj
.
comment
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
memcpy
(
stbObj
.
comment
,
pCreate
->
comment
,
stbObj
.
commentLen
);
memcpy
(
stbObj
.
comment
,
pCreate
->
comment
,
stbObj
.
commentLen
);
}
stbObj
.
pColumns
=
malloc
(
stbObj
.
numOfColumns
*
sizeof
(
SSchema
));
stbObj
.
pColumns
=
malloc
(
stbObj
.
numOfColumns
*
sizeof
(
SSchema
));
stbObj
.
pTags
=
malloc
(
stbObj
.
numOfTags
*
sizeof
(
SSchema
));
stbObj
.
pTags
=
malloc
(
stbObj
.
numOfTags
*
sizeof
(
SSchema
));
if
(
stbObj
.
pColumns
==
NULL
||
stbObj
.
pTags
==
NULL
)
{
stbObj
.
pSmas
=
malloc
(
stbObj
.
numOfSmas
*
sizeof
(
SSchema
));
if
(
stbObj
.
pColumns
==
NULL
||
stbObj
.
pTags
==
NULL
||
stbObj
.
pSmas
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
...
@@ -552,6 +620,18 @@ static int32_t mndCreateStb(SMnode *pMnode, SNodeMsg *pReq, SMCreateStbReq *pCre
...
@@ -552,6 +620,18 @@ static int32_t mndCreateStb(SMnode *pMnode, SNodeMsg *pReq, SMCreateStbReq *pCre
stbObj
.
nextColId
++
;
stbObj
.
nextColId
++
;
}
}
for
(
int32_t
i
=
0
;
i
<
stbObj
.
numOfSmas
;
++
i
)
{
SField
*
pField
=
taosArrayGet
(
pCreate
->
pSmas
,
i
);
SSchema
*
pSchema
=
&
stbObj
.
pSmas
[
i
];
SSchema
*
pColSchema
=
mndFindStbColumns
(
&
stbObj
,
pField
->
name
);
if
(
pColSchema
==
NULL
)
{
mError
(
"stb:%s, sma:%s not found in columns"
,
stbObj
.
name
,
pSchema
->
name
);
terrno
=
TSDB_CODE_MND_INVALID_STB_OPTION
;
return
-
1
;
}
memcpy
(
pSchema
,
pColSchema
,
sizeof
(
SSchema
));
}
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_CREATE_STB
,
&
pReq
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_CREATE_STB
,
&
pReq
->
rpcMsg
);
if
(
pTrans
==
NULL
)
goto
CREATE_STB_OVER
;
if
(
pTrans
==
NULL
)
goto
CREATE_STB_OVER
;
...
@@ -1536,19 +1616,11 @@ static int32_t mndRetrieveStb(SNodeMsg *pReq, SShowObj *pShow, char *data, int32
...
@@ -1536,19 +1616,11 @@ static int32_t mndRetrieveStb(SNodeMsg *pReq, SShowObj *pShow, char *data, int32
if
(
pDb
==
NULL
)
return
0
;
if
(
pDb
==
NULL
)
return
0
;
}
}
tstrncpy
(
prefix
,
pShow
->
db
,
TSDB_DB_FNAME_LEN
);
strcat
(
prefix
,
TS_PATH_DELIMITER
);
int32_t
prefixLen
=
(
int32_t
)
strlen
(
prefix
);
while
(
numOfRows
<
rows
)
{
while
(
numOfRows
<
rows
)
{
pShow
->
pIter
=
sdbFetch
(
pSdb
,
SDB_STB
,
pShow
->
pIter
,
(
void
**
)
&
pStb
);
pShow
->
pIter
=
sdbFetch
(
pSdb
,
SDB_STB
,
pShow
->
pIter
,
(
void
**
)
&
pStb
);
if
(
pShow
->
pIter
==
NULL
)
break
;
if
(
pShow
->
pIter
==
NULL
)
break
;
if
(
pDb
!=
NULL
&&
pStb
->
dbUid
!=
pDb
->
uid
)
{
if
(
pDb
!=
NULL
&&
pStb
->
dbUid
!=
pDb
->
uid
)
{
if
(
strncmp
(
pStb
->
db
,
pDb
->
name
,
prefixLen
)
==
0
)
{
mError
(
"Inconsistent table data, name:%s, db:%s, dbUid:%"
PRIu64
,
pStb
->
name
,
pDb
->
name
,
pDb
->
uid
);
}
sdbRelease
(
pSdb
,
pStb
);
sdbRelease
(
pSdb
,
pStb
);
continue
;
continue
;
}
}
...
...
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
3e455e37
...
@@ -218,6 +218,8 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg
...
@@ -218,6 +218,8 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg
createReq
.
hashBegin
=
pVgroup
->
hashBegin
;
createReq
.
hashBegin
=
pVgroup
->
hashBegin
;
createReq
.
hashEnd
=
pVgroup
->
hashEnd
;
createReq
.
hashEnd
=
pVgroup
->
hashEnd
;
createReq
.
hashMethod
=
pDb
->
hashMethod
;
createReq
.
hashMethod
=
pDb
->
hashMethod
;
createReq
.
numOfRetensions
=
pDb
->
cfg
.
numOfRetensions
;
createReq
.
pRetensions
=
pDb
->
cfg
.
pRetensions
;
for
(
int32_t
v
=
0
;
v
<
pVgroup
->
replica
;
++
v
)
{
for
(
int32_t
v
=
0
;
v
<
pVgroup
->
replica
;
++
v
)
{
SReplica
*
pReplica
=
&
createReq
.
replicas
[
v
];
SReplica
*
pReplica
=
&
createReq
.
replicas
[
v
];
...
...
source/dnode/mnode/impl/test/sma/sma.cpp
浏览文件 @
3e455e37
...
@@ -26,9 +26,12 @@ class MndTestSma : public ::testing::Test {
...
@@ -26,9 +26,12 @@ class MndTestSma : public ::testing::Test {
void
*
BuildDropDbReq
(
const
char
*
dbname
,
int32_t
*
pContLen
);
void
*
BuildDropDbReq
(
const
char
*
dbname
,
int32_t
*
pContLen
);
void
*
BuildCreateStbReq
(
const
char
*
stbname
,
int32_t
*
pContLen
);
void
*
BuildCreateStbReq
(
const
char
*
stbname
,
int32_t
*
pContLen
);
void
*
BuildDropStbReq
(
const
char
*
stbname
,
int32_t
*
pContLen
);
void
*
BuildDropStbReq
(
const
char
*
stbname
,
int32_t
*
pContLen
);
void
*
BuildCreateSmaReq
(
const
char
*
smaname
,
const
char
*
stbname
,
int8_t
igExists
,
const
char
*
expr
,
void
*
BuildCreateBSmaStbReq
(
const
char
*
stbname
,
int32_t
*
pContLen
);
void
*
BuildCreateTSmaReq
(
const
char
*
smaname
,
const
char
*
stbname
,
int8_t
igExists
,
const
char
*
expr
,
const
char
*
tagsFilter
,
const
char
*
sql
,
const
char
*
ast
,
int32_t
*
pContLen
);
const
char
*
tagsFilter
,
const
char
*
sql
,
const
char
*
ast
,
int32_t
*
pContLen
);
void
*
BuildDropSmaReq
(
const
char
*
smaname
,
int8_t
igNotExists
,
int32_t
*
pContLen
);
void
*
BuildDropTSmaReq
(
const
char
*
smaname
,
int8_t
igNotExists
,
int32_t
*
pContLen
);
void
PushField
(
SArray
*
pArray
,
int32_t
bytes
,
int8_t
type
,
const
char
*
name
);
};
};
Testbase
MndTestSma
::
test
;
Testbase
MndTestSma
::
test
;
...
@@ -76,6 +79,14 @@ void* MndTestSma::BuildDropDbReq(const char* dbname, int32_t* pContLen) {
...
@@ -76,6 +79,14 @@ void* MndTestSma::BuildDropDbReq(const char* dbname, int32_t* pContLen) {
return
pReq
;
return
pReq
;
}
}
void
MndTestSma
::
PushField
(
SArray
*
pArray
,
int32_t
bytes
,
int8_t
type
,
const
char
*
name
)
{
SField
field
=
{
0
};
field
.
bytes
=
bytes
;
field
.
type
=
type
;
strcpy
(
field
.
name
,
name
);
taosArrayPush
(
pArray
,
&
field
);
}
void
*
MndTestSma
::
BuildCreateStbReq
(
const
char
*
stbname
,
int32_t
*
pContLen
)
{
void
*
MndTestSma
::
BuildCreateStbReq
(
const
char
*
stbname
,
int32_t
*
pContLen
)
{
SMCreateStbReq
createReq
=
{
0
};
SMCreateStbReq
createReq
=
{
0
};
createReq
.
numOfColumns
=
3
;
createReq
.
numOfColumns
=
3
;
...
@@ -85,37 +96,35 @@ void* MndTestSma::BuildCreateStbReq(const char* stbname, int32_t* pContLen) {
...
@@ -85,37 +96,35 @@ void* MndTestSma::BuildCreateStbReq(const char* stbname, int32_t* pContLen) {
createReq
.
pTags
=
taosArrayInit
(
createReq
.
numOfTags
,
sizeof
(
SField
));
createReq
.
pTags
=
taosArrayInit
(
createReq
.
numOfTags
,
sizeof
(
SField
));
strcpy
(
createReq
.
name
,
stbname
);
strcpy
(
createReq
.
name
,
stbname
);
{
PushField
(
createReq
.
pColumns
,
8
,
TSDB_DATA_TYPE_TIMESTAMP
,
"ts"
);
SField
field
=
{
0
};
PushField
(
createReq
.
pColumns
,
2
,
TSDB_DATA_TYPE_TINYINT
,
"col1"
);
field
.
bytes
=
8
;
PushField
(
createReq
.
pColumns
,
8
,
TSDB_DATA_TYPE_BIGINT
,
"col2"
);
field
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
PushField
(
createReq
.
pTags
,
2
,
TSDB_DATA_TYPE_TINYINT
,
"tag1"
);
strcpy
(
field
.
name
,
"ts"
);
taosArrayPush
(
createReq
.
pColumns
,
&
field
);
}
{
int32_t
tlen
=
tSerializeSMCreateStbReq
(
NULL
,
0
,
&
createReq
);
SField
field
=
{
0
}
;
void
*
pHead
=
rpcMallocCont
(
tlen
)
;
field
.
bytes
=
2
;
tSerializeSMCreateStbReq
(
pHead
,
tlen
,
&
createReq
)
;
field
.
type
=
TSDB_DATA_TYPE_TINYINT
;
tFreeSMCreateStbReq
(
&
createReq
)
;
strcpy
(
field
.
name
,
"col1"
)
;
*
pContLen
=
tlen
;
taosArrayPush
(
createReq
.
pColumns
,
&
field
)
;
return
pHead
;
}
}
{
void
*
MndTestSma
::
BuildCreateBSmaStbReq
(
const
char
*
stbname
,
int32_t
*
pContLen
)
{
SField
field
=
{
0
};
SMCreateStbReq
createReq
=
{
0
};
field
.
bytes
=
8
;
createReq
.
numOfColumns
=
3
;
field
.
type
=
TSDB_DATA_TYPE_BIGINT
;
createReq
.
numOfTags
=
1
;
strcpy
(
field
.
name
,
"col2"
);
createReq
.
numOfSmas
=
1
;
taosArrayPush
(
createReq
.
pColumns
,
&
field
);
createReq
.
igExists
=
0
;
}
createReq
.
pColumns
=
taosArrayInit
(
createReq
.
numOfColumns
,
sizeof
(
SField
));
createReq
.
pTags
=
taosArrayInit
(
createReq
.
numOfTags
,
sizeof
(
SField
));
createReq
.
pSmas
=
taosArrayInit
(
createReq
.
numOfSmas
,
sizeof
(
SField
));
strcpy
(
createReq
.
name
,
stbname
);
{
PushField
(
createReq
.
pColumns
,
8
,
TSDB_DATA_TYPE_TIMESTAMP
,
"ts"
);
SField
field
=
{
0
};
PushField
(
createReq
.
pColumns
,
2
,
TSDB_DATA_TYPE_TINYINT
,
"col1"
);
field
.
bytes
=
2
;
PushField
(
createReq
.
pColumns
,
8
,
TSDB_DATA_TYPE_BIGINT
,
"col2"
);
field
.
type
=
TSDB_DATA_TYPE_TINYINT
;
PushField
(
createReq
.
pTags
,
2
,
TSDB_DATA_TYPE_TINYINT
,
"tag1"
);
strcpy
(
field
.
name
,
"tag1"
);
PushField
(
createReq
.
pSmas
,
2
,
TSDB_DATA_TYPE_TINYINT
,
"col1"
);
taosArrayPush
(
createReq
.
pTags
,
&
field
);
}
int32_t
tlen
=
tSerializeSMCreateStbReq
(
NULL
,
0
,
&
createReq
);
int32_t
tlen
=
tSerializeSMCreateStbReq
(
NULL
,
0
,
&
createReq
);
void
*
pHead
=
rpcMallocCont
(
tlen
);
void
*
pHead
=
rpcMallocCont
(
tlen
);
...
@@ -137,7 +146,7 @@ void* MndTestSma::BuildDropStbReq(const char* stbname, int32_t* pContLen) {
...
@@ -137,7 +146,7 @@ void* MndTestSma::BuildDropStbReq(const char* stbname, int32_t* pContLen) {
return
pReq
;
return
pReq
;
}
}
void
*
MndTestSma
::
BuildCreateSmaReq
(
const
char
*
smaname
,
const
char
*
stbname
,
int8_t
igExists
,
const
char
*
expr
,
void
*
MndTestSma
::
BuildCreate
T
SmaReq
(
const
char
*
smaname
,
const
char
*
stbname
,
int8_t
igExists
,
const
char
*
expr
,
const
char
*
tagsFilter
,
const
char
*
sql
,
const
char
*
ast
,
int32_t
*
pContLen
)
{
const
char
*
tagsFilter
,
const
char
*
sql
,
const
char
*
ast
,
int32_t
*
pContLen
)
{
SMCreateSmaReq
createReq
=
{
0
};
SMCreateSmaReq
createReq
=
{
0
};
strcpy
(
createReq
.
name
,
smaname
);
strcpy
(
createReq
.
name
,
smaname
);
...
@@ -166,7 +175,7 @@ void* MndTestSma::BuildCreateSmaReq(const char* smaname, const char* stbname, in
...
@@ -166,7 +175,7 @@ void* MndTestSma::BuildCreateSmaReq(const char* smaname, const char* stbname, in
return
pHead
;
return
pHead
;
}
}
void
*
MndTestSma
::
BuildDropSmaReq
(
const
char
*
smaname
,
int8_t
igNotExists
,
int32_t
*
pContLen
)
{
void
*
MndTestSma
::
BuildDrop
T
SmaReq
(
const
char
*
smaname
,
int8_t
igNotExists
,
int32_t
*
pContLen
)
{
SMDropSmaReq
dropsmaReq
=
{
0
};
SMDropSmaReq
dropsmaReq
=
{
0
};
dropsmaReq
.
igNotExists
=
igNotExists
;
dropsmaReq
.
igNotExists
=
igNotExists
;
strcpy
(
dropsmaReq
.
name
,
smaname
);
strcpy
(
dropsmaReq
.
name
,
smaname
);
...
@@ -180,6 +189,7 @@ void* MndTestSma::BuildDropSmaReq(const char* smaname, int8_t igNotExists, int32
...
@@ -180,6 +189,7 @@ void* MndTestSma::BuildDropSmaReq(const char* smaname, int8_t igNotExists, int32
}
}
TEST_F
(
MndTestSma
,
01
_Create_Show_Meta_Drop_Restart_Stb
)
{
TEST_F
(
MndTestSma
,
01
_Create_Show_Meta_Drop_Restart_Stb
)
{
#if 0
const char* dbname = "1.d1";
const char* dbname = "1.d1";
const char* stbname = "1.d1.stb";
const char* stbname = "1.d1.stb";
const char* smaname = "1.d1.sma";
const char* smaname = "1.d1.sma";
...
@@ -201,9 +211,9 @@ TEST_F(MndTestSma, 01_Create_Show_Meta_Drop_Restart_Stb) {
...
@@ -201,9 +211,9 @@ TEST_F(MndTestSma, 01_Create_Show_Meta_Drop_Restart_Stb) {
test.SendShowRetrieveReq();
test.SendShowRetrieveReq();
EXPECT_EQ(test.GetShowRows(), 1);
EXPECT_EQ(test.GetShowRows(), 1);
}
}
#if 0
{
{
pReq = BuildCreateSmaReq(smaname, stbname, 0, "expr", "tagsFilter", "sql", "ast", &contLen);
pReq = BuildCreate
T
SmaReq(smaname, stbname, 0, "expr", "tagsFilter", "sql", "ast", &contLen);
pRsp = test.SendReq(TDMT_MND_CREATE_SMA, pReq, contLen);
pRsp = test.SendReq(TDMT_MND_CREATE_SMA, pReq, contLen);
ASSERT_EQ(pRsp->code, 0);
ASSERT_EQ(pRsp->code, 0);
test.SendShowMetaReq(TSDB_MGMT_TABLE_INDEX, dbname);
test.SendShowMetaReq(TSDB_MGMT_TABLE_INDEX, dbname);
...
@@ -226,7 +236,7 @@ TEST_F(MndTestSma, 01_Create_Show_Meta_Drop_Restart_Stb) {
...
@@ -226,7 +236,7 @@ TEST_F(MndTestSma, 01_Create_Show_Meta_Drop_Restart_Stb) {
}
}
{
{
pReq = BuildDropSmaReq(smaname, 0, &contLen);
pReq = BuildDrop
T
SmaReq(smaname, 0, &contLen);
pRsp = test.SendReq(TDMT_MND_DROP_SMA, pReq, contLen);
pRsp = test.SendReq(TDMT_MND_DROP_SMA, pReq, contLen);
ASSERT_EQ(pRsp->code, 0);
ASSERT_EQ(pRsp->code, 0);
test.SendShowMetaReq(TSDB_MGMT_TABLE_INDEX, dbname);
test.SendShowMetaReq(TSDB_MGMT_TABLE_INDEX, dbname);
...
@@ -235,3 +245,50 @@ TEST_F(MndTestSma, 01_Create_Show_Meta_Drop_Restart_Stb) {
...
@@ -235,3 +245,50 @@ TEST_F(MndTestSma, 01_Create_Show_Meta_Drop_Restart_Stb) {
}
}
#endif
#endif
}
}
TEST_F
(
MndTestSma
,
02
_Create_Show_Meta_Drop_Restart_BSma
)
{
const
char
*
dbname
=
"1.d1"
;
const
char
*
stbname
=
"1.d1.bsmastb"
;
int32_t
contLen
=
0
;
void
*
pReq
;
SRpcMsg
*
pRsp
;
{
pReq
=
BuildCreateDbReq
(
dbname
,
&
contLen
);
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
{
pReq
=
BuildCreateBSmaStbReq
(
stbname
,
&
contLen
);
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_STB
,
dbname
);
test
.
SendShowRetrieveReq
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
// CheckBinary("bsmastb", TSDB_TABLE_NAME_LEN);
}
test
.
Restart
();
{
pReq
=
BuildCreateBSmaStbReq
(
stbname
,
&
contLen
);
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_STB_ALREADY_EXIST
);
}
{
pReq
=
BuildDropStbReq
(
stbname
,
&
contLen
);
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_STB
,
dbname
);
test
.
SendShowRetrieveReq
();
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
}
{
pReq
=
BuildDropStbReq
(
stbname
,
&
contLen
);
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_STB
,
pReq
,
contLen
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_STB_NOT_EXIST
);
}
}
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
3e455e37
...
@@ -1377,7 +1377,6 @@ static int doBinarySearchKey(char* pValue, int num, TSKEY key, int order) {
...
@@ -1377,7 +1377,6 @@ static int doBinarySearchKey(char* pValue, int num, TSKEY key, int order) {
}
}
static
int32_t
doCopyRowsFromFileBlock
(
STsdbReadHandle
*
pTsdbReadHandle
,
int32_t
capacity
,
int32_t
numOfRows
,
int32_t
start
,
int32_t
end
)
{
static
int32_t
doCopyRowsFromFileBlock
(
STsdbReadHandle
*
pTsdbReadHandle
,
int32_t
capacity
,
int32_t
numOfRows
,
int32_t
start
,
int32_t
end
)
{
char
*
pData
=
NULL
;
int32_t
step
=
ASCENDING_TRAVERSE
(
pTsdbReadHandle
->
order
)
?
1
:
-
1
;
int32_t
step
=
ASCENDING_TRAVERSE
(
pTsdbReadHandle
->
order
)
?
1
:
-
1
;
SDataCols
*
pCols
=
pTsdbReadHandle
->
rhelper
.
pDCols
[
0
];
SDataCols
*
pCols
=
pTsdbReadHandle
->
rhelper
.
pDCols
[
0
];
...
@@ -1454,14 +1453,12 @@ static int32_t doCopyRowsFromFileBlock(STsdbReadHandle* pTsdbReadHandle, int32_t
...
@@ -1454,14 +1453,12 @@ static int32_t doCopyRowsFromFileBlock(STsdbReadHandle* pTsdbReadHandle, int32_t
return
numOfRows
+
num
;
return
numOfRows
+
num
;
}
}
// TODO fix bug for reverse copy data
// TODO fix bug for reverse copy data problem
// TODO handle the null data
// Note: row1 always has high priority
// Note: row1 always has high priority
static
void
mergeTwoRowFromMem
(
STsdbReadHandle
*
pTsdbReadHandle
,
int32_t
capacity
,
int32_t
numOfRows
,
STSRow
*
row1
,
static
void
mergeTwoRowFromMem
(
STsdbReadHandle
*
pTsdbReadHandle
,
int32_t
capacity
,
int32_t
numOfRows
,
STSRow
*
row1
,
STSRow
*
row2
,
int32_t
numOfCols
,
uint64_t
uid
,
STSchema
*
pSchema1
,
STSchema
*
pSchema2
,
STSRow
*
row2
,
int32_t
numOfCols
,
uint64_t
uid
,
STSchema
*
pSchema1
,
STSchema
*
pSchema2
,
bool
forceSetNull
)
{
bool
forceSetNull
)
{
#if 1
#if 1
char
*
pData
=
NULL
;
STSchema
*
pSchema
;
STSchema
*
pSchema
;
STSRow
*
row
;
STSRow
*
row
;
int16_t
colId
;
int16_t
colId
;
...
@@ -1503,12 +1500,6 @@ static void mergeTwoRowFromMem(STsdbReadHandle* pTsdbReadHandle, int32_t capacit
...
@@ -1503,12 +1500,6 @@ static void mergeTwoRowFromMem(STsdbReadHandle* pTsdbReadHandle, int32_t capacit
while
(
i
<
numOfCols
&&
(
j
<
numOfColsOfRow1
||
k
<
numOfColsOfRow2
))
{
while
(
i
<
numOfCols
&&
(
j
<
numOfColsOfRow1
||
k
<
numOfColsOfRow2
))
{
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pTsdbReadHandle
->
pColumns
,
i
);
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pTsdbReadHandle
->
pColumns
,
i
);
if
(
ASCENDING_TRAVERSE
(
pTsdbReadHandle
->
order
))
{
pData
=
(
char
*
)
pColInfo
->
pData
+
numOfRows
*
pColInfo
->
info
.
bytes
;
}
else
{
pData
=
(
char
*
)
pColInfo
->
pData
+
(
capacity
-
numOfRows
-
1
)
*
pColInfo
->
info
.
bytes
;
}
int32_t
colIdOfRow1
;
int32_t
colIdOfRow1
;
if
(
j
>=
numOfColsOfRow1
)
{
if
(
j
>=
numOfColsOfRow1
)
{
colIdOfRow1
=
INT32_MAX
;
colIdOfRow1
=
INT32_MAX
;
...
@@ -1571,43 +1562,11 @@ static void mergeTwoRowFromMem(STsdbReadHandle* pTsdbReadHandle, int32_t capacit
...
@@ -1571,43 +1562,11 @@ static void mergeTwoRowFromMem(STsdbReadHandle* pTsdbReadHandle, int32_t capacit
if
(
colId
==
pColInfo
->
info
.
colId
)
{
if
(
colId
==
pColInfo
->
info
.
colId
)
{
if
(
tdValTypeIsNorm
(
sVal
.
valType
))
{
if
(
tdValTypeIsNorm
(
sVal
.
valType
))
{
switch
(
pColInfo
->
info
.
type
)
{
colDataAppend
(
pColInfo
,
numOfRows
,
sVal
.
val
,
false
);
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_NCHAR
:
memcpy
(
pData
,
sVal
.
val
,
varDataTLen
(
sVal
.
val
));
break
;
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_UTINYINT
:
*
(
uint8_t
*
)
pData
=
*
(
uint8_t
*
)
sVal
.
val
;
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_USMALLINT
:
*
(
uint16_t
*
)
pData
=
*
(
uint16_t
*
)
sVal
.
val
;
break
;
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_UINT
:
*
(
uint32_t
*
)
pData
=
*
(
uint32_t
*
)
sVal
.
val
;
break
;
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
*
(
uint64_t
*
)
pData
=
*
(
uint64_t
*
)
sVal
.
val
;
break
;
case
TSDB_DATA_TYPE_FLOAT
:
SET_FLOAT_PTR
(
pData
,
sVal
.
val
);
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
SET_DOUBLE_PTR
(
pData
,
sVal
.
val
);
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
*
(
TSKEY
*
)
pData
=
*
(
TSKEY
*
)
sVal
.
val
;
break
;
default:
memcpy
(
pData
,
sVal
.
val
,
pColInfo
->
info
.
bytes
);
}
}
else
if
(
forceSetNull
)
{
}
else
if
(
forceSetNull
)
{
colDataAppend
(
pColInfo
,
numOfRows
,
NULL
,
true
);
colDataAppend
(
pColInfo
,
numOfRows
,
NULL
,
true
);
}
}
i
++
;
i
++
;
if
(
row
==
row1
)
{
if
(
row
==
row1
)
{
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
3e455e37
...
@@ -76,11 +76,12 @@ typedef struct SResultRowCell {
...
@@ -76,11 +76,12 @@ typedef struct SResultRowCell {
* If the number of generated results is greater than this value,
* If the number of generated results is greater than this value,
* query query will be halt and return results to client immediate.
* query query will be halt and return results to client immediate.
*/
*/
typedef
struct
SRspResultInfo
{
typedef
struct
SResultInfo
{
// TODO refactor
int64_t
total
;
// total generated result size in rows
int64_t
totalRows
;
// total generated result size in rows
int64_t
totalBytes
;
// total results in bytes.
int32_t
capacity
;
// capacity of current result output buffer
int32_t
capacity
;
// capacity of current result output buffer
int32_t
threshold
;
// result size threshold in rows.
int32_t
threshold
;
// result size threshold in rows.
}
SR
spR
esultInfo
;
}
SResultInfo
;
typedef
struct
SColumnFilterElem
{
typedef
struct
SColumnFilterElem
{
int16_t
bytes
;
// column length
int16_t
bytes
;
// column length
...
@@ -160,8 +161,8 @@ typedef struct STaskCostInfo {
...
@@ -160,8 +161,8 @@ typedef struct STaskCostInfo {
typedef
struct
SOperatorCostInfo
{
typedef
struct
SOperatorCostInfo
{
uint64_t
openCost
;
uint64_t
openCost
;
uint64_t
execCost
;
uint64_t
execCost
;
uint64_t
totalRows
;
//
uint64_t totalRows;
uint64_t
totalBytes
;
//
uint64_t totalBytes;
}
SOperatorCostInfo
;
}
SOperatorCostInfo
;
typedef
struct
{
typedef
struct
{
...
@@ -301,7 +302,7 @@ typedef struct STaskRuntimeEnv {
...
@@ -301,7 +302,7 @@ typedef struct STaskRuntimeEnv {
int64_t
currentOffset
;
// dynamic offset value
int64_t
currentOffset
;
// dynamic offset value
STableQueryInfo
*
current
;
STableQueryInfo
*
current
;
SR
spR
esultInfo
resultInfo
;
SResultInfo
resultInfo
;
SHashObj
*
pTableRetrieveTsMap
;
SHashObj
*
pTableRetrieveTsMap
;
struct
SUdfInfo
*
pUdfInfo
;
struct
SUdfInfo
*
pUdfInfo
;
}
STaskRuntimeEnv
;
}
STaskRuntimeEnv
;
...
@@ -324,7 +325,7 @@ typedef struct SOperatorInfo {
...
@@ -324,7 +325,7 @@ typedef struct SOperatorInfo {
STaskRuntimeEnv
*
pRuntimeEnv
;
// todo remove it
STaskRuntimeEnv
*
pRuntimeEnv
;
// todo remove it
SExecTaskInfo
*
pTaskInfo
;
SExecTaskInfo
*
pTaskInfo
;
SOperatorCostInfo
cost
;
SOperatorCostInfo
cost
;
SResultInfo
resultInfo
;
struct
SOperatorInfo
**
pDownstream
;
// downstram pointer list
struct
SOperatorInfo
**
pDownstream
;
// downstram pointer list
int32_t
numOfDownstream
;
// number of downstream. The value is always ONE expect for join operator
int32_t
numOfDownstream
;
// number of downstream. The value is always ONE expect for join operator
__optr_fn_t
getNextFn
;
__optr_fn_t
getNextFn
;
...
@@ -539,6 +540,8 @@ typedef struct SFillOperatorInfo {
...
@@ -539,6 +540,8 @@ typedef struct SFillOperatorInfo {
void
**
p
;
void
**
p
;
SSDataBlock
*
existNewGroupBlock
;
SSDataBlock
*
existNewGroupBlock
;
bool
multigroupResult
;
bool
multigroupResult
;
SInterval
intervalInfo
;
int32_t
capacity
;
}
SFillOperatorInfo
;
}
SFillOperatorInfo
;
typedef
struct
SGroupKeys
{
typedef
struct
SGroupKeys
{
...
@@ -649,21 +652,20 @@ SOperatorInfo* createOrderOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
...
@@ -649,21 +652,20 @@ SOperatorInfo* createOrderOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
SOperatorInfo
*
createSortedMergeOperatorInfo
(
SOperatorInfo
**
downstream
,
int32_t
numOfDownstream
,
SExprInfo
*
pExprInfo
,
int32_t
num
,
SArray
*
pOrderVal
,
SArray
*
pGroupInfo
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createSortedMergeOperatorInfo
(
SOperatorInfo
**
downstream
,
int32_t
numOfDownstream
,
SExprInfo
*
pExprInfo
,
int32_t
num
,
SArray
*
pOrderVal
,
SArray
*
pGroupInfo
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createSysTableScanOperatorInfo
(
void
*
pSysTableReadHandle
,
SSDataBlock
*
pResBlock
,
const
SName
*
pName
,
SOperatorInfo
*
createSysTableScanOperatorInfo
(
void
*
pSysTableReadHandle
,
SSDataBlock
*
pResBlock
,
const
SName
*
pName
,
SNode
*
pCondition
,
SEpSet
epset
,
SArray
*
colList
,
SExecTaskInfo
*
pTaskInfo
);
SNode
*
pCondition
,
SEpSet
epset
,
SArray
*
colList
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createLimitOperatorInfo
(
SOperatorInfo
*
downstream
,
int32_t
numOfDownstream
,
SLimit
*
pLimit
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createLimitOperatorInfo
(
SOperatorInfo
*
downstream
,
SLimit
*
pLimit
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createIntervalOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResBlock
,
SInterval
*
pInterval
,
SOperatorInfo
*
createIntervalOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResBlock
,
SInterval
*
pInterval
,
const
STableGroupInfo
*
pTableGroupInfo
,
SExecTaskInfo
*
pTaskInfo
);
const
STableGroupInfo
*
pTableGroupInfo
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createSessionAggOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResBlock
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createSessionAggOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResBlock
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createGroupOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
SOperatorInfo
*
createGroupOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
SArray
*
pGroupColList
,
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
);
SArray
*
pGroupColList
,
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
);
SOperatorInfo
*
createFillOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfCols
,
SInterval
*
pInterval
,
SSDataBlock
*
pResBlock
,
int32_t
fillType
,
char
*
fillVal
,
bool
multigroupResult
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createTableSeqScanOperatorInfo
(
void
*
pTsdbReadHandle
,
STaskRuntimeEnv
*
pRuntimeEnv
);
SOperatorInfo
*
createTableSeqScanOperatorInfo
(
void
*
pTsdbReadHandle
,
STaskRuntimeEnv
*
pRuntimeEnv
);
SOperatorInfo
*
createAllTimeIntervalOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SOperatorInfo
*
createAllTimeIntervalOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createFillOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
bool
multigroupResult
);
SOperatorInfo
*
createMultiTableTimeIntervalOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SOperatorInfo
*
createMultiTableTimeIntervalOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createAllMultiTableTimeIntervalOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SOperatorInfo
*
createAllMultiTableTimeIntervalOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
3e455e37
...
@@ -248,7 +248,7 @@ static int32_t setGroupResultOutputBuf_rv(SOptrBasicInfo *binfo, int32_t numOfCo
...
@@ -248,7 +248,7 @@ static int32_t setGroupResultOutputBuf_rv(SOptrBasicInfo *binfo, int32_t numOfCo
static
void
initCtxOutputBuffer
(
SqlFunctionCtx
*
pCtx
,
int32_t
size
);
static
void
initCtxOutputBuffer
(
SqlFunctionCtx
*
pCtx
,
int32_t
size
);
static
void
getAlignQueryTimeWindow
(
SInterval
*
pInterval
,
int32_t
precision
,
int64_t
key
,
int64_t
keyFirst
,
int64_t
keyLast
,
STimeWindow
*
win
);
static
void
getAlignQueryTimeWindow
(
SInterval
*
pInterval
,
int32_t
precision
,
int64_t
key
,
int64_t
keyFirst
,
int64_t
keyLast
,
STimeWindow
*
win
);
static
void
setResultBufSize
(
STaskAttr
*
pQueryAttr
,
SR
spR
esultInfo
*
pResultInfo
);
static
void
setResultBufSize
(
STaskAttr
*
pQueryAttr
,
SResultInfo
*
pResultInfo
);
static
void
setCtxTagForJoin
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SqlFunctionCtx
*
pCtx
,
SExprInfo
*
pExprInfo
,
void
*
pTable
);
static
void
setCtxTagForJoin
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SqlFunctionCtx
*
pCtx
,
SExprInfo
*
pExprInfo
,
void
*
pTable
);
static
void
setParamForStableStddev
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
SExprInfo
*
pExpr
);
static
void
setParamForStableStddev
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
SExprInfo
*
pExpr
);
static
void
setParamForStableStddevByColData
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
SExprInfo
*
pExpr
,
char
*
val
,
int16_t
bytes
);
static
void
setParamForStableStddevByColData
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
SExprInfo
*
pExpr
,
char
*
val
,
int16_t
bytes
);
...
@@ -7083,52 +7083,54 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo *pOperator, bool* newgrou
...
@@ -7083,52 +7083,54 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo *pOperator, bool* newgrou
return
pInfo
->
binfo
.
pRes
;
return
pInfo
->
binfo
.
pRes
;
}
}
static
void
doHandleRemainBlockForNewGroupImpl
(
SFillOperatorInfo
*
pInfo
,
S
TaskRuntimeEnv
*
pRuntimeEnv
,
bool
*
newgroup
)
{
static
void
doHandleRemainBlockForNewGroupImpl
(
SFillOperatorInfo
*
pInfo
,
S
ResultInfo
*
pResultInfo
,
bool
*
newgroup
,
SExecTaskInfo
*
pTaskInfo
)
{
pInfo
->
totalInputRows
=
pInfo
->
existNewGroupBlock
->
info
.
rows
;
pInfo
->
totalInputRows
=
pInfo
->
existNewGroupBlock
->
info
.
rows
;
int64_t
ekey
=
Q_STATUS_EQUAL
(
pRuntimeEnv
->
status
,
TASK_COMPLETED
)
?
pRuntimeEnv
->
pQueryAttr
->
window
.
ekey
:
pInfo
->
existNewGroupBlock
->
info
.
window
.
ekey
;
// int64_t ekey = Q_STATUS_EQUAL(pRuntimeEnv->status, TASK_COMPLETED)? pTaskInfo->window.ekey:pInfo->existNewGroupBlock->info.window.ekey;
taosResetFillInfo
(
pInfo
->
pFillInfo
,
getFillInfoStart
(
pInfo
->
pFillInfo
));
taosResetFillInfo
(
pInfo
->
pFillInfo
,
getFillInfoStart
(
pInfo
->
pFillInfo
));
taosFillSetStartInfo
(
pInfo
->
pFillInfo
,
pInfo
->
existNewGroupBlock
->
info
.
rows
,
ekey
);
//
taosFillSetStartInfo(pInfo->pFillInfo, pInfo->existNewGroupBlock->info.rows, ekey);
taosFillSetInputDataBlock
(
pInfo
->
pFillInfo
,
pInfo
->
existNewGroupBlock
);
taosFillSetInputDataBlock
(
pInfo
->
pFillInfo
,
pInfo
->
existNewGroupBlock
);
doFillTimeIntervalGapsInResults
(
pInfo
->
pFillInfo
,
pInfo
->
pRes
,
pR
untimeEnv
->
resultInfo
.
capacity
,
pInfo
->
p
);
doFillTimeIntervalGapsInResults
(
pInfo
->
pFillInfo
,
pInfo
->
pRes
,
pR
esultInfo
->
capacity
,
pInfo
->
p
);
pInfo
->
existNewGroupBlock
=
NULL
;
pInfo
->
existNewGroupBlock
=
NULL
;
*
newgroup
=
true
;
*
newgroup
=
true
;
}
}
static
void
doHandleRemainBlockFromNewGroup
(
SFillOperatorInfo
*
pInfo
,
S
TaskRuntimeEnv
*
pRuntimeEnv
,
bool
*
newgroup
)
{
static
void
doHandleRemainBlockFromNewGroup
(
SFillOperatorInfo
*
pInfo
,
S
ResultInfo
*
pResultInfo
,
bool
*
newgroup
)
{
if
(
taosFillHasMoreResults
(
pInfo
->
pFillInfo
))
{
if
(
taosFillHasMoreResults
(
pInfo
->
pFillInfo
))
{
*
newgroup
=
false
;
*
newgroup
=
false
;
doFillTimeIntervalGapsInResults
(
pInfo
->
pFillInfo
,
pInfo
->
pRes
,
(
int32_t
)
pR
untimeEnv
->
resultInfo
.
capacity
,
pInfo
->
p
);
doFillTimeIntervalGapsInResults
(
pInfo
->
pFillInfo
,
pInfo
->
pRes
,
(
int32_t
)
pR
esultInfo
->
capacity
,
pInfo
->
p
);
if
(
pInfo
->
pRes
->
info
.
rows
>
pR
untimeEnv
->
resultInfo
.
threshold
||
(
!
pInfo
->
multigroupResult
))
{
if
(
pInfo
->
pRes
->
info
.
rows
>
pR
esultInfo
->
threshold
||
(
!
pInfo
->
multigroupResult
))
{
return
;
return
;
}
}
}
}
// handle the cached new group data block
// handle the cached new group data block
if
(
pInfo
->
existNewGroupBlock
)
{
if
(
pInfo
->
existNewGroupBlock
)
{
doHandleRemainBlockForNewGroupImpl
(
pInfo
,
pRuntimeEnv
,
newgroup
);
// doHandleRemainBlockForNewGroupImpl(pInfo, pResultInfo
, newgroup);
}
}
}
}
static
SSDataBlock
*
doFill
(
SOperatorInfo
*
pOperator
,
bool
*
newgroup
)
{
static
SSDataBlock
*
doFill
(
SOperatorInfo
*
pOperator
,
bool
*
newgroup
)
{
SFillOperatorInfo
*
pInfo
=
pOperator
->
info
;
SFillOperatorInfo
*
pInfo
=
pOperator
->
info
;
pInfo
->
pRes
->
info
.
rows
=
0
;
SResultInfo
*
pResultInfo
=
&
pOperator
->
resultInfo
;
blockDataCleanup
(
pInfo
->
pRes
);
if
(
pOperator
->
status
==
OP_EXEC_DONE
)
{
if
(
pOperator
->
status
==
OP_EXEC_DONE
)
{
return
NULL
;
return
NULL
;
}
}
STaskRuntimeEnv
*
pRuntimeEnv
=
pOperator
->
pRuntimeEnv
;
doHandleRemainBlockFromNewGroup
(
pInfo
,
pResultInfo
,
newgroup
);
doHandleRemainBlockFromNewGroup
(
pInfo
,
pRuntimeEnv
,
newgroup
);
if
(
pInfo
->
pRes
->
info
.
rows
>
pResultInfo
->
threshold
||
(
!
pInfo
->
multigroupResult
&&
pInfo
->
pRes
->
info
.
rows
>
0
))
{
if
(
pInfo
->
pRes
->
info
.
rows
>
pRuntimeEnv
->
resultInfo
.
threshold
||
(
!
pInfo
->
multigroupResult
&&
pInfo
->
pRes
->
info
.
rows
>
0
))
{
return
pInfo
->
pRes
;
return
pInfo
->
pRes
;
}
}
SOperatorInfo
*
pDownstream
=
pOperator
->
pDownstream
[
0
];
while
(
1
)
{
while
(
1
)
{
publishOperatorProfEvent
(
p
Operator
->
pDownstream
[
0
]
,
QUERY_PROF_BEFORE_OPERATOR_EXEC
);
publishOperatorProfEvent
(
p
Downstream
,
QUERY_PROF_BEFORE_OPERATOR_EXEC
);
SSDataBlock
*
pBlock
=
p
Operator
->
pDownstream
[
0
]
->
getNextFn
(
pOperator
->
pDownstream
[
0
]
,
newgroup
);
SSDataBlock
*
pBlock
=
p
Downstream
->
getNextFn
(
pDownstream
,
newgroup
);
publishOperatorProfEvent
(
p
Operator
->
pDownstream
[
0
]
,
QUERY_PROF_AFTER_OPERATOR_EXEC
);
publishOperatorProfEvent
(
p
Downstream
,
QUERY_PROF_AFTER_OPERATOR_EXEC
);
if
(
*
newgroup
)
{
if
(
*
newgroup
)
{
assert
(
pBlock
!=
NULL
);
assert
(
pBlock
!=
NULL
);
...
@@ -7140,7 +7142,7 @@ static SSDataBlock* doFill(SOperatorInfo *pOperator, bool* newgroup) {
...
@@ -7140,7 +7142,7 @@ static SSDataBlock* doFill(SOperatorInfo *pOperator, bool* newgroup) {
// Fill the previous group data block, before handle the data block of new group.
// Fill the previous group data block, before handle the data block of new group.
// Close the fill operation for previous group data block
// Close the fill operation for previous group data block
taosFillSetStartInfo
(
pInfo
->
pFillInfo
,
0
,
pRuntimeEnv
->
pQueryAttr
->
window
.
ekey
);
//
taosFillSetStartInfo(pInfo->pFillInfo, 0, pRuntimeEnv->pQueryAttr->window.ekey);
}
else
{
}
else
{
if
(
pBlock
==
NULL
)
{
if
(
pBlock
==
NULL
)
{
if
(
pInfo
->
totalInputRows
==
0
)
{
if
(
pInfo
->
totalInputRows
==
0
)
{
...
@@ -7148,7 +7150,7 @@ static SSDataBlock* doFill(SOperatorInfo *pOperator, bool* newgroup) {
...
@@ -7148,7 +7150,7 @@ static SSDataBlock* doFill(SOperatorInfo *pOperator, bool* newgroup) {
return
NULL
;
return
NULL
;
}
}
taosFillSetStartInfo
(
pInfo
->
pFillInfo
,
0
,
pRuntimeEnv
->
pQueryAttr
->
window
.
ekey
);
//
taosFillSetStartInfo(pInfo->pFillInfo, 0, pRuntimeEnv->pQueryAttr->window.ekey);
}
else
{
}
else
{
pInfo
->
totalInputRows
+=
pBlock
->
info
.
rows
;
pInfo
->
totalInputRows
+=
pBlock
->
info
.
rows
;
taosFillSetStartInfo
(
pInfo
->
pFillInfo
,
pBlock
->
info
.
rows
,
pBlock
->
info
.
window
.
ekey
);
taosFillSetStartInfo
(
pInfo
->
pFillInfo
,
pBlock
->
info
.
rows
,
pBlock
->
info
.
window
.
ekey
);
...
@@ -7156,25 +7158,25 @@ static SSDataBlock* doFill(SOperatorInfo *pOperator, bool* newgroup) {
...
@@ -7156,25 +7158,25 @@ static SSDataBlock* doFill(SOperatorInfo *pOperator, bool* newgroup) {
}
}
}
}
doFillTimeIntervalGapsInResults
(
pInfo
->
pFillInfo
,
pInfo
->
pRes
,
p
RuntimeEnv
->
resultInfo
.
capacity
,
pInfo
->
p
);
doFillTimeIntervalGapsInResults
(
pInfo
->
pFillInfo
,
pInfo
->
pRes
,
p
Info
->
capacity
,
pInfo
->
p
);
// current group has no more result to return
// current group has no more result to return
if
(
pInfo
->
pRes
->
info
.
rows
>
0
)
{
if
(
pInfo
->
pRes
->
info
.
rows
>
0
)
{
// 1. The result in current group not reach the threshold of output result, continue
// 1. The result in current group not reach the threshold of output result, continue
// 2. If multiple group results existing in one SSDataBlock is not allowed, return immediately
// 2. If multiple group results existing in one SSDataBlock is not allowed, return immediately
if
(
pInfo
->
pRes
->
info
.
rows
>
pR
untimeEnv
->
resultInfo
.
threshold
||
pBlock
==
NULL
||
(
!
pInfo
->
multigroupResult
))
{
if
(
pInfo
->
pRes
->
info
.
rows
>
pR
esultInfo
->
threshold
||
pBlock
==
NULL
||
(
!
pInfo
->
multigroupResult
))
{
return
pInfo
->
pRes
;
return
pInfo
->
pRes
;
}
}
doHandleRemainBlockFromNewGroup
(
pInfo
,
pRuntimeEnv
,
newgroup
);
//
doHandleRemainBlockFromNewGroup(pInfo, pRuntimeEnv, newgroup);
if
(
pInfo
->
pRes
->
info
.
rows
>
p
RuntimeEnv
->
resultInfo
.
threshold
||
pBlock
==
NULL
)
{
if
(
pInfo
->
pRes
->
info
.
rows
>
p
Operator
->
resultInfo
.
threshold
||
pBlock
==
NULL
)
{
return
pInfo
->
pRes
;
return
pInfo
->
pRes
;
}
}
}
else
if
(
pInfo
->
existNewGroupBlock
)
{
// try next group
}
else
if
(
pInfo
->
existNewGroupBlock
)
{
// try next group
assert
(
pBlock
!=
NULL
);
assert
(
pBlock
!=
NULL
);
doHandleRemainBlockForNewGroupImpl
(
pInfo
,
pRuntimeEnv
,
newgroup
);
//
doHandleRemainBlockForNewGroupImpl(pInfo, pRuntimeEnv, newgroup);
if
(
pInfo
->
pRes
->
info
.
rows
>
pR
untimeEnv
->
resultInfo
.
threshold
)
{
if
(
pInfo
->
pRes
->
info
.
rows
>
pR
esultInfo
->
threshold
)
{
return
pInfo
->
pRes
;
return
pInfo
->
pRes
;
}
}
}
else
{
}
else
{
...
@@ -7537,8 +7539,7 @@ SColumnInfo* extractColumnFilterInfo(SExprInfo* pExpr, int32_t numOfOutput, int3
...
@@ -7537,8 +7539,7 @@ SColumnInfo* extractColumnFilterInfo(SExprInfo* pExpr, int32_t numOfOutput, int3
return
0
;
return
0
;
}
}
SOperatorInfo
*
createLimitOperatorInfo
(
SOperatorInfo
*
downstream
,
int32_t
numOfDownstream
,
SLimit
*
pLimit
,
SExecTaskInfo
*
pTaskInfo
)
{
SOperatorInfo
*
createLimitOperatorInfo
(
SOperatorInfo
*
downstream
,
SLimit
*
pLimit
,
SExecTaskInfo
*
pTaskInfo
)
{
ASSERT
(
numOfDownstream
==
1
);
SLimitOperatorInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SLimitOperatorInfo
));
SLimitOperatorInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SLimitOperatorInfo
));
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
if
(
pInfo
==
NULL
||
pOperator
==
NULL
)
{
if
(
pInfo
==
NULL
||
pOperator
==
NULL
)
{
...
@@ -7622,7 +7623,7 @@ SOperatorInfo* createAllTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, S
...
@@ -7622,7 +7623,7 @@ SOperatorInfo* createAllTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, S
STableIntervalOperatorInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
STableIntervalOperatorInfo
));
STableIntervalOperatorInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
STableIntervalOperatorInfo
));
pInfo
->
binfo
.
pCtx
=
createSqlFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pInfo
->
binfo
.
rowCellInfoOffset
);
pInfo
->
binfo
.
pCtx
=
createSqlFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pInfo
->
binfo
.
rowCellInfoOffset
);
pInfo
->
binfo
.
pRes
=
createOutputBuf
(
pExpr
,
numOfOutput
,
pRuntimeEnv
->
resultInfo
.
capacity
);
// pInfo->binfo.pRes = createOutputBuf(pExpr, numOfOutput, pResultInfo->
capacity);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
);
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
...
@@ -7647,7 +7648,7 @@ SOperatorInfo* createStatewindowOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOper
...
@@ -7647,7 +7648,7 @@ SOperatorInfo* createStatewindowOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOper
pInfo
->
colIndex
=
-
1
;
pInfo
->
colIndex
=
-
1
;
pInfo
->
reptScan
=
false
;
pInfo
->
reptScan
=
false
;
pInfo
->
binfo
.
pCtx
=
createSqlFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pInfo
->
binfo
.
rowCellInfoOffset
);
pInfo
->
binfo
.
pCtx
=
createSqlFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pInfo
->
binfo
.
rowCellInfoOffset
);
pInfo
->
binfo
.
pRes
=
createOutputBuf
(
pExpr
,
numOfOutput
,
pRuntimeEnv
->
resultInfo
.
capacity
);
// pInfo->binfo.pRes = createOutputBuf(pExpr, numOfOutput, pResultInfo->
capacity);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
);
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
...
@@ -7712,7 +7713,7 @@ SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntim
...
@@ -7712,7 +7713,7 @@ SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntim
STableIntervalOperatorInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
STableIntervalOperatorInfo
));
STableIntervalOperatorInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
STableIntervalOperatorInfo
));
pInfo
->
binfo
.
pCtx
=
createSqlFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pInfo
->
binfo
.
rowCellInfoOffset
);
pInfo
->
binfo
.
pCtx
=
createSqlFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pInfo
->
binfo
.
rowCellInfoOffset
);
pInfo
->
binfo
.
pRes
=
createOutputBuf
(
pExpr
,
numOfOutput
,
pRuntimeEnv
->
resultInfo
.
capacity
);
// pInfo->binfo.pRes = createOutputBuf(pExpr, numOfOutput, pResultInfo->
capacity);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
);
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
...
@@ -7736,7 +7737,7 @@ SOperatorInfo* createAllMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRun
...
@@ -7736,7 +7737,7 @@ SOperatorInfo* createAllMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRun
STableIntervalOperatorInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
STableIntervalOperatorInfo
));
STableIntervalOperatorInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
STableIntervalOperatorInfo
));
pInfo
->
binfo
.
pCtx
=
createSqlFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pInfo
->
binfo
.
rowCellInfoOffset
);
pInfo
->
binfo
.
pCtx
=
createSqlFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pInfo
->
binfo
.
rowCellInfoOffset
);
pInfo
->
binfo
.
pRes
=
createOutputBuf
(
pExpr
,
numOfOutput
,
pRuntimeEnv
->
resultInfo
.
capacity
);
// pInfo->binfo.pRes = createOutputBuf(pExpr, numOfOutput, pResultInfo->
capacity);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
);
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
...
@@ -7827,52 +7828,76 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
...
@@ -7827,52 +7828,76 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
return
NULL
;
return
NULL
;
}
}
SOperatorInfo
*
createFillOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
bool
multigroupResult
)
{
static
int32_t
initFillInfo
(
SFillOperatorInfo
*
pInfo
,
SExprInfo
*
pExpr
,
int32_t
numOfCols
,
int64_t
*
fillVal
,
SFillOperatorInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SFillOperatorInfo
));
STimeWindow
win
,
int32_t
capacity
,
const
char
*
id
,
SInterval
*
pInterval
,
int32_t
fillType
)
{
pInfo
->
pRes
=
createOutputBuf
(
pExpr
,
numOfOutput
,
pRuntimeEnv
->
resultInfo
.
capacity
);
struct
SFillColInfo
*
pColInfo
=
createFillColInfo
(
pExpr
,
numOfCols
,
(
int64_t
*
)
fillVal
);
pInfo
->
multigroupResult
=
multigroupResult
;
{
TSKEY
sk
=
TMIN
(
win
.
skey
,
win
.
ekey
);
STaskAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
TSKEY
ek
=
TMAX
(
win
.
skey
,
win
.
ekey
);
struct
SFillColInfo
*
pColInfo
=
createFillColInfo
(
pExpr
,
numOfOutput
,
pQueryAttr
->
fillVal
);
STimeWindow
w
=
TSWINDOW_INITIALIZER
;
TSKEY
sk
=
TMIN
(
pQueryAttr
->
window
.
skey
,
pQueryAttr
->
window
.
ekey
);
// TODO set correct time precision
TSKEY
ek
=
TMAX
(
pQueryAttr
->
window
.
skey
,
pQueryAttr
->
window
.
ekey
)
;
STimeWindow
w
=
TSWINDOW_INITIALIZER
;
// getAlignQueryTimeWindow(pQueryAttr, pQueryAttr->window
.skey, sk, ek, &w);
getAlignQueryTimeWindow
(
pInterval
,
TSDB_TIME_PRECISION_MILLI
,
win
.
skey
,
sk
,
ek
,
&
w
);
int32_t
order
=
TSDB_ORDER_ASC
;
pInfo
->
pFillInfo
=
pInfo
->
pFillInfo
=
taosCreateFillInfo
(
pQueryAttr
->
order
.
order
,
w
.
skey
,
0
,
(
int32_t
)
pRuntimeEnv
->
resultInfo
.
capacity
,
numOfOutput
,
taosCreateFillInfo
(
order
,
w
.
skey
,
0
,
capacity
,
numOfCols
,
pInterval
->
sliding
,
pQueryAttr
->
interval
.
sliding
,
pQueryAttr
->
interval
.
slidingUnit
,
pInterval
->
slidingUnit
,
(
int8_t
)
pInterval
->
precision
,
fillType
,
pColInfo
,
id
);
(
int8_t
)
pQueryAttr
->
precision
,
pQueryAttr
->
fillType
,
pColInfo
,
pRuntimeEnv
->
qinfo
);
pInfo
->
p
=
calloc
(
numOfOutput
,
POINTER_BYTES
);
pInfo
->
p
=
calloc
(
numOfCols
,
POINTER_BYTES
);
if
(
pInfo
->
pFillInfo
==
NULL
||
pInfo
->
p
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
else
{
return
TSDB_CODE_SUCCESS
;
}
}
}
SOperatorInfo
*
createFillOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfCols
,
SInterval
*
pInterval
,
SSDataBlock
*
pResBlock
,
int32_t
fillType
,
char
*
fillVal
,
bool
multigroupResult
,
SExecTaskInfo
*
pTaskInfo
)
{
SFillOperatorInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SFillOperatorInfo
));
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
pInfo
->
pRes
=
pResBlock
;
pInfo
->
multigroupResult
=
multigroupResult
;
pInfo
->
intervalInfo
=
*
pInterval
;
SResultInfo
*
pResultInfo
=
&
pOperator
->
resultInfo
;
// int32_t code = initFillInfo(pInfo, pExpr, numOfCols, fillVal, , pResultInfo->capacity, pTaskInfo->id.str, pInterval, fillType);
// if (code != TSDB_CODE_SUCCESS) {
// goto _error;
// }
pOperator
->
name
=
"FillOperator"
;
pOperator
->
name
=
"FillOperator"
;
pOperator
->
blockingOptr
=
false
;
pOperator
->
blockingOptr
=
false
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
status
=
OP_NOT_OPENED
;
// pOperator->operatorType = OP_Fill;
// pOperator->operatorType = OP_Fill;
pOperator
->
pExpr
=
pExpr
;
pOperator
->
pExpr
=
pExpr
;
pOperator
->
numOfOutput
=
numOf
Output
;
pOperator
->
numOfOutput
=
numOf
Cols
;
pOperator
->
info
=
pInfo
;
pOperator
->
info
=
pInfo
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
_openFn
=
operatorDummyOpenFn
;
pOperator
->
getNextFn
=
doFill
;
pOperator
->
getNextFn
=
doFill
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
closeFn
=
destroySFillOperatorInfo
;
pOperator
->
closeFn
=
destroySFillOperatorInfo
;
int32_t
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
int32_t
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
return
pOperator
;
return
pOperator
;
_error:
tfree
(
pOperator
);
tfree
(
pInfo
);
return
NULL
;
}
}
SOperatorInfo
*
createSLimitOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
void
*
pMerger
,
bool
multigroupResult
)
{
SOperatorInfo
*
createSLimitOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
void
*
pMerger
,
bool
multigroupResult
)
{
SSLimitOperatorInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SSLimitOperatorInfo
));
SSLimitOperatorInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SSLimitOperatorInfo
));
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
// pInfo->orderColumnList = getResultGroupCheckColumns(pQueryAttr);
// pInfo->orderColumnList = getResultGroupCheckColumns(pQueryAttr);
// pInfo->slimit = pQueryAttr->slimit;
// pInfo->slimit = pQueryAttr->slimit;
// pInfo->limit = pQueryAttr->limit;
// pInfo->limit = pQueryAttr->limit;
// pInfo->capacity = pR
untimeEnv->resultInfo.
capacity;
// pInfo->capacity = pR
esultInfo->
capacity;
// pInfo->threshold = (int64_t)(pInfo->capacity * 0.8);
// pInfo->threshold = (int64_t)(pInfo->capacity * 0.8);
// pInfo->currentOffset = pQueryAttr->limit.offset;
// pInfo->currentOffset = pQueryAttr->limit.offset;
// pInfo->currentGroupOffset = pQueryAttr->slimit.offset;
// pInfo->currentGroupOffset = pQueryAttr->slimit.offset;
...
@@ -7895,9 +7920,8 @@ SOperatorInfo* createSLimitOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorI
...
@@ -7895,9 +7920,8 @@ SOperatorInfo* createSLimitOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorI
offset
+=
pExpr
[
index
->
colIndex
].
base
.
resSchema
.
bytes
;
offset
+=
pExpr
[
index
->
colIndex
].
base
.
resSchema
.
bytes
;
}
}
pInfo
->
pRes
=
createOutputBuf
(
pExpr
,
numOfOutput
,
p
RuntimeEnv
->
resultInfo
.
capacity
);
pInfo
->
pRes
=
createOutputBuf
(
pExpr
,
numOfOutput
,
p
Operator
->
resultInfo
.
capacity
);
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
pOperator
->
name
=
"SLimitOperator"
;
pOperator
->
name
=
"SLimitOperator"
;
// pOperator->operatorType = OP_SLimit;
// pOperator->operatorType = OP_SLimit;
...
@@ -7920,7 +7944,7 @@ static SSDataBlock* doTagScan(SOperatorInfo *pOperator, bool* newgroup) {
...
@@ -7920,7 +7944,7 @@ static SSDataBlock* doTagScan(SOperatorInfo *pOperator, bool* newgroup) {
}
}
STaskRuntimeEnv* pRuntimeEnv = pOperator->pRuntimeEnv;
STaskRuntimeEnv* pRuntimeEnv = pOperator->pRuntimeEnv;
int32_t maxNumOfTables = (int32_t)pR
untimeEnv->resultInfo.
capacity;
int32_t maxNumOfTables = (int32_t)pR
esultInfo->
capacity;
STagScanInfo *pInfo = pOperator->info;
STagScanInfo *pInfo = pOperator->info;
SSDataBlock *pRes = pInfo->pRes;
SSDataBlock *pRes = pInfo->pRes;
...
@@ -8046,7 +8070,7 @@ static SSDataBlock* doTagScan(SOperatorInfo *pOperator, bool* newgroup) {
...
@@ -8046,7 +8070,7 @@ static SSDataBlock* doTagScan(SOperatorInfo *pOperator, bool* newgroup) {
SOperatorInfo
*
createTagScanOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
)
{
SOperatorInfo
*
createTagScanOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
)
{
STagScanInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
STagScanInfo
));
STagScanInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
STagScanInfo
));
pInfo
->
pRes
=
createOutputBuf
(
pExpr
,
numOfOutput
,
pRuntimeEnv
->
resultInfo
.
capacity
);
// pInfo->pRes = createOutputBuf(pExpr, numOfOutput, pResultInfo->
capacity);
size_t
numOfGroup
=
GET_NUM_OF_TABLEGROUP
(
pRuntimeEnv
);
size_t
numOfGroup
=
GET_NUM_OF_TABLEGROUP
(
pRuntimeEnv
);
assert
(
numOfGroup
==
0
||
numOfGroup
==
1
);
assert
(
numOfGroup
==
0
||
numOfGroup
==
1
);
...
@@ -8372,7 +8396,7 @@ static SExecTaskInfo* createExecTaskInfo(uint64_t queryId, uint64_t taskId) {
...
@@ -8372,7 +8396,7 @@ static SExecTaskInfo* createExecTaskInfo(uint64_t queryId, uint64_t taskId) {
return
pTaskInfo
;
return
pTaskInfo
;
}
}
static
tsdbReaderT
doCreateDataReader
(
STableScanPhysiNode
*
pTableScanNode
,
SReadHandle
*
pHandle
,
uint64_t
queryId
,
uint64_t
taskId
);
static
tsdbReaderT
doCreateDataReader
(
STableScanPhysiNode
*
pTableScanNode
,
SReadHandle
*
pHandle
,
STableGroupInfo
*
pTableGroupInfo
,
uint64_t
queryId
,
uint64_t
taskId
);
static
int32_t
doCreateTableGroup
(
void
*
metaHandle
,
int32_t
tableType
,
uint64_t
tableUid
,
STableGroupInfo
*
pGroupInfo
,
uint64_t
queryId
,
uint64_t
taskId
);
static
int32_t
doCreateTableGroup
(
void
*
metaHandle
,
int32_t
tableType
,
uint64_t
tableUid
,
STableGroupInfo
*
pGroupInfo
,
uint64_t
queryId
,
uint64_t
taskId
);
static
SArray
*
extractTableIdList
(
const
STableGroupInfo
*
pTableGroupInfo
);
static
SArray
*
extractTableIdList
(
const
STableGroupInfo
*
pTableGroupInfo
);
...
@@ -8380,20 +8404,13 @@ static SArray* extractScanColumnId(SNodeList* pNodeList);
...
@@ -8380,20 +8404,13 @@ static SArray* extractScanColumnId(SNodeList* pNodeList);
static
SArray
*
extractColumnInfo
(
SNodeList
*
pNodeList
);
static
SArray
*
extractColumnInfo
(
SNodeList
*
pNodeList
);
SOperatorInfo
*
doCreateOperatorTreeNode
(
SPhysiNode
*
pPhyNode
,
SExecTaskInfo
*
pTaskInfo
,
SReadHandle
*
pHandle
,
uint64_t
queryId
,
uint64_t
taskId
,
STableGroupInfo
*
pTableGroupInfo
)
{
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
(
pPhyNode
->
pChildren
==
NULL
||
LIST_LENGTH
(
pPhyNode
->
pChildren
)
==
0
)
{
if
(
pPhyNode
->
pChildren
==
NULL
||
LIST_LENGTH
(
pPhyNode
->
pChildren
)
==
0
)
{
if
(
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
==
nodeType
(
pPhyNode
))
{
if
(
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
==
nodeType
(
pPhyNode
))
{
SScanPhysiNode
*
pScanPhyNode
=
(
SScanPhysiNode
*
)
pPhyNode
;
SScanPhysiNode
*
pScanPhyNode
=
(
SScanPhysiNode
*
)
pPhyNode
;
size_t
numOfCols
=
LIST_LENGTH
(
pScanPhyNode
->
pScanCols
);
size_t
numOfCols
=
LIST_LENGTH
(
pScanPhyNode
->
pScanCols
);
tsdbReaderT
pDataReader
=
doCreateDataReader
((
STableScanPhysiNode
*
)
pPhyNode
,
pHandle
,
(
uint64_t
)
queryId
,
taskId
);
tsdbReaderT
pDataReader
=
doCreateDataReader
((
STableScanPhysiNode
*
)
pPhyNode
,
pHandle
,
pTableGroupInfo
,
(
uint64_t
)
queryId
,
taskId
);
return
createTableScanOperatorInfo
(
pDataReader
,
pScanPhyNode
->
order
,
numOfCols
,
pScanPhyNode
->
count
,
pScanPhyNode
->
reverse
,
pTaskInfo
);
int32_t
code
=
doCreateTableGroup
(
pHandle
->
meta
,
pScanPhyNode
->
tableType
,
pScanPhyNode
->
uid
,
pTableGroupInfo
,
queryId
,
taskId
);
return
createTableScanOperatorInfo
(
pDataReader
,
pScanPhyNode
->
order
,
numOfCols
,
pScanPhyNode
->
count
,
pScanPhyNode
->
reverse
,
pTaskInfo
);
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
==
nodeType
(
pPhyNode
))
{
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
==
nodeType
(
pPhyNode
))
{
SExchangePhysiNode
*
pExchange
=
(
SExchangePhysiNode
*
)
pPhyNode
;
SExchangePhysiNode
*
pExchange
=
(
SExchangePhysiNode
*
)
pPhyNode
;
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pExchange
->
node
.
pOutputDataBlockDesc
);
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pExchange
->
node
.
pOutputDataBlockDesc
);
...
@@ -8401,10 +8418,8 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTa
...
@@ -8401,10 +8418,8 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTa
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
==
nodeType
(
pPhyNode
))
{
}
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
,
pTableGroupInfo
,
queryId
,
taskId
);
SArray
*
tableIdList
=
extractTableIdList
(
pTableGroupInfo
);
int32_t
code
=
doCreateTableGroup
(
pHandle
->
meta
,
pScanPhyNode
->
tableType
,
pScanPhyNode
->
uid
,
&
groupInfo
,
queryId
,
taskId
);
SArray
*
tableIdList
=
extractTableIdList
(
&
groupInfo
);
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pScanPhyNode
->
node
.
pOutputDataBlockDesc
);
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pScanPhyNode
->
node
.
pOutputDataBlockDesc
);
SArray
*
colList
=
extractScanColumnId
(
pScanPhyNode
->
pScanCols
);
SArray
*
colList
=
extractScanColumnId
(
pScanPhyNode
->
pScanCols
);
...
@@ -8472,7 +8487,7 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTa
...
@@ -8472,7 +8487,7 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTa
SIntervalPhysiNode
*
pIntervalPhyNode
=
(
SIntervalPhysiNode
*
)
pPhyNode
;
SIntervalPhysiNode
*
pIntervalPhyNode
=
(
SIntervalPhysiNode
*
)
pPhyNode
;
int32_t
num
=
0
;
int32_t
num
=
0
;
SExprInfo
*
pExprInfo
=
createExprInfo
(
pIntervalPhyNode
->
pFuncs
,
NULL
,
&
num
);
SExprInfo
*
pExprInfo
=
createExprInfo
(
pIntervalPhyNode
->
window
.
pFuncs
,
NULL
,
&
num
);
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pPhyNode
->
pOutputDataBlockDesc
);
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pPhyNode
->
pOutputDataBlockDesc
);
SInterval
interval
=
{.
interval
=
pIntervalPhyNode
->
interval
,
.
sliding
=
pIntervalPhyNode
->
sliding
,
SInterval
interval
=
{.
interval
=
pIntervalPhyNode
->
interval
,
.
sliding
=
pIntervalPhyNode
->
sliding
,
...
@@ -8597,22 +8612,20 @@ SArray* extractTableIdList(const STableGroupInfo* pTableGroupInfo) {
...
@@ -8597,22 +8612,20 @@ SArray* extractTableIdList(const STableGroupInfo* pTableGroupInfo) {
return
tableIdList
;
return
tableIdList
;
}
}
tsdbReaderT
doCreateDataReader
(
STableScanPhysiNode
*
pTableScanNode
,
SReadHandle
*
pHandle
,
uint64_t
queryId
,
uint64_t
taskId
)
{
tsdbReaderT
doCreateDataReader
(
STableScanPhysiNode
*
pTableScanNode
,
SReadHandle
*
pHandle
,
STableGroupInfo
*
pTableGroupInfo
,
uint64_t
queryId
,
uint64_t
taskId
)
{
STableGroupInfo
groupInfo
=
{
0
};
uint64_t
uid
=
pTableScanNode
->
scan
.
uid
;
uint64_t
uid
=
pTableScanNode
->
scan
.
uid
;
int32_t
code
=
doCreateTableGroup
(
pHandle
->
meta
,
pTableScanNode
->
scan
.
tableType
,
uid
,
&
g
roupInfo
,
queryId
,
taskId
);
int32_t
code
=
doCreateTableGroup
(
pHandle
->
meta
,
pTableScanNode
->
scan
.
tableType
,
uid
,
pTableG
roupInfo
,
queryId
,
taskId
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
goto
_error
;
}
}
if
(
groupInfo
.
numOfTables
==
0
)
{
if
(
pTableGroupInfo
->
numOfTables
==
0
)
{
code
=
0
;
code
=
0
;
qDebug
(
"no table qualified for query, TID:0x%"
PRIx64
", QID:0x%"
PRIx64
,
taskId
,
queryId
);
qDebug
(
"no table qualified for query, TID:0x%"
PRIx64
", QID:0x%"
PRIx64
,
taskId
,
queryId
);
goto
_error
;
goto
_error
;
}
}
return
createDataReaderImpl
(
pTableScanNode
,
&
g
roupInfo
,
pHandle
->
reader
,
queryId
,
taskId
);
return
createDataReaderImpl
(
pTableScanNode
,
pTableG
roupInfo
,
pHandle
->
reader
,
queryId
,
taskId
);
_error:
_error:
terrno
=
code
;
terrno
=
code
;
...
@@ -8847,7 +8860,7 @@ static void doUpdateExprColumnIndex(STaskAttr *pQueryAttr) {
...
@@ -8847,7 +8860,7 @@ static void doUpdateExprColumnIndex(STaskAttr *pQueryAttr) {
}
}
}
}
void
setResultBufSize
(
STaskAttr
*
pQueryAttr
,
SR
spR
esultInfo
*
pResultInfo
)
{
void
setResultBufSize
(
STaskAttr
*
pQueryAttr
,
SResultInfo
*
pResultInfo
)
{
const
int32_t
DEFAULT_RESULT_MSG_SIZE
=
1024
*
(
1024
+
512
);
const
int32_t
DEFAULT_RESULT_MSG_SIZE
=
1024
*
(
1024
+
512
);
// the minimum number of rows for projection query
// the minimum number of rows for projection query
...
@@ -8868,7 +8881,7 @@ void setResultBufSize(STaskAttr* pQueryAttr, SRspResultInfo* pResultInfo) {
...
@@ -8868,7 +8881,7 @@ void setResultBufSize(STaskAttr* pQueryAttr, SRspResultInfo* pResultInfo) {
}
}
pResultInfo
->
threshold
=
(
int32_t
)(
pResultInfo
->
capacity
*
THRESHOLD_RATIO
);
pResultInfo
->
threshold
=
(
int32_t
)(
pResultInfo
->
capacity
*
THRESHOLD_RATIO
);
pResultInfo
->
total
=
0
;
pResultInfo
->
total
Rows
=
0
;
}
}
//TODO refactor
//TODO refactor
...
...
source/libs/function/inc/tfill.h
浏览文件 @
3e455e37
...
@@ -61,7 +61,7 @@ typedef struct SFillInfo {
...
@@ -61,7 +61,7 @@ typedef struct SFillInfo {
SFillColInfo
*
pFillCol
;
// column info for fill operations
SFillColInfo
*
pFillCol
;
// column info for fill operations
SFillTagColInfo
*
pTags
;
// tags value for filling gap
SFillTagColInfo
*
pTags
;
// tags value for filling gap
void
*
handle
;
// for debug purpose
const
char
*
id
;
}
SFillInfo
;
}
SFillInfo
;
int64_t
getNumOfResultsAfterFillGap
(
SFillInfo
*
pFillInfo
,
int64_t
ekey
,
int32_t
maxNumOfRows
);
int64_t
getNumOfResultsAfterFillGap
(
SFillInfo
*
pFillInfo
,
int64_t
ekey
,
int32_t
maxNumOfRows
);
...
...
source/libs/function/src/tfill.c
浏览文件 @
3e455e37
...
@@ -342,7 +342,7 @@ static int32_t taosNumOfRemainRows(SFillInfo* pFillInfo) {
...
@@ -342,7 +342,7 @@ static int32_t taosNumOfRemainRows(SFillInfo* pFillInfo) {
struct
SFillInfo
*
taosCreateFillInfo
(
int32_t
order
,
TSKEY
skey
,
int32_t
numOfTags
,
int32_t
capacity
,
int32_t
numOfCols
,
struct
SFillInfo
*
taosCreateFillInfo
(
int32_t
order
,
TSKEY
skey
,
int32_t
numOfTags
,
int32_t
capacity
,
int32_t
numOfCols
,
int64_t
slidingTime
,
int8_t
slidingUnit
,
int8_t
precision
,
int32_t
fillType
,
int64_t
slidingTime
,
int8_t
slidingUnit
,
int8_t
precision
,
int32_t
fillType
,
struct
SFillColInfo
*
pCol
,
void
*
handle
)
{
struct
SFillColInfo
*
pCol
,
const
char
*
id
)
{
if
(
fillType
==
TSDB_FILL_NONE
)
{
if
(
fillType
==
TSDB_FILL_NONE
)
{
return
NULL
;
return
NULL
;
}
}
...
@@ -357,7 +357,7 @@ struct SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTag
...
@@ -357,7 +357,7 @@ struct SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTag
pFillInfo
->
numOfCols
=
numOfCols
;
pFillInfo
->
numOfCols
=
numOfCols
;
pFillInfo
->
precision
=
precision
;
pFillInfo
->
precision
=
precision
;
pFillInfo
->
alloc
=
capacity
;
pFillInfo
->
alloc
=
capacity
;
pFillInfo
->
handle
=
handle
;
pFillInfo
->
id
=
id
;
pFillInfo
->
interval
.
interval
=
slidingTime
;
pFillInfo
->
interval
.
interval
=
slidingTime
;
pFillInfo
->
interval
.
intervalUnit
=
slidingUnit
;
pFillInfo
->
interval
.
intervalUnit
=
slidingUnit
;
...
...
source/libs/nodes/src/nodesCloneFuncs.c
浏览文件 @
3e455e37
...
@@ -272,11 +272,14 @@ static SNode* logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* pD
...
@@ -272,11 +272,14 @@ static SNode* logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* pD
COPY_SCALAR_FIELD
(
interval
);
COPY_SCALAR_FIELD
(
interval
);
COPY_SCALAR_FIELD
(
offset
);
COPY_SCALAR_FIELD
(
offset
);
COPY_SCALAR_FIELD
(
sliding
);
COPY_SCALAR_FIELD
(
sliding
);
COPY_SCALAR_FIELD
(
intervalUnit
);
COPY_SCALAR_FIELD
(
slidingUnit
);
CLONE_NODE_FIELD
(
pFill
);
CLONE_NODE_FIELD
(
pFill
);
COPY_SCALAR_FIELD
(
sessionGap
);
return
(
SNode
*
)
pDst
;
return
(
SNode
*
)
pDst
;
}
}
static
SNode
*
logicSubplanCopy
(
const
S
SubLogicPlan
*
pSrc
,
SSubLogicP
lan
*
pDst
)
{
static
SNode
*
logicSubplanCopy
(
const
S
LogicSubplan
*
pSrc
,
SLogicSubp
lan
*
pDst
)
{
CLONE_NODE_FIELD
(
pNode
);
CLONE_NODE_FIELD
(
pNode
);
COPY_SCALAR_FIELD
(
subplanType
);
COPY_SCALAR_FIELD
(
subplanType
);
return
(
SNode
*
)
pDst
;
return
(
SNode
*
)
pDst
;
...
@@ -358,7 +361,7 @@ SNodeptr nodesCloneNode(const SNodeptr pNode) {
...
@@ -358,7 +361,7 @@ SNodeptr nodesCloneNode(const SNodeptr pNode) {
case
QUERY_NODE_LOGIC_PLAN_WINDOW
:
case
QUERY_NODE_LOGIC_PLAN_WINDOW
:
return
logicWindowCopy
((
const
SWindowLogicNode
*
)
pNode
,
(
SWindowLogicNode
*
)
pDst
);
return
logicWindowCopy
((
const
SWindowLogicNode
*
)
pNode
,
(
SWindowLogicNode
*
)
pDst
);
case
QUERY_NODE_LOGIC_SUBPLAN
:
case
QUERY_NODE_LOGIC_SUBPLAN
:
return
logicSubplanCopy
((
const
S
SubLogicPlan
*
)
pNode
,
(
SSubLogicP
lan
*
)
pDst
);
return
logicSubplanCopy
((
const
S
LogicSubplan
*
)
pNode
,
(
SLogicSubp
lan
*
)
pDst
);
default:
default:
break
;
break
;
}
}
...
...
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
3e455e37
...
@@ -70,6 +70,14 @@ const char* nodesNodeName(ENodeType type) {
...
@@ -70,6 +70,14 @@ const char* nodesNodeName(ENodeType type) {
return
"SlotDesc"
;
return
"SlotDesc"
;
case
QUERY_NODE_COLUMN_DEF
:
case
QUERY_NODE_COLUMN_DEF
:
return
"ColumnDef"
;
return
"ColumnDef"
;
case
QUERY_NODE_DOWNSTREAM_SOURCE
:
return
"DownstreamSource"
;
case
QUERY_NODE_DATABASE_OPTIONS
:
return
"DatabaseOptions"
;
case
QUERY_NODE_TABLE_OPTIONS
:
return
"TableOptions"
;
case
QUERY_NODE_INDEX_OPTIONS
:
return
"IndexOptions"
;
case
QUERY_NODE_SET_OPERATOR
:
case
QUERY_NODE_SET_OPERATOR
:
return
"SetOperator"
;
return
"SetOperator"
;
case
QUERY_NODE_SELECT_STMT
:
case
QUERY_NODE_SELECT_STMT
:
...
@@ -78,16 +86,76 @@ const char* nodesNodeName(ENodeType type) {
...
@@ -78,16 +86,76 @@ const char* nodesNodeName(ENodeType type) {
return
"VnodeModifStmt"
;
return
"VnodeModifStmt"
;
case
QUERY_NODE_CREATE_DATABASE_STMT
:
case
QUERY_NODE_CREATE_DATABASE_STMT
:
return
"CreateDatabaseStmt"
;
return
"CreateDatabaseStmt"
;
case
QUERY_NODE_DROP_DATABASE_STMT
:
return
"DropDatabaseStmt"
;
case
QUERY_NODE_ALTER_DATABASE_STMT
:
return
"AlterDatabaseStmt"
;
case
QUERY_NODE_CREATE_TABLE_STMT
:
case
QUERY_NODE_CREATE_TABLE_STMT
:
return
"CreateTableStmt"
;
return
"CreateTableStmt"
;
case
QUERY_NODE_CREATE_SUBTABLE_CLAUSE
:
return
"CreateSubtableClause"
;
case
QUERY_NODE_CREATE_MULTI_TABLE_STMT
:
return
"CreateMultiTableStmt"
;
case
QUERY_NODE_DROP_TABLE_CLAUSE
:
return
"DropTableClause"
;
case
QUERY_NODE_DROP_TABLE_STMT
:
return
"DropTableStmt"
;
case
QUERY_NODE_DROP_SUPER_TABLE_STMT
:
return
"DropSuperTableStmt"
;
case
QUERY_NODE_ALTER_TABLE_STMT
:
return
"AlterTableStmt"
;
case
QUERY_NODE_CREATE_USER_STMT
:
return
"CreateUserStmt"
;
case
QUERY_NODE_ALTER_USER_STMT
:
return
"AlterUserStmt"
;
case
QUERY_NODE_DROP_USER_STMT
:
return
"DropUserStmt"
;
case
QUERY_NODE_USE_DATABASE_STMT
:
case
QUERY_NODE_USE_DATABASE_STMT
:
return
"UseDatabaseStmt"
;
return
"UseDatabaseStmt"
;
case
QUERY_NODE_CREATE_DNODE_STMT
:
return
"CreateDnodeStmt"
;
case
QUERY_NODE_DROP_DNODE_STMT
:
return
"DropDnodeStmt"
;
case
QUERY_NODE_ALTER_DNODE_STMT
:
return
"AlterDnodeStmt"
;
case
QUERY_NODE_CREATE_INDEX_STMT
:
return
"CreateIndexStmt"
;
case
QUERY_NODE_DROP_INDEX_STMT
:
return
"DropIndexStmt"
;
case
QUERY_NODE_CREATE_QNODE_STMT
:
return
"CreateQnodeStmt"
;
case
QUERY_NODE_DROP_QNODE_STMT
:
return
"DropQnodeStmt"
;
case
QUERY_NODE_CREATE_TOPIC_STMT
:
return
"CreateTopicStmt"
;
case
QUERY_NODE_DROP_TOPIC_STMT
:
return
"DropTopicStmt"
;
case
QUERY_NODE_ALTER_LOCAL_STMT
:
return
"AlterLocalStmt"
;
case
QUERY_NODE_SHOW_DATABASES_STMT
:
case
QUERY_NODE_SHOW_DATABASES_STMT
:
return
"ShowDatabaseStmt"
;
return
"ShowDatabaseStmt"
;
case
QUERY_NODE_SHOW_TABLES_STMT
:
case
QUERY_NODE_SHOW_TABLES_STMT
:
return
"ShowTablesStmt"
;
return
"ShowTablesStmt"
;
case
QUERY_NODE_CREATE_TOPIC_STMT
:
case
QUERY_NODE_SHOW_STABLES_STMT
:
return
"CreateTopicStmt"
;
return
"ShowStablesStmt"
;
case
QUERY_NODE_SHOW_USERS_STMT
:
return
"ShowUsersStmt"
;
case
QUERY_NODE_SHOW_DNODES_STMT
:
return
"ShowDnodesStmt"
;
case
QUERY_NODE_SHOW_VGROUPS_STMT
:
return
"ShowVgroupsStmt"
;
case
QUERY_NODE_SHOW_MNODES_STMT
:
return
"ShowMnodesStmt"
;
case
QUERY_NODE_SHOW_MODULES_STMT
:
return
"ShowModulesStmt"
;
case
QUERY_NODE_SHOW_QNODES_STMT
:
return
"ShowQnodesStmt"
;
case
QUERY_NODE_SHOW_FUNCTIONS_STMT
:
return
"ShowFunctionsStmt"
;
case
QUERY_NODE_SHOW_INDEXES_STMT
:
return
"ShowIndexesStmt"
;
case
QUERY_NODE_SHOW_STREAMS_STMT
:
return
"ShowStreamsStmt"
;
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
return
"LogicScan"
;
return
"LogicScan"
;
case
QUERY_NODE_LOGIC_PLAN_JOIN
:
case
QUERY_NODE_LOGIC_PLAN_JOIN
:
...
@@ -98,6 +166,10 @@ const char* nodesNodeName(ENodeType type) {
...
@@ -98,6 +166,10 @@ const char* nodesNodeName(ENodeType type) {
return
"LogicProject"
;
return
"LogicProject"
;
case
QUERY_NODE_LOGIC_PLAN_VNODE_MODIF
:
case
QUERY_NODE_LOGIC_PLAN_VNODE_MODIF
:
return
"LogicVnodeModif"
;
return
"LogicVnodeModif"
;
case
QUERY_NODE_LOGIC_PLAN_EXCHANGE
:
return
"LogicExchange"
;
case
QUERY_NODE_LOGIC_PLAN_WINDOW
:
return
"LogicWindow"
;
case
QUERY_NODE_LOGIC_SUBPLAN
:
case
QUERY_NODE_LOGIC_SUBPLAN
:
return
"LogicSubplan"
;
return
"LogicSubplan"
;
case
QUERY_NODE_LOGIC_PLAN
:
case
QUERY_NODE_LOGIC_PLAN
:
...
@@ -124,6 +196,8 @@ const char* nodesNodeName(ENodeType type) {
...
@@ -124,6 +196,8 @@ const char* nodesNodeName(ENodeType type) {
return
"PhysiSort"
;
return
"PhysiSort"
;
case
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
:
case
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
:
return
"PhysiInterval"
;
return
"PhysiInterval"
;
case
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW
:
return
"PhysiSessionWindow"
;
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
return
"PhysiDispatch"
;
return
"PhysiDispatch"
;
case
QUERY_NODE_PHYSICAL_PLAN_INSERT
:
case
QUERY_NODE_PHYSICAL_PLAN_INSERT
:
...
@@ -846,8 +920,37 @@ static int32_t jsonToPhysiExchangeNode(const SJson* pJson, void* pObj) {
...
@@ -846,8 +920,37 @@ static int32_t jsonToPhysiExchangeNode(const SJson* pJson, void* pObj) {
return
code
;
return
code
;
}
}
static
const
char
*
jkIntervalPhysiPlanExprs
=
"Exprs"
;
static
const
char
*
jkWindowPhysiPlanExprs
=
"Exprs"
;
static
const
char
*
jkIntervalPhysiPlanFuncs
=
"Funcs"
;
static
const
char
*
jkWindowPhysiPlanFuncs
=
"Funcs"
;
static
int32_t
physiWindowNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SWinodwPhysiNode
*
pNode
=
(
const
SWinodwPhysiNode
*
)
pObj
;
int32_t
code
=
physicPlanNodeToJson
(
pObj
,
pJson
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkWindowPhysiPlanExprs
,
pNode
->
pExprs
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkWindowPhysiPlanFuncs
,
pNode
->
pFuncs
);
}
return
code
;
}
static
int32_t
jsonToPhysiWindowNode
(
const
SJson
*
pJson
,
void
*
pObj
)
{
SWinodwPhysiNode
*
pNode
=
(
SWinodwPhysiNode
*
)
pObj
;
int32_t
code
=
jsonToPhysicPlanNode
(
pJson
,
pObj
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkWindowPhysiPlanExprs
,
&
pNode
->
pExprs
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkWindowPhysiPlanFuncs
,
&
pNode
->
pFuncs
);
}
return
code
;
}
static
const
char
*
jkIntervalPhysiPlanInterval
=
"Interval"
;
static
const
char
*
jkIntervalPhysiPlanInterval
=
"Interval"
;
static
const
char
*
jkIntervalPhysiPlanOffset
=
"Offset"
;
static
const
char
*
jkIntervalPhysiPlanOffset
=
"Offset"
;
static
const
char
*
jkIntervalPhysiPlanSliding
=
"Sliding"
;
static
const
char
*
jkIntervalPhysiPlanSliding
=
"Sliding"
;
...
@@ -858,13 +961,7 @@ static const char* jkIntervalPhysiPlanFill = "Fill";
...
@@ -858,13 +961,7 @@ static const char* jkIntervalPhysiPlanFill = "Fill";
static
int32_t
physiIntervalNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
static
int32_t
physiIntervalNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SIntervalPhysiNode
*
pNode
=
(
const
SIntervalPhysiNode
*
)
pObj
;
const
SIntervalPhysiNode
*
pNode
=
(
const
SIntervalPhysiNode
*
)
pObj
;
int32_t
code
=
physicPlanNodeToJson
(
pObj
,
pJson
);
int32_t
code
=
physiWindowNodeToJson
(
pObj
,
pJson
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkIntervalPhysiPlanExprs
,
pNode
->
pExprs
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkIntervalPhysiPlanFuncs
,
pNode
->
pFuncs
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkIntervalPhysiPlanInterval
,
pNode
->
interval
);
code
=
tjsonAddIntegerToObject
(
pJson
,
jkIntervalPhysiPlanInterval
,
pNode
->
interval
);
}
}
...
@@ -890,13 +987,7 @@ static int32_t physiIntervalNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -890,13 +987,7 @@ static int32_t physiIntervalNodeToJson(const void* pObj, SJson* pJson) {
static
int32_t
jsonToPhysiIntervalNode
(
const
SJson
*
pJson
,
void
*
pObj
)
{
static
int32_t
jsonToPhysiIntervalNode
(
const
SJson
*
pJson
,
void
*
pObj
)
{
SIntervalPhysiNode
*
pNode
=
(
SIntervalPhysiNode
*
)
pObj
;
SIntervalPhysiNode
*
pNode
=
(
SIntervalPhysiNode
*
)
pObj
;
int32_t
code
=
jsonToPhysicPlanNode
(
pJson
,
pObj
);
int32_t
code
=
jsonToPhysiWindowNode
(
pJson
,
pObj
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkIntervalPhysiPlanExprs
,
&
pNode
->
pExprs
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkIntervalPhysiPlanFuncs
,
&
pNode
->
pFuncs
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetBigIntValue
(
pJson
,
jkIntervalPhysiPlanInterval
,
&
pNode
->
interval
);
code
=
tjsonGetBigIntValue
(
pJson
,
jkIntervalPhysiPlanInterval
,
&
pNode
->
interval
);
}
}
...
@@ -919,6 +1010,30 @@ static int32_t jsonToPhysiIntervalNode(const SJson* pJson, void* pObj) {
...
@@ -919,6 +1010,30 @@ static int32_t jsonToPhysiIntervalNode(const SJson* pJson, void* pObj) {
return
code
;
return
code
;
}
}
static
const
char
*
jkSessionWindowPhysiPlanGap
=
"Gap"
;
static
int32_t
physiSessionWindowNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SSessionWinodwPhysiNode
*
pNode
=
(
const
SSessionWinodwPhysiNode
*
)
pObj
;
int32_t
code
=
physiWindowNodeToJson
(
pObj
,
pJson
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkSessionWindowPhysiPlanGap
,
pNode
->
gap
);
}
return
code
;
}
static
int32_t
jsonToPhysiSessionWindowNode
(
const
SJson
*
pJson
,
void
*
pObj
)
{
SSessionWinodwPhysiNode
*
pNode
=
(
SSessionWinodwPhysiNode
*
)
pObj
;
int32_t
code
=
jsonToPhysiWindowNode
(
pJson
,
pObj
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetNumberValue
(
pJson
,
jkSessionWindowPhysiPlanGap
,
pNode
->
gap
);
}
return
code
;
}
static
const
char
*
jkDataSinkInputDataBlockDesc
=
"InputDataBlockDesc"
;
static
const
char
*
jkDataSinkInputDataBlockDesc
=
"InputDataBlockDesc"
;
static
int32_t
physicDataSinkNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
static
int32_t
physicDataSinkNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
...
@@ -2066,6 +2181,8 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -2066,6 +2181,8 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
break
;
break
;
case
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
:
case
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
:
return
physiIntervalNodeToJson
(
pObj
,
pJson
);
return
physiIntervalNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW
:
return
physiSessionWindowNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
return
physiDispatchNodeToJson
(
pObj
,
pJson
);
return
physiDispatchNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_PHYSICAL_PLAN_INSERT
:
case
QUERY_NODE_PHYSICAL_PLAN_INSERT
:
...
@@ -2075,7 +2192,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -2075,7 +2192,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
case
QUERY_NODE_PHYSICAL_PLAN
:
case
QUERY_NODE_PHYSICAL_PLAN
:
return
planToJson
(
pObj
,
pJson
);
return
planToJson
(
pObj
,
pJson
);
default:
default:
assert
(
0
);
//
assert(0);
break
;
break
;
}
}
nodesWarn
(
"specificNodeToJson unknown node = %s"
,
nodesNodeName
(
nodeType
(
pObj
)));
nodesWarn
(
"specificNodeToJson unknown node = %s"
,
nodesNodeName
(
nodeType
(
pObj
)));
...
@@ -2149,14 +2266,16 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
...
@@ -2149,14 +2266,16 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
return
jsonToPhysiAggNode
(
pJson
,
pObj
);
return
jsonToPhysiAggNode
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
:
case
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
:
return
jsonToPhysiExchangeNode
(
pJson
,
pObj
);
return
jsonToPhysiExchangeNode
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
:
return
jsonToPhysiIntervalNode
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW
:
return
jsonToPhysiSessionWindowNode
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
return
jsonToPhysiDispatchNode
(
pJson
,
pObj
);
return
jsonToPhysiDispatchNode
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_SUBPLAN
:
case
QUERY_NODE_PHYSICAL_SUBPLAN
:
return
jsonToSubplan
(
pJson
,
pObj
);
return
jsonToSubplan
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_PLAN
:
case
QUERY_NODE_PHYSICAL_PLAN
:
return
jsonToPlan
(
pJson
,
pObj
);
return
jsonToPlan
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
:
return
jsonToPhysiIntervalNode
(
pJson
,
pObj
);
default:
default:
assert
(
0
);
assert
(
0
);
break
;
break
;
...
...
source/libs/nodes/src/nodesTraverseFuncs.c
浏览文件 @
3e455e37
...
@@ -79,9 +79,14 @@ static EDealRes walkNode(SNode* pNode, ETraversalOrder order, FNodeWalker walker
...
@@ -79,9 +79,14 @@ static EDealRes walkNode(SNode* pNode, ETraversalOrder order, FNodeWalker walker
case
QUERY_NODE_STATE_WINDOW
:
case
QUERY_NODE_STATE_WINDOW
:
res
=
walkNode
(((
SStateWindowNode
*
)
pNode
)
->
pCol
,
order
,
walker
,
pContext
);
res
=
walkNode
(((
SStateWindowNode
*
)
pNode
)
->
pCol
,
order
,
walker
,
pContext
);
break
;
break
;
case
QUERY_NODE_SESSION_WINDOW
:
case
QUERY_NODE_SESSION_WINDOW
:
{
res
=
walkNode
(((
SSessionWindowNode
*
)
pNode
)
->
pCol
,
order
,
walker
,
pContext
);
SSessionWindowNode
*
pSession
=
(
SSessionWindowNode
*
)
pNode
;
res
=
walkNode
(
pSession
->
pCol
,
order
,
walker
,
pContext
);
if
(
DEAL_RES_ERROR
!=
res
)
{
res
=
walkNode
(
pSession
->
pGap
,
order
,
walker
,
pContext
);
}
break
;
break
;
}
case
QUERY_NODE_INTERVAL_WINDOW
:
{
case
QUERY_NODE_INTERVAL_WINDOW
:
{
SIntervalWindowNode
*
pInterval
=
(
SIntervalWindowNode
*
)
pNode
;
SIntervalWindowNode
*
pInterval
=
(
SIntervalWindowNode
*
)
pNode
;
res
=
walkNode
(
pInterval
->
pInterval
,
order
,
walker
,
pContext
);
res
=
walkNode
(
pInterval
->
pInterval
,
order
,
walker
,
pContext
);
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
3e455e37
...
@@ -160,7 +160,7 @@ SNodeptr nodesMakeNode(ENodeType type) {
...
@@ -160,7 +160,7 @@ SNodeptr nodesMakeNode(ENodeType type) {
case
QUERY_NODE_LOGIC_PLAN_WINDOW
:
case
QUERY_NODE_LOGIC_PLAN_WINDOW
:
return
makeNode
(
type
,
sizeof
(
SWindowLogicNode
));
return
makeNode
(
type
,
sizeof
(
SWindowLogicNode
));
case
QUERY_NODE_LOGIC_SUBPLAN
:
case
QUERY_NODE_LOGIC_SUBPLAN
:
return
makeNode
(
type
,
sizeof
(
S
SubLogicP
lan
));
return
makeNode
(
type
,
sizeof
(
S
LogicSubp
lan
));
case
QUERY_NODE_LOGIC_PLAN
:
case
QUERY_NODE_LOGIC_PLAN
:
return
makeNode
(
type
,
sizeof
(
SQueryLogicPlan
));
return
makeNode
(
type
,
sizeof
(
SQueryLogicPlan
));
case
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN
:
case
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN
:
...
@@ -185,6 +185,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
...
@@ -185,6 +185,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
return
makeNode
(
type
,
sizeof
(
SNode
));
return
makeNode
(
type
,
sizeof
(
SNode
));
case
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
:
case
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
:
return
makeNode
(
type
,
sizeof
(
SIntervalPhysiNode
));
return
makeNode
(
type
,
sizeof
(
SIntervalPhysiNode
));
case
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW
:
return
makeNode
(
type
,
sizeof
(
SSessionWinodwPhysiNode
));
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
return
makeNode
(
type
,
sizeof
(
SDataDispatcherNode
));
return
makeNode
(
type
,
sizeof
(
SDataDispatcherNode
));
case
QUERY_NODE_PHYSICAL_PLAN_INSERT
:
case
QUERY_NODE_PHYSICAL_PLAN_INSERT
:
...
@@ -332,6 +334,7 @@ int32_t nodesListAppend(SNodeList* pList, SNodeptr pNode) {
...
@@ -332,6 +334,7 @@ int32_t nodesListAppend(SNodeList* pList, SNodeptr pNode) {
int32_t
nodesListStrictAppend
(
SNodeList
*
pList
,
SNodeptr
pNode
)
{
int32_t
nodesListStrictAppend
(
SNodeList
*
pList
,
SNodeptr
pNode
)
{
if
(
NULL
==
pNode
)
{
if
(
NULL
==
pNode
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
int32_t
code
=
nodesListAppend
(
pList
,
pNode
);
int32_t
code
=
nodesListAppend
(
pList
,
pNode
);
...
@@ -341,6 +344,17 @@ int32_t nodesListStrictAppend(SNodeList* pList, SNodeptr pNode) {
...
@@ -341,6 +344,17 @@ int32_t nodesListStrictAppend(SNodeList* pList, SNodeptr pNode) {
return
code
;
return
code
;
}
}
int32_t
nodesListMakeAppend
(
SNodeList
**
pList
,
SNodeptr
pNode
)
{
if
(
NULL
==
*
pList
)
{
*
pList
=
nodesMakeList
();
if
(
NULL
==
*
pList
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
return
nodesListAppend
(
*
pList
,
pNode
);
}
int32_t
nodesListAppendList
(
SNodeList
*
pTarget
,
SNodeList
*
pSrc
)
{
int32_t
nodesListAppendList
(
SNodeList
*
pTarget
,
SNodeList
*
pSrc
)
{
if
(
NULL
==
pTarget
||
NULL
==
pSrc
)
{
if
(
NULL
==
pTarget
||
NULL
==
pSrc
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
...
source/libs/parser/inc/parAst.h
浏览文件 @
3e455e37
...
@@ -100,7 +100,7 @@ SNode* createTempTableNode(SAstCreateContext* pCxt, SNode* pSubquery, const STok
...
@@ -100,7 +100,7 @@ SNode* createTempTableNode(SAstCreateContext* pCxt, SNode* pSubquery, const STok
SNode
*
createJoinTableNode
(
SAstCreateContext
*
pCxt
,
EJoinType
type
,
SNode
*
pLeft
,
SNode
*
pRight
,
SNode
*
pJoinCond
);
SNode
*
createJoinTableNode
(
SAstCreateContext
*
pCxt
,
EJoinType
type
,
SNode
*
pLeft
,
SNode
*
pRight
,
SNode
*
pJoinCond
);
SNode
*
createLimitNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pLimit
,
const
SToken
*
pOffset
);
SNode
*
createLimitNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pLimit
,
const
SToken
*
pOffset
);
SNode
*
createOrderByExprNode
(
SAstCreateContext
*
pCxt
,
SNode
*
pExpr
,
EOrder
order
,
ENullOrder
nullOrder
);
SNode
*
createOrderByExprNode
(
SAstCreateContext
*
pCxt
,
SNode
*
pExpr
,
EOrder
order
,
ENullOrder
nullOrder
);
SNode
*
createSessionWindowNode
(
SAstCreateContext
*
pCxt
,
SNode
*
pCol
,
const
SToken
*
pVal
);
SNode
*
createSessionWindowNode
(
SAstCreateContext
*
pCxt
,
SNode
*
pCol
,
SNode
*
pGap
);
SNode
*
createStateWindowNode
(
SAstCreateContext
*
pCxt
,
SNode
*
pCol
);
SNode
*
createStateWindowNode
(
SAstCreateContext
*
pCxt
,
SNode
*
pCol
);
SNode
*
createIntervalWindowNode
(
SAstCreateContext
*
pCxt
,
SNode
*
pInterval
,
SNode
*
pOffset
,
SNode
*
pSliding
,
SNode
*
pFill
);
SNode
*
createIntervalWindowNode
(
SAstCreateContext
*
pCxt
,
SNode
*
pInterval
,
SNode
*
pOffset
,
SNode
*
pSliding
,
SNode
*
pFill
);
SNode
*
createFillNode
(
SAstCreateContext
*
pCxt
,
EFillMode
mode
,
SNode
*
pValues
);
SNode
*
createFillNode
(
SAstCreateContext
*
pCxt
,
EFillMode
mode
,
SNode
*
pValues
);
...
...
source/libs/parser/inc/sql.y
浏览文件 @
3e455e37
...
@@ -624,7 +624,7 @@ partition_by_clause_opt(A) ::= PARTITION BY expression_list(B).
...
@@ -624,7 +624,7 @@ partition_by_clause_opt(A) ::= PARTITION BY expression_list(B).
twindow_clause_opt(A) ::= . { A = NULL; }
twindow_clause_opt(A) ::= . { A = NULL; }
twindow_clause_opt(A) ::=
twindow_clause_opt(A) ::=
SESSION NK_LP column_reference(B) NK_COMMA
NK_INTEGER(C) NK_RP. { A = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, B), &C
); }
SESSION NK_LP column_reference(B) NK_COMMA
duration_literal(C) NK_RP. { A = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)
); }
twindow_clause_opt(A) ::= STATE_WINDOW NK_LP column_reference(B) NK_RP. { A = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, B)); }
twindow_clause_opt(A) ::= STATE_WINDOW NK_LP column_reference(B) NK_RP. { A = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, B)); }
twindow_clause_opt(A) ::=
twindow_clause_opt(A) ::=
INTERVAL NK_LP duration_literal(B) NK_RP sliding_opt(C) fill_opt(D). { A = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, B), NULL, C, D); }
INTERVAL NK_LP duration_literal(B) NK_RP sliding_opt(C) fill_opt(D). { A = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, B), NULL, C, D); }
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
3e455e37
...
@@ -679,11 +679,11 @@ SNode* createOrderByExprNode(SAstCreateContext* pCxt, SNode* pExpr, EOrder order
...
@@ -679,11 +679,11 @@ SNode* createOrderByExprNode(SAstCreateContext* pCxt, SNode* pExpr, EOrder order
return
(
SNode
*
)
orderByExpr
;
return
(
SNode
*
)
orderByExpr
;
}
}
SNode
*
createSessionWindowNode
(
SAstCreateContext
*
pCxt
,
SNode
*
pCol
,
const
SToken
*
pVal
)
{
SNode
*
createSessionWindowNode
(
SAstCreateContext
*
pCxt
,
SNode
*
pCol
,
SNode
*
pGap
)
{
SSessionWindowNode
*
session
=
(
SSessionWindowNode
*
)
nodesMakeNode
(
QUERY_NODE_SESSION_WINDOW
);
SSessionWindowNode
*
session
=
(
SSessionWindowNode
*
)
nodesMakeNode
(
QUERY_NODE_SESSION_WINDOW
);
CHECK_OUT_OF_MEM
(
session
);
CHECK_OUT_OF_MEM
(
session
);
session
->
pCol
=
pCol
;
session
->
pCol
=
pCol
;
// session->gap = getInteger(pVal)
;
session
->
pGap
=
pGap
;
return
(
SNode
*
)
session
;
return
(
SNode
*
)
session
;
}
}
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
3e455e37
...
@@ -1870,14 +1870,21 @@ static void toSchema(const SColumnDefNode* pCol, int32_t colId, SSchema* pSchema
...
@@ -1870,14 +1870,21 @@ static void toSchema(const SColumnDefNode* pCol, int32_t colId, SSchema* pSchema
}
}
static
void
destroyCreateTbReq
(
SVCreateTbReq
*
pReq
)
{
static
void
destroyCreateTbReq
(
SVCreateTbReq
*
pReq
)
{
tfree
(
pReq
->
dbFName
);
tfree
(
pReq
->
name
);
tfree
(
pReq
->
name
);
tfree
(
pReq
->
ntbCfg
.
pSchema
);
tfree
(
pReq
->
ntbCfg
.
pSchema
);
}
}
static
int32_t
buildNormalTableBatchReq
(
static
int32_t
buildNormalTableBatchReq
(
int32_t
acctId
,
const
char
*
pDbName
,
const
char
*
pTableName
,
const
char
*
pDbName
,
const
char
*
pTableName
,
const
SNodeList
*
pColumns
,
const
SVgroupInfo
*
pVgroupInfo
,
SVgroupTablesBatch
*
pBatch
)
{
const
SNodeList
*
pColumns
,
const
SVgroupInfo
*
pVgroupInfo
,
SVgroupTablesBatch
*
pBatch
)
{
char
dbFName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
SName
name
=
{
.
type
=
TSDB_DB_NAME_T
,
.
acctId
=
acctId
};
strcpy
(
name
.
dbname
,
pDbName
);
tNameGetFullDbName
(
&
name
,
dbFName
);
SVCreateTbReq
req
=
{
0
};
SVCreateTbReq
req
=
{
0
};
req
.
type
=
TD_NORMAL_TABLE
;
req
.
type
=
TD_NORMAL_TABLE
;
req
.
dbFName
=
strdup
(
dbFName
);
req
.
name
=
strdup
(
pTableName
);
req
.
name
=
strdup
(
pTableName
);
req
.
ntbCfg
.
nCols
=
LIST_LENGTH
(
pColumns
);
req
.
ntbCfg
.
nCols
=
LIST_LENGTH
(
pColumns
);
req
.
ntbCfg
.
pSchema
=
calloc
(
req
.
ntbCfg
.
nCols
,
sizeof
(
SSchema
));
req
.
ntbCfg
.
pSchema
=
calloc
(
req
.
ntbCfg
.
nCols
,
sizeof
(
SSchema
));
...
@@ -1904,7 +1911,7 @@ static int32_t buildNormalTableBatchReq(
...
@@ -1904,7 +1911,7 @@ static int32_t buildNormalTableBatchReq(
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
serializeVgroupTablesBatch
(
int32_t
acctId
,
SVgroupTablesBatch
*
pTbBatch
,
SArray
*
pBufArray
)
{
static
int32_t
serializeVgroupTablesBatch
(
SVgroupTablesBatch
*
pTbBatch
,
SArray
*
pBufArray
)
{
int
tlen
=
sizeof
(
SMsgHead
)
+
tSerializeSVCreateTbBatchReq
(
NULL
,
&
(
pTbBatch
->
req
));
int
tlen
=
sizeof
(
SMsgHead
)
+
tSerializeSVCreateTbBatchReq
(
NULL
,
&
(
pTbBatch
->
req
));
void
*
buf
=
malloc
(
tlen
);
void
*
buf
=
malloc
(
tlen
);
if
(
NULL
==
buf
)
{
if
(
NULL
==
buf
)
{
...
@@ -1932,6 +1939,7 @@ static void destroyCreateTbReqBatch(SVgroupTablesBatch* pTbBatch) {
...
@@ -1932,6 +1939,7 @@ static void destroyCreateTbReqBatch(SVgroupTablesBatch* pTbBatch) {
size_t
size
=
taosArrayGetSize
(
pTbBatch
->
req
.
pArray
);
size_t
size
=
taosArrayGetSize
(
pTbBatch
->
req
.
pArray
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SVCreateTbReq
*
pTableReq
=
taosArrayGet
(
pTbBatch
->
req
.
pArray
,
i
);
SVCreateTbReq
*
pTableReq
=
taosArrayGet
(
pTbBatch
->
req
.
pArray
,
i
);
tfree
(
pTableReq
->
dbFName
);
tfree
(
pTableReq
->
name
);
tfree
(
pTableReq
->
name
);
if
(
pTableReq
->
type
==
TSDB_NORMAL_TABLE
)
{
if
(
pTableReq
->
type
==
TSDB_NORMAL_TABLE
)
{
...
@@ -1973,9 +1981,9 @@ static int32_t buildCreateTableDataBlock(int32_t acctId, const SCreateTableStmt*
...
@@ -1973,9 +1981,9 @@ static int32_t buildCreateTableDataBlock(int32_t acctId, const SCreateTableStmt*
}
}
SVgroupTablesBatch
tbatch
=
{
0
};
SVgroupTablesBatch
tbatch
=
{
0
};
int32_t
code
=
buildNormalTableBatchReq
(
pStmt
->
dbName
,
pStmt
->
tableName
,
pStmt
->
pCols
,
pInfo
,
&
tbatch
);
int32_t
code
=
buildNormalTableBatchReq
(
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
pStmt
->
pCols
,
pInfo
,
&
tbatch
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
serializeVgroupTablesBatch
(
acctId
,
&
tbatch
,
*
pBufArray
);
code
=
serializeVgroupTablesBatch
(
&
tbatch
,
*
pBufArray
);
}
}
destroyCreateTbReqBatch
(
&
tbatch
);
destroyCreateTbReqBatch
(
&
tbatch
);
...
@@ -2004,9 +2012,16 @@ static int32_t rewriteCreateTable(STranslateContext* pCxt, SQuery* pQuery) {
...
@@ -2004,9 +2012,16 @@ static int32_t rewriteCreateTable(STranslateContext* pCxt, SQuery* pQuery) {
return
code
;
return
code
;
}
}
static
void
addCreateTbReqIntoVgroup
(
SHashObj
*
pVgroupHashmap
,
const
char
*
pDbName
,
const
char
*
pTableName
,
SKVRow
row
,
uint64_t
suid
,
SVgroupInfo
*
pVgInfo
)
{
static
void
addCreateTbReqIntoVgroup
(
int32_t
acctId
,
SHashObj
*
pVgroupHashmap
,
const
char
*
pDbName
,
const
char
*
pTableName
,
SKVRow
row
,
uint64_t
suid
,
SVgroupInfo
*
pVgInfo
)
{
char
dbFName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
SName
name
=
{
.
type
=
TSDB_DB_NAME_T
,
.
acctId
=
acctId
};
strcpy
(
name
.
dbname
,
pDbName
);
tNameGetFullDbName
(
&
name
,
dbFName
);
struct
SVCreateTbReq
req
=
{
0
};
struct
SVCreateTbReq
req
=
{
0
};
req
.
type
=
TD_CHILD_TABLE
;
req
.
type
=
TD_CHILD_TABLE
;
req
.
dbFName
=
strdup
(
dbFName
);
req
.
name
=
strdup
(
pTableName
);
req
.
name
=
strdup
(
pTableName
);
req
.
ctbCfg
.
suid
=
suid
;
req
.
ctbCfg
.
suid
=
suid
;
req
.
ctbCfg
.
pTag
=
row
;
req
.
ctbCfg
.
pTag
=
row
;
...
@@ -2159,7 +2174,7 @@ static int32_t rewriteCreateSubTable(STranslateContext* pCxt, SCreateSubTableCla
...
@@ -2159,7 +2174,7 @@ static int32_t rewriteCreateSubTable(STranslateContext* pCxt, SCreateSubTableCla
code
=
getTableHashVgroup
(
pCxt
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
info
);
code
=
getTableHashVgroup
(
pCxt
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
info
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
addCreateTbReqIntoVgroup
(
pVgroupHashmap
,
pStmt
->
dbName
,
pStmt
->
tableName
,
row
,
pSuperTableMeta
->
uid
,
&
info
);
addCreateTbReqIntoVgroup
(
p
Cxt
->
pParseCxt
->
acctId
,
p
VgroupHashmap
,
pStmt
->
dbName
,
pStmt
->
tableName
,
row
,
pSuperTableMeta
->
uid
,
&
info
);
}
}
tfree
(
pSuperTableMeta
);
tfree
(
pSuperTableMeta
);
...
@@ -2181,7 +2196,7 @@ static SArray* serializeVgroupsTablesBatch(int32_t acctId, SHashObj* pVgroupHash
...
@@ -2181,7 +2196,7 @@ static SArray* serializeVgroupsTablesBatch(int32_t acctId, SHashObj* pVgroupHash
break
;
break
;
}
}
serializeVgroupTablesBatch
(
acctId
,
pTbBatch
,
pBufArray
);
serializeVgroupTablesBatch
(
pTbBatch
,
pBufArray
);
destroyCreateTbReqBatch
(
pTbBatch
);
destroyCreateTbReqBatch
(
pTbBatch
);
}
while
(
true
);
}
while
(
true
);
...
...
source/libs/parser/src/parUtil.c
浏览文件 @
3e455e37
...
@@ -71,6 +71,7 @@ int32_t generateSyntaxErrMsg(SMsgBuf* pBuf, int32_t errCode, ...) {
...
@@ -71,6 +71,7 @@ int32_t generateSyntaxErrMsg(SMsgBuf* pBuf, int32_t errCode, ...) {
va_start
(
vArgList
,
errCode
);
va_start
(
vArgList
,
errCode
);
vsnprintf
(
pBuf
->
buf
,
pBuf
->
len
,
getSyntaxErrFormat
(
errCode
),
vArgList
);
vsnprintf
(
pBuf
->
buf
,
pBuf
->
len
,
getSyntaxErrFormat
(
errCode
),
vArgList
);
va_end
(
vArgList
);
va_end
(
vArgList
);
terrno
=
errCode
;
return
errCode
;
return
errCode
;
}
}
...
...
source/libs/parser/src/sql.c
浏览文件 @
3e455e37
...
@@ -208,135 +208,135 @@ typedef union {
...
@@ -208,135 +208,135 @@ typedef union {
** yy_default[] Default action for each state.
** yy_default[] Default action for each state.
**
**
*********** Begin parsing tables **********************************************/
*********** Begin parsing tables **********************************************/
#define YY_ACTTAB_COUNT (126
9
)
#define YY_ACTTAB_COUNT (126
6
)
static
const
YYACTIONTYPE
yy_action
[]
=
{
static
const
YYACTIONTYPE
yy_action
[]
=
{
/* 0 */
1042
,
1201
,
22
1
,
43
,
24
,
167
,
359
,
1197
,
1203
,
1092
,
/* 0 */
1042
,
1201
,
22
2
,
43
,
24
,
168
,
359
,
1197
,
1203
,
1092
,
/* 10 */
24
6
,
265
,
89
,
31
,
29
,
27
,
26
,
25
,
20
,
1201
,
/* 10 */
24
7
,
266
,
89
,
31
,
29
,
27
,
26
,
25
,
20
,
1201
,
/* 20 */
1098
,
27
,
26
,
25
,
1081
,
1197
,
1202
,
1103
,
31
,
29
,
/* 20 */
1098
,
27
,
26
,
25
,
1081
,
1197
,
1202
,
1103
,
31
,
29
,
/* 30 */
27
,
26
,
25
,
358
,
997
,
78
,
20
5
,
866
,
77
,
76
,
/* 30 */
27
,
26
,
25
,
358
,
997
,
78
,
20
6
,
866
,
77
,
76
,
/* 40 */
75
,
74
,
73
,
72
,
71
,
70
,
69
,
1088
,
20
7
,
411
,
/* 40 */
75
,
74
,
73
,
72
,
71
,
70
,
69
,
1088
,
20
8
,
411
,
/* 50 */
410
,
409
,
408
,
407
,
406
,
405
,
404
,
403
,
402
,
401
,
/* 50 */
410
,
409
,
408
,
407
,
406
,
405
,
404
,
403
,
402
,
401
,
/* 60 */
400
,
399
,
398
,
397
,
396
,
395
,
394
,
393
,
1000
,
105
,
/* 60 */
400
,
399
,
398
,
397
,
396
,
395
,
394
,
393
,
1000
,
105
,
/* 70 */
26
6
,
1011
,
878
,
31
,
29
,
27
,
26
,
25
,
1228
,
131
,
/* 70 */
26
7
,
1011
,
878
,
31
,
29
,
27
,
26
,
25
,
1228
,
131
,
/* 80 */
901
,
346
,
111
,
24
5
,
233
,
343
,
1213
,
1177
,
271
,
78
,
/* 80 */
901
,
346
,
111
,
24
6
,
234
,
343
,
1213
,
1177
,
272
,
78
,
/* 90 */
130
,
22
,
77
,
76
,
75
,
74
,
73
,
72
,
71
,
70
,
/* 90 */
130
,
22
,
77
,
76
,
75
,
74
,
73
,
72
,
71
,
70
,
/* 100 */
69
,
31
,
29
,
27
,
26
,
25
,
1228
,
1314
,
20
7
,
287
,
/* 100 */
69
,
31
,
29
,
27
,
26
,
25
,
1228
,
1314
,
20
8
,
288
,
/* 110 */
31
6
,
282
,
266
,
343
,
286
,
44
,
902
,
285
,
128
,
283
,
/* 110 */
31
7
,
283
,
267
,
343
,
287
,
44
,
902
,
286
,
128
,
284
,
/* 120 */
117
,
342
,
28
4
,
345
,
1312
,
23
,
228
,
1189
,
896
,
897
,
/* 120 */
117
,
342
,
28
5
,
345
,
1312
,
23
,
229
,
1189
,
896
,
897
,
/* 130 */
898
,
899
,
900
,
904
,
905
,
906
,
1079
,
20
0
,
1214
,
1217
,
/* 130 */
898
,
899
,
900
,
904
,
905
,
906
,
1079
,
20
1
,
1214
,
1217
,
/* 140 */
901
,
769
,
382
,
381
,
380
,
773
,
379
,
775
,
776
,
378
,
/* 140 */
901
,
769
,
382
,
381
,
380
,
773
,
379
,
775
,
776
,
378
,
/* 150 */
778
,
375
,
109
,
784
,
372
,
786
,
787
,
369
,
366
,
1148
,
/* 150 */
778
,
375
,
109
,
784
,
372
,
786
,
787
,
369
,
366
,
1148
,
/* 160 */
1213
,
846
,
127
,
1141
,
30
1
,
220
,
125
,
43
,
323
,
185
,
/* 160 */
1213
,
846
,
127
,
1141
,
30
2
,
221
,
125
,
43
,
323
,
186
,
/* 170 */
1146
,
358
,
1133
,
30
,
28
,
938
,
902
,
844
,
25
4
,
238
,
/* 170 */
1146
,
358
,
1133
,
30
,
28
,
938
,
902
,
844
,
25
5
,
239
,
/* 180 */
1228
,
23
0
,
392
,
846
,
1099
,
23
,
228
,
343
,
896
,
897
,
/* 180 */
1228
,
23
1
,
392
,
846
,
1099
,
23
,
229
,
343
,
896
,
897
,
/* 190 */
898
,
899
,
900
,
904
,
905
,
906
,
1201
,
345
,
358
,
844
,
/* 190 */
898
,
899
,
900
,
904
,
905
,
906
,
1201
,
345
,
358
,
844
,
/* 200 */
893
,
1189
,
1197
,
1202
,
30
2
,
359
,
331
,
845
,
12
,
118
,
/* 200 */
893
,
1189
,
1197
,
1202
,
30
3
,
359
,
331
,
845
,
12
,
118
,
/* 210 */
66
,
61
,
1214
,
1217
,
1253
,
1213
,
962
,
27
5
,
206
,
1249
,
/* 210 */
66
,
61
,
1214
,
1217
,
1253
,
1213
,
962
,
27
6
,
207
,
1249
,
/* 220 */
1165
,
10
,
122
,
121
,
30
,
28
,
1103
,
120
,
1314
,
845
,
/* 220 */
1165
,
10
,
122
,
121
,
30
,
28
,
1103
,
120
,
1314
,
845
,
/* 230 */
1314
,
1
,
23
0
,
423
,
846
,
1228
,
312
,
960
,
961
,
963
,
/* 230 */
1314
,
1
,
23
1
,
423
,
846
,
1228
,
313
,
960
,
961
,
963
,
/* 240 */
964
,
117
,
330
,
117
,
1213
,
1312
,
24
1
,
1312
,
10
,
321
,
/* 240 */
964
,
117
,
330
,
117
,
1213
,
1312
,
24
2
,
1312
,
10
,
321
,
/* 250 */
844
,
334
,
345
,
1168
,
1170
,
423
,
1189
,
346
,
696
,
12
,
/* 250 */
844
,
334
,
345
,
1168
,
1170
,
423
,
1189
,
346
,
696
,
12
,
/* 260 */
695
,
847
,
850
,
1178
,
1228
,
359
,
62
,
1214
,
1217
,
1253
,
/* 260 */
695
,
847
,
850
,
1178
,
1228
,
359
,
62
,
1214
,
1217
,
1253
,
/* 270 */
66
,
330
,
2
79
,
223
,
1249
,
112
,
278
,
281
,
697
,
327
,
/* 270 */
66
,
330
,
2
80
,
224
,
1249
,
112
,
279
,
282
,
697
,
327
,
/* 280 */
845
,
345
,
1
,
847
,
850
,
1189
,
1103
,
16
3
,
118
,
9
,
/* 280 */
845
,
345
,
1
,
847
,
850
,
1189
,
1103
,
16
4
,
118
,
9
,
/* 290 */
8
,
59
,
1213
,
30
8
,
1280
,
62
,
1214
,
1217
,
1253
,
280
,
/* 290 */
8
,
59
,
1213
,
30
9
,
1280
,
62
,
1214
,
1217
,
1253
,
281
,
/* 300 */
92
,
93
,
22
3
,
1249
,
112
,
1314
,
423
,
327
,
1095
,
106
,
/* 300 */
92
,
93
,
22
4
,
1249
,
112
,
1314
,
423
,
327
,
1095
,
106
,
/* 310 */
1070
,
903
,
1228
,
31
,
29
,
27
,
26
,
25
,
1313
,
343
,
/* 310 */
1070
,
903
,
1228
,
31
,
29
,
27
,
26
,
25
,
1313
,
343
,
/* 320 */
21
,
1213
,
1312
,
1281
,
392
,
1267
,
90
,
868
,
92
,
345
,
/* 320 */
21
,
1213
,
1312
,
1281
,
392
,
1267
,
90
,
868
,
92
,
345
,
/* 330 */
907
,
419
,
418
,
1189
,
847
,
850
,
114
,
1260
,
1261
,
867
,
/* 330 */
907
,
419
,
418
,
1189
,
847
,
850
,
114
,
1260
,
1261
,
867
,
/* 340 */
1265
,
1228
,
1264
,
62
,
1214
,
1217
,
1253
,
331
,
343
,
118
,
/* 340 */
1265
,
1228
,
1264
,
62
,
1214
,
1217
,
1253
,
331
,
343
,
118
,
/* 350 */
22
3
,
1249
,
1326
,
695
,
90
,
1094
,
1213
,
864
,
345
,
914
,
/* 350 */
22
4
,
1249
,
1326
,
695
,
90
,
1094
,
1213
,
864
,
345
,
914
,
/* 360 */
1228
,
1287
,
1189
,
865
,
16
0
,
1260
,
326
,
343
,
325
,
273
,
/* 360 */
1228
,
1287
,
1189
,
865
,
16
1
,
1260
,
326
,
343
,
325
,
274
,
/* 370 */
23
4
,
1314
,
62
,
1214
,
1217
,
1253
,
1228
,
359
,
104
,
223
,
/* 370 */
23
5
,
1314
,
62
,
1214
,
1217
,
1253
,
1228
,
359
,
104
,
224
,
/* 380 */
1249
,
1326
,
1100
,
343
,
117
,
1213
,
1105
,
385
,
1312
,
1022
,
/* 380 */
1249
,
1326
,
1100
,
343
,
117
,
1213
,
1105
,
385
,
1312
,
1022
,
/* 390 */
1310
,
1090
,
320
,
345
,
30
,
28
,
1189
,
1189
,
1103
,
1021
,
/* 390 */
1310
,
1090
,
320
,
345
,
30
,
28
,
1189
,
1189
,
1103
,
1021
,
/* 400 */
1267
,
333
,
23
0
,
104
,
846
,
1228
,
1080
,
62
,
1214
,
1217
,
/* 400 */
1267
,
333
,
23
1
,
104
,
846
,
1228
,
1080
,
62
,
1214
,
1217
,
/* 410 */
1253
,
1106
,
343
,
1148
,
22
3
,
1249
,
1326
,
1263
,
359
,
235
,
/* 410 */
1253
,
1106
,
343
,
1148
,
22
4
,
1249
,
1326
,
1263
,
359
,
236
,
/* 420 */
844
,
1148
,
345
,
356
,
1146
,
1271
,
1189
,
24
2
,
162
,
12
,
/* 420 */
844
,
1148
,
345
,
356
,
1146
,
1271
,
1189
,
24
3
,
163
,
12
,
/* 430 */
1189
,
331
,
1146
,
30
,
28
,
1012
,
19
5
,
1214
,
1217
,
1103
,
/* 430 */
1189
,
331
,
1146
,
30
,
28
,
1012
,
19
6
,
1214
,
1217
,
1103
,
/* 440 */
1189
,
23
0
,
1213
,
846
,
190
,
1020
,
1019
,
1018
,
136
,
192
,
/* 440 */
1189
,
23
1
,
1213
,
846
,
191
,
1020
,
1019
,
1018
,
136
,
193
,
/* 450 */
845
,
134
,
1
,
1038
,
31
5
,
1314
,
30
,
28
,
344
,
844
,
/* 450 */
845
,
134
,
1
,
1038
,
31
6
,
1314
,
30
,
28
,
344
,
844
,
/* 460 */
6
,
19
1
,
1228
,
389
,
230
,
1213
,
846
,
388
,
117
,
343
,
/* 460 */
6
,
19
2
,
1228
,
389
,
231
,
1213
,
846
,
388
,
117
,
343
,
/* 470 */
1017
,
123
,
1312
,
1148
,
118
,
28
8
,
423
,
322
,
317
,
345
,
/* 470 */
1017
,
123
,
1312
,
1148
,
118
,
28
9
,
423
,
322
,
318
,
345
,
/* 480 */
1016
,
1015
,
844
,
1189
,
1169
,
1228
,
1189
,
1189
,
1189
,
845
,
/* 480 */
1016
,
1015
,
844
,
1189
,
1169
,
1228
,
1189
,
1189
,
1189
,
845
,
/* 490 */
390
,
7
,
343
,
63
,
1214
,
1217
,
1253
,
1148
,
869
,
1086
,
/* 490 */
390
,
7
,
343
,
63
,
1214
,
1217
,
1253
,
1148
,
869
,
1086
,
/* 500 */
1252
,
1249
,
345
,
1045
,
847
,
850
,
1189
,
945
,
1147
,
387
,
/* 500 */
1252
,
1249
,
345
,
1045
,
847
,
850
,
1189
,
945
,
1147
,
387
,
/* 510 */
386
,
1189
,
845
,
866
,
7
,
423
,
63
,
1214
,
1217
,
1253
,
/* 510 */
386
,
1189
,
845
,
866
,
7
,
423
,
63
,
1214
,
1217
,
1253
,
/* 520 */
24
0
,
1189
,
1189
,
341
,
1249
,
30
,
28
,
299
,
104
,
30
,
/* 520 */
24
1
,
1189
,
1189
,
341
,
1249
,
30
,
28
,
300
,
104
,
30
,
/* 530 */
28
,
64
,
384
,
23
0
,
338
,
846
,
1105
,
230
,
423
,
846
,
/* 530 */
28
,
64
,
384
,
23
1
,
338
,
846
,
1105
,
231
,
423
,
846
,
/* 540 */
29
7
,
1213
,
1267
,
847
,
850
,
999
,
31
,
29
,
27
,
26
,
/* 540 */
29
8
,
1213
,
1267
,
847
,
850
,
999
,
31
,
29
,
27
,
26
,
/* 550 */
25
,
844
,
28
7
,
933
,
282
,
844
,
1014
,
286
,
118
,
1262
,
/* 550 */
25
,
844
,
28
8
,
933
,
283
,
844
,
1014
,
287
,
118
,
1262
,
/* 560 */
28
5
,
1228
,
283
,
118
,
1213
,
284
,
847
,
850
,
343
,
87
,
/* 560 */
28
6
,
1228
,
284
,
118
,
1213
,
285
,
847
,
850
,
343
,
87
,
/* 570 */
86
,
85
,
84
,
83
,
82
,
81
,
80
,
79
,
345
,
864
,
/* 570 */
86
,
85
,
84
,
83
,
82
,
81
,
80
,
79
,
345
,
864
,
/* 580 */
1033
,
845
,
1189
,
7
,
1228
,
845
,
24
7
,
1
,
1071
,
259
,
/* 580 */
1033
,
845
,
1189
,
7
,
1228
,
845
,
24
8
,
1
,
1071
,
260
,
/* 590 */
1013
,
343
,
107
,
1214
,
1217
,
937
,
426
,
1189
,
26
0
,
149
,
/* 590 */
1013
,
343
,
107
,
1214
,
1217
,
937
,
426
,
1189
,
26
1
,
149
,
/* 600 */
1213
,
345
,
29
0
,
164
,
359
,
1189
,
243
,
423
,
339
,
357
,
/* 600 */
1213
,
345
,
29
1
,
165
,
359
,
1189
,
244
,
423
,
339
,
357
,
/* 610 */
18
3
,
423
,
304
,
88
,
104
,
63
,
1214
,
1217
,
1253
,
415
,
/* 610 */
18
4
,
423
,
305
,
88
,
104
,
63
,
1214
,
1217
,
1253
,
415
,
/* 620 */
1228
,
18
2
,
1105
,
1250
,
98
,
1103
,
1010
,
343
,
313
,
332
,
/* 620 */
1228
,
18
3
,
1105
,
1250
,
98
,
1103
,
1010
,
343
,
314
,
332
,
/* 630 */
1327
,
1189
,
1031
,
1009
,
1008
,
847
,
850
,
345
,
359
,
847
,
/* 630 */
1327
,
1189
,
1031
,
1009
,
1008
,
847
,
850
,
345
,
359
,
847
,
/* 640 */
850
,
1189
,
1142
,
18
0
,
229
,
359
,
60
,
1007
,
1006
,
178
,
/* 640 */
850
,
1189
,
1142
,
18
1
,
230
,
359
,
60
,
1007
,
1006
,
179
,
/* 650 */
24
4
,
201
,
1214
,
1217
,
293
,
1005
,
157
,
1004
,
1213
,
1103
,
/* 650 */
24
5
,
202
,
1214
,
1217
,
294
,
1005
,
158
,
1004
,
1213
,
1103
,
/* 660 */
1272
,
933
,
1229
,
1213
,
27
2
,
258
,
1103
,
1189
,
253
,
252
,
/* 660 */
1272
,
933
,
1229
,
1213
,
27
3
,
259
,
1103
,
1189
,
254
,
253
,
/* 670 */
25
1
,
250
,
249
,
335
,
1189
,
1189
,
1003
,
853
,
1228
,
138
,
/* 670 */
25
2
,
251
,
250
,
335
,
1189
,
1189
,
1003
,
853
,
1228
,
138
,
/* 680 */
355
,
1213
,
137
,
1228
,
140
,
343
,
1213
,
139
,
1189
,
1189
,
/* 680 */
355
,
1213
,
137
,
1228
,
140
,
343
,
1213
,
139
,
1189
,
1189
,
/* 690 */
343
,
852
,
991
,
992
,
30
7
,
345
,
1189
,
146
,
1189
,
1189
,
/* 690 */
343
,
852
,
991
,
992
,
30
8
,
345
,
1189
,
146
,
1189
,
1189
,
/* 700 */
345
,
1228
,
3
09
,
327
,
1189
,
328
,
1228
,
856
,
343
,
201
,
/* 700 */
345
,
1228
,
3
10
,
327
,
1189
,
328
,
1228
,
856
,
343
,
202
,
/* 710 */
1214
,
1217
,
1002
,
343
,
107
,
1214
,
1217
,
1189
,
345
,
9
,
/* 710 */
1214
,
1217
,
1002
,
343
,
107
,
1214
,
1217
,
1189
,
345
,
9
,
/* 720 */
8
,
855
,
1189
,
345
,
92
,
22
7
,
864
,
1189
,
1213
,
936
,
/* 720 */
8
,
855
,
1189
,
345
,
92
,
22
8
,
864
,
1189
,
1213
,
936
,
/* 730 */
23
1
,
1213
,
201
,
1214
,
1217
,
1283
,
1213
,
201
,
1214
,
1217
,
/* 730 */
23
2
,
1213
,
202
,
1214
,
1217
,
1283
,
1213
,
202
,
1214
,
1217
,
/* 740 */
31
,
29
,
27
,
26
,
25
,
336
,
327
,
1167
,
1228
,
52
,
/* 740 */
31
,
29
,
27
,
26
,
25
,
336
,
327
,
1167
,
1228
,
52
,
/* 750 */
90
,
1228
,
1328
,
1189
,
16
6
,
343
,
1228
,
1078
,
343
,
329
,
/* 750 */
90
,
1228
,
1328
,
1189
,
16
7
,
343
,
1228
,
1078
,
343
,
329
,
/* 760 */
113
,
1260
,
1261
,
343
,
1265
,
345
,
1096
,
92
,
345
,
1189
,
/* 760 */
113
,
1260
,
1261
,
343
,
1265
,
345
,
1096
,
92
,
345
,
1189
,
/* 770 */
2
,
119
,
1189
,
345
,
1213
,
142
,
25
6
,
1189
,
141
,
199
,
/* 770 */
2
,
119
,
1189
,
345
,
1213
,
142
,
25
7
,
1189
,
141
,
200
,
/* 780 */
1214
,
1217
,
20
2
,
1214
,
1217
,
959
,
154
,
193
,
1214
,
1217
,
/* 780 */
1214
,
1217
,
20
3
,
1214
,
1217
,
959
,
154
,
194
,
1214
,
1217
,
/* 790 */
24
8
,
255
,
257
,
90
,
1228
,
261
,
1213
,
41
,
152
,
878
,
/* 790 */
24
9
,
256
,
258
,
90
,
1228
,
262
,
1213
,
41
,
152
,
878
,
/* 800 */
908
,
343
,
1213
,
115
,
1260
,
1261
,
872
,
1265
,
994
,
995
,
/* 800 */
908
,
343
,
1213
,
115
,
1260
,
1261
,
872
,
1265
,
994
,
995
,
/* 810 */
26
2
,
345
,
32
,
263
,
389
,
1189
,
1228
,
124
,
388
,
871
,
/* 810 */
26
3
,
345
,
32
,
264
,
389
,
1189
,
1228
,
124
,
388
,
871
,
/* 820 */
875
,
58
,
1228
,
343
,
42
,
20
3
,
1214
,
1217
,
1207
,
343
,
/* 820 */
875
,
58
,
1228
,
343
,
42
,
20
4
,
1214
,
1217
,
1207
,
343
,
/* 830 */
1213
,
54
,
32
,
345
,
839
,
26
4
,
1213
,
1189
,
267
,
345
,
/* 830 */
1213
,
54
,
32
,
345
,
839
,
26
5
,
1213
,
1189
,
268
,
345
,
/* 840 */
1205
,
390
,
129
,
1189
,
27
4
,
870
,
32
,
194
,
1214
,
1217
,
/* 840 */
1205
,
390
,
129
,
1189
,
27
5
,
870
,
32
,
195
,
1214
,
1217
,
/* 850 */
1228
,
27
6
,
68
,
204
,
1214
,
1217
,
1228
,
343
,
172
,
1093
,
/* 850 */
1228
,
27
7
,
68
,
205
,
1214
,
1217
,
1228
,
343
,
173
,
1093
,
/* 860 */
387
,
386
,
2
19
,
343
,
1213
,
133
,
351
,
345
,
177
,
1089
,
/* 860 */
387
,
386
,
2
20
,
343
,
1213
,
133
,
351
,
345
,
178
,
1089
,
/* 870 */
17
0
,
1189
,
135
,
345
,
762
,
100
,
101
,
1189
,
95
,
1091
,
/* 870 */
17
1
,
1189
,
135
,
345
,
762
,
100
,
101
,
1189
,
95
,
1091
,
/* 880 */
96
,
1225
,
1214
,
1217
,
1228
,
1087
,
98
,
1224
,
1214
,
1217
,
/* 880 */
96
,
1225
,
1214
,
1217
,
1228
,
1087
,
98
,
1224
,
1214
,
1217
,
/* 890 */
757
,
343
,
1213
,
102
,
790
,
794
,
103
,
800
,
1213
,
799
,
/* 890 */
757
,
343
,
1213
,
102
,
790
,
794
,
103
,
800
,
1213
,
799
,
/* 900 */
30
6
,
345
,
41
,
303
,
145
,
1189
,
364
,
96
,
99
,
97
,
/* 900 */
30
7
,
345
,
41
,
304
,
145
,
1189
,
364
,
96
,
99
,
97
,
/* 910 */
30
5
,
98
,
1228
,
869
,
314
,
1223
,
1214
,
1217
,
1228
,
343
,
/* 910 */
30
6
,
98
,
1228
,
869
,
315
,
1223
,
1214
,
1217
,
1228
,
343
,
/* 920 */
96
,
1284
,
349
,
1294
,
150
,
343
,
31
1
,
850
,
1293
,
345
,
/* 920 */
96
,
1284
,
349
,
1294
,
150
,
343
,
31
2
,
850
,
1293
,
345
,
/* 930 */
153
,
22
2
,
1213
,
1189
,
5
,
345
,
324
,
110
,
1274
,
1189
,
/* 930 */
153
,
22
3
,
1213
,
1189
,
319
,
345
,
5
,
110
,
1274
,
1189
,
/* 940 */
1213
,
3
10
,
156
,
210
,
1214
,
1217
,
237
,
236
,
4
,
209
,
/* 940 */
1213
,
3
24
,
157
,
211
,
1214
,
1217
,
238
,
237
,
311
,
210
,
/* 950 */
1214
,
1217
,
1228
,
933
,
91
,
868
,
858
,
1268
,
33
,
343
,
/* 950 */
1214
,
1217
,
1228
,
4
,
933
,
91
,
858
,
868
,
1268
,
343
,
/* 960 */
1228
,
159
,
158
,
340
,
1311
,
224
,
1329
,
343
,
1213
,
345
,
/* 960 */
1228
,
33
,
159
,
160
,
1311
,
225
,
1329
,
343
,
1213
,
345
,
/* 970 */
337
,
165
,
851
,
1189
,
292
,
214
,
17
,
345
,
1235
,
1176
,
/* 970 */
337
,
340
,
851
,
1189
,
293
,
215
,
166
,
345
,
17
,
1235
,
/* 980 */
347
,
1189
,
348
,
211
,
1214
,
1217
,
352
,
1175
,
1228
,
300
,
/* 980 */
1176
,
1189
,
347
,
212
,
1214
,
1217
,
348
,
233
,
1228
,
301
,
/* 990 */
232
,
208
,
1214
,
1217
,
353
,
343
,
354
,
279
,
51
,
174
,
/* 990 */
1175
,
209
,
1214
,
1217
,
352
,
343
,
353
,
280
,
354
,
175
,
/* 1000 */
184
,
278
,
854
,
144
,
1104
,
345
,
295
,
53
,
186
,
1189
,
/* 1000 */
51
,
279
,
854
,
144
,
185
,
345
,
296
,
187
,
53
,
1189
,
/* 1010 */
362
,
289
,
181
,
215
,
143
,
213
,
212
,
422
,
277
,
198
,
/* 1010 */
1104
,
290
,
182
,
216
,
143
,
214
,
213
,
422
,
278
,
199
,
/* 1020 */
1214
,
1217
,
196
,
197
,
280
,
188
,
189
,
1183
,
360
,
822
,
/* 1020 */
1214
,
1217
,
362
,
197
,
281
,
198
,
189
,
190
,
360
,
1183
,
/* 1030 */
1160
,
1159
,
94
,
1158
,
1157
,
1156
,
1155
,
1154
,
1153
,
40
,
/* 1030 */
822
,
1160
,
1159
,
94
,
1158
,
1157
,
1156
,
1155
,
1154
,
40
,
/* 1040 */
824
,
1152
,
39
,
1151
,
1150
,
1149
,
1044
,
1182
,
1173
,
126
,
/* 1040 */
1153
,
824
,
39
,
1152
,
1151
,
1150
,
1149
,
1044
,
1182
,
1173
,
/* 1050 */
1082
,
708
,
1043
,
1041
,
268
,
269
,
859
,
850
,
270
,
1030
,
/* 1050 */
126
,
1082
,
708
,
1043
,
1041
,
269
,
859
,
850
,
270
,
271
,
/* 1060 */
10
29
,
1026
,
1084
,
67
,
132
,
1083
,
805
,
804
,
1039
,
1034
,
/* 1060 */
10
30
,
1029
,
1026
,
1084
,
67
,
132
,
805
,
1083
,
804
,
1039
,
/* 1070 */
737
,
803
,
1032
,
1025
,
1024
,
1181
,
65
,
736
,
735
,
216
,
/* 1070 */
1034
,
737
,
803
,
1032
,
1025
,
1024
,
1181
,
736
,
217
,
735
,
/* 1080 */
734
,
1180
,
36
,
1172
,
45
,
217
,
218
,
148
,
296
,
73
3
,
/* 1080 */
734
,
218
,
1180
,
36
,
1172
,
45
,
219
,
148
,
297
,
3
,
/* 1090 */
3
,
32
,
732
,
298
,
291
,
14
,
294
,
151
,
15
,
34
,
/* 1090 */
733
,
65
,
32
,
732
,
299
,
14
,
292
,
151
,
958
,
15
,
/* 1100 */
37
,
11
,
48
,
319
,
1205
,
8
,
19
,
161
,
894
,
350
,
/* 1100 */
1205
,
147
,
162
,
295
,
37
,
11
,
156
,
19
,
34
,
48
,
/* 1110 */
147
,
176
,
998
,
998
,
998
,
998
,
998
,
318
,
1171
,
998
,
/* 1110 */
8
,
350
,
894
,
1171
,
177
,
998
,
998
,
998
,
998
,
998
,
/* 1120 */
783
,
998
,
998
,
998
,
998
,
998
,
998
,
998
,
998
,
980
,
/* 1120 */
998
,
783
,
998
,
998
,
998
,
998
,
998
,
998
,
980
,
979
,
/* 1130 */
979
,
225
,
984
,
983
,
226
,
998
,
998
,
998
,
99
8
,
998
,
/* 1130 */
226
,
984
,
983
,
227
,
860
,
998
,
998
,
998
,
10
8
,
998
,
/* 1140 */
998
,
958
,
998
,
175
,
998
,
998
,
10
8
,
155
,
998
,
952
,
/* 1140 */
998
,
176
,
998
,
998
,
998
,
998
,
99
8
,
155
,
998
,
952
,
/* 1150 */
46
,
998
,
860
,
951
,
47
,
768
,
930
,
929
,
998
,
985
,
/* 1150 */
46
,
998
,
951
,
47
,
998
,
768
,
930
,
929
,
998
,
985
,
/* 1160 */
998
,
998
,
998
,
998
,
998
,
998
,
998
,
998
,
998
,
13
,
/* 1160 */
998
,
998
,
35
,
998
,
998
,
998
,
998
,
998
,
876
,
116
,
/* 1170 */
35
,
116
,
876
,
16
,
18
,
998
,
169
,
956
,
171
,
168
,
/* 1170 */
13
,
18
,
16
,
170
,
956
,
998
,
172
,
174
,
169
,
49
,
/* 1180 */
49
,
173
,
50
,
998
,
1204
,
363
,
239
,
54
,
367
,
38
,
/* 1180 */
50
,
1204
,
998
,
998
,
54
,
38
,
363
,
1040
,
240
,
367
,
/* 1190 */
10
40
,
179
,
370
,
373
,
998
,
998
,
998
,
998
,
376
,
998
,
/* 1190 */
10
28
,
370
,
373
,
180
,
998
,
361
,
998
,
796
,
376
,
998
,
/* 1200 */
998
,
796
,
998
,
791
,
365
,
998
,
788
,
728
,
720
,
998
,
/* 1200 */
791
,
365
,
728
,
788
,
368
,
1027
,
785
,
998
,
798
,
371
,
/* 1210 */
420
,
848
,
361
,
785
,
368
,
798
,
797
,
782
,
998
,
998
,
/* 1210 */
420
,
720
,
797
,
779
,
998
,
998
,
998
,
727
,
782
,
998
,
/* 1220 */
72
7
,
371
,
998
,
998
,
779
,
726
,
55
,
374
,
706
,
777
,
/* 1220 */
72
6
,
998
,
998
,
725
,
724
,
706
,
781
,
374
,
391
,
777
,
/* 1230 */
391
,
725
,
724
,
1028
,
414
,
1027
,
1023
,
723
,
413
,
998
,
/* 1230 */
723
,
722
,
721
,
377
,
719
,
1023
,
718
,
717
,
413
,
716
,
/* 1240 */
3
77
,
998
,
722
,
721
,
56
,
57
,
719
,
718
,
187
,
729
,
/* 1240 */
3
83
,
55
,
56
,
57
,
425
,
715
,
729
,
714
,
713
,
421
,
/* 1250 */
421
,
717
,
716
,
715
,
714
,
713
,
712
,
383
,
424
,
711
,
/* 1250 */
712
,
711
,
412
,
848
,
188
,
424
,
998
,
416
,
417
,
998
,
/* 1260 */
412
,
425
,
998
,
416
,
417
,
998
,
998
,
781
,
780
,
/* 1260 */
998
,
414
,
998
,
998
,
998
,
780
,
};
};
static
const
YYCODETYPE
yy_lookahead
[]
=
{
static
const
YYCODETYPE
yy_lookahead
[]
=
{
/* 0 */
0
,
207
,
190
,
174
,
221
,
222
,
172
,
213
,
214
,
187
,
/* 0 */
0
,
207
,
190
,
174
,
221
,
222
,
172
,
213
,
214
,
187
,
...
@@ -432,40 +432,40 @@ static const YYCODETYPE yy_lookahead[] = {
...
@@ -432,40 +432,40 @@ static const YYCODETYPE yy_lookahead[] = {
/* 900 */
204
,
203
,
83
,
211
,
171
,
207
,
83
,
83
,
71
,
83
,
/* 900 */
204
,
203
,
83
,
211
,
171
,
207
,
83
,
83
,
71
,
83
,
/* 910 */
193
,
83
,
186
,
20
,
145
,
217
,
218
,
219
,
186
,
193
,
/* 910 */
193
,
83
,
186
,
20
,
145
,
217
,
218
,
219
,
186
,
193
,
/* 920 */
83
,
216
,
144
,
246
,
208
,
193
,
207
,
123
,
246
,
203
,
/* 920 */
83
,
216
,
144
,
246
,
208
,
193
,
207
,
123
,
246
,
203
,
/* 930 */
208
,
207
,
166
,
207
,
152
,
203
,
151
,
240
,
243
,
207
,
/* 930 */
208
,
207
,
166
,
207
,
207
,
203
,
152
,
240
,
243
,
207
,
/* 940 */
166
,
1
40
,
242
,
217
,
218
,
219
,
12
,
13
,
139
,
217
,
/* 940 */
166
,
1
51
,
242
,
217
,
218
,
219
,
12
,
13
,
140
,
217
,
/* 950 */
218
,
219
,
186
,
13
6
,
193
,
20
,
22
,
215
,
114
,
193
,
/* 950 */
218
,
219
,
186
,
13
9
,
136
,
193
,
22
,
20
,
215
,
193
,
/* 960 */
186
,
227
,
239
,
156
,
252
,
160
,
257
,
193
,
166
,
203
,
/* 960 */
186
,
114
,
239
,
227
,
252
,
160
,
257
,
193
,
166
,
203
,
/* 970 */
154
,
251
,
38
,
207
,
4
,
35
,
70
,
203
,
223
,
208
,
/* 970 */
154
,
156
,
38
,
207
,
4
,
35
,
251
,
203
,
70
,
223
,
/* 980 */
20
7
,
207
,
207
,
217
,
218
,
219
,
118
,
208
,
186
,
19
,
/* 980 */
20
8
,
207
,
207
,
217
,
218
,
219
,
207
,
207
,
186
,
19
,
/* 990 */
20
7
,
217
,
218
,
219
,
205
,
193
,
204
,
57
,
171
,
193
,
/* 990 */
20
8
,
217
,
218
,
219
,
118
,
193
,
205
,
57
,
204
,
193
,
/* 1000 */
1
82
,
61
,
68
,
33
,
193
,
203
,
36
,
70
,
172
,
207
,
/* 1000 */
1
71
,
61
,
68
,
33
,
182
,
203
,
36
,
172
,
70
,
207
,
/* 1010 */
1
89
,
41
,
171
,
73
,
44
,
75
,
76
,
168
,
78
,
217
,
/* 1010 */
1
93
,
41
,
171
,
73
,
44
,
75
,
76
,
168
,
78
,
217
,
/* 1020 */
218
,
219
,
18
0
,
180
,
84
,
173
,
164
,
0
,
94
,
82
,
/* 1020 */
218
,
219
,
18
9
,
180
,
84
,
180
,
173
,
164
,
94
,
0
,
/* 1030 */
0
,
0
,
114
,
0
,
0
,
0
,
0
,
0
,
0
,
69
,
/* 1030 */
82
,
0
,
0
,
114
,
0
,
0
,
0
,
0
,
0
,
69
,
/* 1040 */
22
,
0
,
72
,
0
,
0
,
0
,
0
,
0
,
0
,
43
,
/* 1040 */
0
,
22
,
72
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
/* 1050 */
0
,
48
,
0
,
0
,
38
,
36
,
122
,
123
,
43
,
0
,
/* 1050 */
43
,
0
,
48
,
0
,
0
,
38
,
122
,
123
,
36
,
43
,
/* 1060 */
0
,
0
,
0
,
79
,
77
,
0
,
38
,
38
,
0
,
0
,
/* 1060 */
0
,
0
,
0
,
0
,
79
,
77
,
38
,
0
,
38
,
0
,
/* 1070 */
38
,
22
,
0
,
0
,
0
,
0
,
20
,
38
,
38
,
22
,
/* 1070 */
0
,
38
,
22
,
0
,
0
,
0
,
0
,
38
,
22
,
38
,
/* 1080 */
38
,
0
,
121
,
0
,
70
,
22
,
22
,
116
,
22
,
38
,
/* 1080 */
38
,
22
,
0
,
121
,
0
,
70
,
22
,
116
,
22
,
83
,
/* 1090 */
83
,
83
,
38
,
22
,
39
,
141
,
38
,
71
,
141
,
135
,
/* 1090 */
38
,
20
,
83
,
38
,
22
,
141
,
39
,
71
,
71
,
141
,
/* 1100 */
8
3
,
141
,
4
,
83
,
82
,
2
,
83
,
82
,
126
,
119
,
/* 1100 */
8
2
,
43
,
82
,
38
,
83
,
141
,
83
,
83
,
135
,
4
,
/* 1110 */
43
,
116
,
258
,
258
,
258
,
258
,
258
,
38
,
0
,
258
,
/* 1110 */
2
,
119
,
126
,
0
,
116
,
258
,
258
,
258
,
258
,
258
,
/* 1120 */
96
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
25
8
,
38
,
/* 1120 */
258
,
96
,
258
,
258
,
258
,
258
,
258
,
258
,
3
8
,
38
,
/* 1130 */
38
,
38
,
38
,
38
,
38
,
258
,
258
,
258
,
258
,
258
,
/* 1130 */
38
,
38
,
38
,
38
,
22
,
258
,
258
,
258
,
70
,
258
,
/* 1140 */
258
,
71
,
258
,
43
,
258
,
258
,
70
,
70
,
258
,
71
,
/* 1140 */
258
,
43
,
258
,
258
,
258
,
258
,
258
,
70
,
258
,
71
,
/* 1150 */
70
,
258
,
22
,
71
,
70
,
22
,
71
,
71
,
258
,
71
,
/* 1150 */
70
,
258
,
71
,
70
,
258
,
22
,
71
,
71
,
258
,
71
,
/* 1160 */
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
70
,
/* 1160 */
258
,
258
,
83
,
258
,
258
,
258
,
258
,
258
,
71
,
82
,
/* 1170 */
83
,
82
,
71
,
83
,
70
,
258
,
71
,
71
,
70
,
82
,
/* 1170 */
70
,
70
,
83
,
71
,
71
,
258
,
70
,
70
,
82
,
70
,
/* 1180 */
70
,
70
,
70
,
258
,
82
,
38
,
38
,
80
,
38
,
70
,
/* 1180 */
70
,
82
,
258
,
258
,
80
,
70
,
38
,
0
,
38
,
38
,
/* 1190 */
0
,
82
,
38
,
38
,
258
,
258
,
258
,
258
,
38
,
258
,
/* 1190 */
0
,
38
,
38
,
82
,
258
,
81
,
258
,
22
,
38
,
258
,
/* 1200 */
258
,
22
,
258
,
71
,
70
,
258
,
71
,
22
,
22
,
258
,
/* 1200 */
71
,
70
,
22
,
71
,
70
,
0
,
71
,
258
,
38
,
70
,
/* 1210 */
22
,
22
,
81
,
71
,
70
,
38
,
38
,
96
,
258
,
258
,
/* 1210 */
22
,
22
,
38
,
71
,
258
,
258
,
258
,
38
,
96
,
258
,
/* 1220 */
38
,
70
,
258
,
258
,
71
,
38
,
70
,
70
,
48
,
71
,
/* 1220 */
38
,
258
,
258
,
38
,
38
,
48
,
96
,
70
,
47
,
71
,
/* 1230 */
47
,
38
,
38
,
0
,
43
,
0
,
0
,
38
,
36
,
25
8
,
/* 1230 */
38
,
38
,
38
,
70
,
38
,
0
,
38
,
38
,
36
,
3
8
,
/* 1240 */
70
,
258
,
38
,
38
,
70
,
70
,
38
,
38
,
22
,
68
,
/* 1240 */
84
,
70
,
70
,
70
,
20
,
38
,
68
,
38
,
38
,
21
,
/* 1250 */
21
,
38
,
38
,
38
,
38
,
38
,
38
,
84
,
21
,
3
8
,
/* 1250 */
38
,
38
,
38
,
22
,
22
,
21
,
258
,
38
,
37
,
25
8
,
/* 1260 */
38
,
20
,
258
,
38
,
37
,
258
,
258
,
96
,
96
,
258
,
/* 1260 */
258
,
43
,
258
,
258
,
258
,
96
,
258
,
258
,
258
,
258
,
/* 1270 */
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
/* 1270 */
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
/* 1280 */
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
/* 1280 */
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
/* 1290 */
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
/* 1290 */
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
...
@@ -481,12 +481,11 @@ static const YYCODETYPE yy_lookahead[] = {
...
@@ -481,12 +481,11 @@ static const YYCODETYPE yy_lookahead[] = {
/* 1390 */
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
/* 1390 */
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
/* 1400 */
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
/* 1400 */
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
/* 1410 */
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
/* 1410 */
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
/* 1420 */
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
/* 1420 */
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
/* 1430 */
258
,
258
,
};
};
#define YY_SHIFT_COUNT (426)
#define YY_SHIFT_COUNT (426)
#define YY_SHIFT_MIN (0)
#define YY_SHIFT_MIN (0)
#define YY_SHIFT_MAX (12
41
)
#define YY_SHIFT_MAX (12
35
)
static
const
unsigned
short
int
yy_shift_ofst
[]
=
{
static
const
unsigned
short
int
yy_shift_ofst
[]
=
{
/* 0 */
426
,
212
,
161
,
382
,
382
,
382
,
382
,
421
,
382
,
382
,
/* 0 */
426
,
212
,
161
,
382
,
382
,
382
,
382
,
421
,
382
,
382
,
/* 10 */
151
,
513
,
517
,
444
,
513
,
513
,
513
,
513
,
513
,
513
,
/* 10 */
151
,
513
,
517
,
444
,
513
,
513
,
513
,
513
,
513
,
513
,
...
@@ -503,38 +502,38 @@ static const unsigned short int yy_shift_ofst[] = {
...
@@ -503,38 +502,38 @@ static const unsigned short int yy_shift_ofst[] = {
/* 120 */
657
,
661
,
661
,
706
,
786
,
66
,
343
,
799
,
66
,
706
,
/* 120 */
657
,
661
,
661
,
706
,
786
,
66
,
343
,
799
,
66
,
706
,
/* 130 */
66
,
825
,
17
,
17
,
17
,
17
,
17
,
17
,
17
,
17
,
/* 130 */
66
,
825
,
17
,
17
,
17
,
17
,
17
,
17
,
17
,
17
,
/* 140 */
17
,
17
,
17
,
706
,
825
,
786
,
278
,
343
,
799
,
893
,
/* 140 */
17
,
17
,
17
,
706
,
825
,
786
,
278
,
343
,
799
,
893
,
/* 150 */
769
,
778
,
804
,
769
,
778
,
804
,
782
,
785
,
801
,
809
,
/* 150 */
769
,
778
,
804
,
769
,
778
,
804
,
804
,
784
,
790
,
808
,
/* 160 */
81
7
,
343
,
935
,
844
,
805
,
807
,
816
,
906
,
17
,
778
,
/* 160 */
81
4
,
818
,
343
,
937
,
847
,
805
,
815
,
816
,
908
,
17
,
/* 170 */
804
,
804
,
778
,
804
,
868
,
343
,
799
,
306
,
278
,
343
,
/* 170 */
778
,
804
,
804
,
778
,
804
,
876
,
343
,
799
,
306
,
278
,
/* 180 */
937
,
706
,
278
,
825
,
1269
,
1269
,
1269
,
1269
,
0
,
545
,
/* 180 */
343
,
938
,
706
,
278
,
825
,
1266
,
1266
,
1266
,
1266
,
0
,
/* 190 */
5
77
,
46
,
970
,
16
,
89
,
728
,
406
,
757
,
301
,
301
,
/* 190 */
5
45
,
577
,
46
,
970
,
16
,
89
,
728
,
406
,
757
,
301
,
/* 200 */
301
,
301
,
301
,
301
,
301
,
115
,
288
,
196
,
7
,
7
,
/* 200 */
301
,
301
,
301
,
301
,
301
,
301
,
115
,
288
,
196
,
7
,
/* 210 */
7
,
7
,
374
,
605
,
610
,
701
,
453
,
580
,
632
,
506
,
/* 210 */
7
,
7
,
7
,
374
,
605
,
610
,
701
,
453
,
580
,
632
,
/* 220 */
5
41
,
714
,
715
,
718
,
647
,
590
,
451
,
729
,
74
,
749
,
/* 220 */
5
06
,
541
,
714
,
715
,
718
,
647
,
590
,
451
,
729
,
74
,
/* 230 */
7
58
,
763
,
787
,
795
,
797
,
803
,
639
,
653
,
819
,
823
,
/* 230 */
7
49
,
758
,
763
,
787
,
795
,
797
,
803
,
639
,
653
,
819
,
/* 240 */
82
4
,
826
,
828
,
837
,
751
,
1027
,
947
,
1030
,
1031
,
918
,
/* 240 */
82
3
,
824
,
826
,
828
,
837
,
751
,
1029
,
948
,
1031
,
1032
,
/* 250 */
1033
,
1034
,
1035
,
1036
,
1037
,
1038
,
1018
,
1041
,
1043
,
1044
,
/* 250 */
919
,
1034
,
1035
,
1036
,
1037
,
1038
,
1040
,
1019
,
1043
,
1044
,
/* 260 */
1045
,
1046
,
1047
,
1048
,
10
06
,
1050
,
1003
,
1052
,
1053
,
1016
,
/* 260 */
1045
,
1046
,
1047
,
1048
,
10
49
,
1007
,
1051
,
1004
,
1053
,
1054
,
/* 270 */
101
9
,
1015
,
1059
,
1060
,
1061
,
1062
,
984
,
987
,
1028
,
1029
,
/* 270 */
101
7
,
1022
,
1016
,
1060
,
1061
,
1062
,
1063
,
985
,
988
,
1028
,
/* 280 */
10
49
,
1065
,
1032
,
1039
,
1040
,
1042
,
1051
,
1054
,
1068
,
1057
,
/* 280 */
10
30
,
1050
,
1067
,
1033
,
1039
,
1041
,
1042
,
1052
,
1055
,
1069
,
/* 290 */
10
69
,
1063
,
1055
,
1072
,
1064
,
1058
,
1073
,
1066
,
1074
,
1071
,
/* 290 */
10
56
,
1070
,
1059
,
1057
,
1073
,
1064
,
1065
,
1074
,
1066
,
1075
,
/* 300 */
10
56
,
1075
,
1081
,
961
,
1083
,
1014
,
1067
,
971
,
1007
,
1008
,
/* 300 */
10
72
,
1071
,
1076
,
1082
,
962
,
1084
,
1015
,
1058
,
971
,
1006
,
/* 310 */
954
,
1026
,
1017
,
1070
,
1076
,
1077
,
1078
,
1080
,
1082
,
1079
,
/* 310 */
1009
,
954
,
1026
,
1021
,
1027
,
1068
,
1077
,
1078
,
1080
,
1081
,
/* 320 */
102
0
,
1022
,
1084
,
1023
,
957
,
1085
,
1086
,
1025
,
964
,
1087
,
/* 320 */
102
3
,
1018
,
1083
,
1024
,
958
,
1085
,
1086
,
1020
,
973
,
1079
,
/* 330 */
108
9
,
1088
,
1090
,
960
,
1098
,
1091
,
1092
,
1093
,
1094
,
1095
,
/* 330 */
108
7
,
1088
,
1089
,
964
,
1105
,
1090
,
1091
,
1092
,
1093
,
1094
,
/* 340 */
109
6
,
1103
,
982
,
1097
,
1101
,
1099
,
1104
,
1105
,
1106
,
1108
,
/* 340 */
109
5
,
1108
,
986
,
1096
,
1097
,
1100
,
1101
,
1102
,
1103
,
1106
,
/* 350 */
11
11
,
990
,
1110
,
1118
,
1100
,
995
,
1112
,
1107
,
1102
,
1109
,
/* 350 */
11
07
,
992
,
1109
,
1113
,
1098
,
998
,
1110
,
1104
,
1099
,
1111
,
/* 360 */
11
30
,
1119
,
1131
,
1132
,
1147
,
1148
,
1134
,
1135
,
1150
,
114
4
,
/* 360 */
11
12
,
1115
,
1114
,
1129
,
1148
,
1150
,
1131
,
1132
,
1151
,
113
4
,
/* 370 */
11
42
,
1154
,
1151
,
1153
,
1155
,
1157
,
1158
,
1160
,
1170
,
1024
,
/* 370 */
11
35
,
1153
,
1139
,
1142
,
1154
,
1157
,
1158
,
1160
,
1163
,
1025
,
/* 380 */
112
1
,
1171
,
1172
,
1133
,
1173
,
1156
,
1174
,
1175
,
1177
,
1178
,
/* 380 */
112
2
,
1130
,
1169
,
1133
,
1156
,
1171
,
1172
,
1173
,
1170
,
1174
,
/* 390 */
117
9
,
1180
,
1183
,
1181
,
1185
,
1182
,
1187
,
1193
,
1194
,
1199
,
/* 390 */
117
5
,
1177
,
1181
,
1178
,
1180
,
1179
,
1182
,
1185
,
1186
,
1192
,
/* 400 */
1
204
,
1205
,
1186
,
1208
,
1209
,
1213
,
1214
,
1215
,
1216
,
1217
,
/* 400 */
1
193
,
1194
,
1189
,
1196
,
1198
,
1199
,
1201
,
1207
,
1209
,
1210
,
/* 410 */
121
8
,
1221
,
1190
,
1222
,
1202
,
1191
,
1233
,
1225
,
1227
,
123
5
,
/* 410 */
121
2
,
1213
,
1187
,
1214
,
1202
,
1218
,
1190
,
1219
,
1221
,
120
5
,
/* 420 */
123
6
,
1188
,
1229
,
1189
,
1226
,
1237
,
1241
,
/* 420 */
123
5
,
1188
,
1228
,
1231
,
1232
,
1234
,
1224
,
};
};
#define YY_REDUCE_COUNT (18
7
)
#define YY_REDUCE_COUNT (18
8
)
#define YY_REDUCE_MIN (-217)
#define YY_REDUCE_MIN (-217)
#define YY_REDUCE_MAX (86
2
)
#define YY_REDUCE_MAX (86
3
)
static
const
short
yy_reduce_ofst
[]
=
{
static
const
short
yy_reduce_ofst
[]
=
{
/* 0 */
-
129
,
-
6
,
49
,
78
,
126
,
155
,
190
,
219
,
276
,
299
,
/* 0 */
-
129
,
-
6
,
49
,
78
,
126
,
155
,
190
,
219
,
276
,
299
,
/* 10 */
135
,
375
,
398
,
434
,
492
,
-
80
,
497
,
515
,
520
,
562
,
/* 10 */
135
,
375
,
398
,
434
,
492
,
-
80
,
497
,
515
,
520
,
562
,
...
@@ -551,10 +550,10 @@ static const short yy_reduce_ofst[] = {
...
@@ -551,10 +550,10 @@ static const short yy_reduce_ofst[] = {
/* 120 */
589
,
592
,
593
,
623
,
599
,
643
,
620
,
631
,
650
,
666
,
/* 120 */
589
,
592
,
593
,
623
,
599
,
643
,
620
,
631
,
650
,
666
,
/* 130 */
668
,
676
,
665
,
673
,
679
,
683
,
686
,
689
,
690
,
693
,
/* 130 */
668
,
676
,
665
,
673
,
679
,
683
,
686
,
689
,
690
,
693
,
/* 140 */
699
,
707
,
710
,
680
,
694
,
692
,
733
,
717
,
696
,
705
,
/* 140 */
699
,
707
,
710
,
680
,
694
,
692
,
733
,
717
,
696
,
705
,
/* 150 */
677
,
716
,
719
,
682
,
722
,
724
,
695
,
700
,
697
,
723
,
/* 150 */
677
,
716
,
719
,
682
,
722
,
724
,
727
,
695
,
700
,
697
,
/* 160 */
471
,
761
,
742
,
734
,
709
,
712
,
720
,
755
,
476
,
771
,
/* 160 */
723
,
471
,
762
,
743
,
736
,
709
,
712
,
725
,
756
,
476
,
/* 170 */
77
3
,
775
,
779
,
783
,
789
,
806
,
792
,
818
,
827
,
811
,
/* 170 */
77
2
,
775
,
779
,
782
,
780
,
791
,
806
,
794
,
822
,
829
,
/* 180 */
8
21
,
836
,
841
,
849
,
842
,
843
,
852
,
862
,
/* 180 */
8
17
,
833
,
835
,
841
,
849
,
843
,
845
,
853
,
863
,
};
};
static
const
YYACTIONTYPE
yy_default
[]
=
{
static
const
YYACTIONTYPE
yy_default
[]
=
{
/* 0 */
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 0 */
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
...
@@ -572,23 +571,23 @@ static const YYACTIONTYPE yy_default[] = {
...
@@ -572,23 +571,23 @@ static const YYACTIONTYPE yy_default[] = {
/* 120 */
1166
,
1163
,
1163
,
996
,
996
,
1049
,
996
,
996
,
1049
,
996
,
/* 120 */
1166
,
1163
,
1163
,
996
,
996
,
1049
,
996
,
996
,
1049
,
996
,
/* 130 */
1049
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 130 */
1049
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 140 */
996
,
996
,
996
,
996
,
996
,
996
,
1047
,
996
,
996
,
996
,
/* 140 */
996
,
996
,
996
,
996
,
996
,
996
,
1047
,
996
,
996
,
996
,
/* 150 */
1297
,
1295
,
996
,
1297
,
1295
,
996
,
1309
,
1305
,
1288
,
1286
,
/* 150 */
1297
,
1295
,
996
,
1297
,
1295
,
996
,
996
,
1309
,
1305
,
1288
,
/* 160 */
12
72
,
996
,
996
,
996
,
1333
,
1321
,
1317
,
996
,
996
,
1295
,
/* 160 */
12
86
,
1272
,
996
,
996
,
996
,
1333
,
1321
,
1317
,
996
,
996
,
/* 170 */
996
,
996
,
1295
,
996
,
1174
,
996
,
996
,
996
,
1047
,
996
,
/* 170 */
1295
,
996
,
996
,
1295
,
996
,
1174
,
996
,
996
,
996
,
1047
,
/* 180 */
1101
,
996
,
1047
,
996
,
1135
,
1135
,
1050
,
1001
,
996
,
996
,
/* 180 */
996
,
1101
,
996
,
1047
,
996
,
1135
,
1135
,
1050
,
1001
,
996
,
/* 190 */
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
1227
,
1308
,
/* 190 */
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
1227
,
/* 200 */
130
7
,
1226
,
1232
,
1231
,
1230
,
996
,
996
,
996
,
1221
,
1222
,
/* 200 */
130
8
,
1307
,
1226
,
1232
,
1231
,
1230
,
996
,
996
,
996
,
1221
,
/* 210 */
122
0
,
1219
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 210 */
122
2
,
1220
,
1219
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 220 */
996
,
996
,
996
,
1256
,
996
,
1318
,
1322
,
996
,
996
,
996
,
/* 220 */
996
,
996
,
996
,
996
,
1256
,
996
,
1318
,
1322
,
996
,
996
,
/* 230 */
1206
,
99
6
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 230 */
996
,
120
6
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 240 */
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 240 */
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 250 */
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 250 */
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 260 */
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 260 */
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 270 */
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 270 */
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 280 */
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 280 */
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 290 */
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 290 */
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 300 */
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
1279
,
128
9
,
/* 300 */
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
127
9
,
/* 310 */
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 310 */
1289
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 320 */
996
,
1206
,
996
,
1306
,
996
,
1265
,
1261
,
996
,
996
,
1257
,
/* 320 */
996
,
1206
,
996
,
1306
,
996
,
1265
,
1261
,
996
,
996
,
1257
,
/* 330 */
996
,
996
,
1316
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 330 */
996
,
996
,
1316
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 340 */
996
,
1251
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 340 */
996
,
1251
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
...
@@ -1263,7 +1262,7 @@ static const char *const yyRuleName[] = {
...
@@ -1263,7 +1262,7 @@ static const char *const yyRuleName[] = {
/* 289 */
"partition_by_clause_opt ::="
,
/* 289 */
"partition_by_clause_opt ::="
,
/* 290 */
"partition_by_clause_opt ::= PARTITION BY expression_list"
,
/* 290 */
"partition_by_clause_opt ::= PARTITION BY expression_list"
,
/* 291 */
"twindow_clause_opt ::="
,
/* 291 */
"twindow_clause_opt ::="
,
/* 292 */
"twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA
NK_INTEGER
NK_RP"
,
/* 292 */
"twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA
duration_literal
NK_RP"
,
/* 293 */
"twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP"
,
/* 293 */
"twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP"
,
/* 294 */
"twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt"
,
/* 294 */
"twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt"
,
/* 295 */
"twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt"
,
/* 295 */
"twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt"
,
...
@@ -2163,7 +2162,7 @@ static const struct {
...
@@ -2163,7 +2162,7 @@ static const struct {
{
240
,
0
},
/* (289) partition_by_clause_opt ::= */
{
240
,
0
},
/* (289) partition_by_clause_opt ::= */
{
240
,
-
3
},
/* (290) partition_by_clause_opt ::= PARTITION BY expression_list */
{
240
,
-
3
},
/* (290) partition_by_clause_opt ::= PARTITION BY expression_list */
{
241
,
0
},
/* (291) twindow_clause_opt ::= */
{
241
,
0
},
/* (291) twindow_clause_opt ::= */
{
241
,
-
6
},
/* (292) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA
NK_INTEGER
NK_RP */
{
241
,
-
6
},
/* (292) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA
duration_literal
NK_RP */
{
241
,
-
4
},
/* (293) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */
{
241
,
-
4
},
/* (293) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */
{
241
,
-
6
},
/* (294) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */
{
241
,
-
6
},
/* (294) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */
{
241
,
-
8
},
/* (295) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */
{
241
,
-
8
},
/* (295) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */
...
@@ -3230,8 +3229,8 @@ static YYACTIONTYPE yy_reduce(
...
@@ -3230,8 +3229,8 @@ static YYACTIONTYPE yy_reduce(
case
317
:
/* order_by_clause_opt ::= ORDER BY sort_specification_list */
yytestcase
(
yyruleno
==
317
);
case
317
:
/* order_by_clause_opt ::= ORDER BY sort_specification_list */
yytestcase
(
yyruleno
==
317
);
{
yymsp
[
-
2
].
minor
.
yy136
=
yymsp
[
0
].
minor
.
yy136
;
}
{
yymsp
[
-
2
].
minor
.
yy136
=
yymsp
[
0
].
minor
.
yy136
;
}
break
;
break
;
case
292
:
/* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA
NK_INTEGER
NK_RP */
case
292
:
/* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA
duration_literal
NK_RP */
{
yymsp
[
-
5
].
minor
.
yy140
=
createSessionWindowNode
(
pCxt
,
releaseRawExprNode
(
pCxt
,
yymsp
[
-
3
].
minor
.
yy140
),
&
yymsp
[
-
1
].
minor
.
yy0
);
}
{
yymsp
[
-
5
].
minor
.
yy140
=
createSessionWindowNode
(
pCxt
,
releaseRawExprNode
(
pCxt
,
yymsp
[
-
3
].
minor
.
yy140
),
releaseRawExprNode
(
pCxt
,
yymsp
[
-
1
].
minor
.
yy140
)
);
}
break
;
break
;
case
293
:
/* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */
case
293
:
/* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */
{
yymsp
[
-
3
].
minor
.
yy140
=
createStateWindowNode
(
pCxt
,
releaseRawExprNode
(
pCxt
,
yymsp
[
-
1
].
minor
.
yy140
));
}
{
yymsp
[
-
3
].
minor
.
yy140
=
createStateWindowNode
(
pCxt
,
releaseRawExprNode
(
pCxt
,
yymsp
[
-
1
].
minor
.
yy140
));
}
...
...
source/libs/parser/test/parserAstTest.cpp
浏览文件 @
3e455e37
...
@@ -44,6 +44,9 @@ protected:
...
@@ -44,6 +44,9 @@ protected:
query_
=
nullptr
;
query_
=
nullptr
;
bool
res
=
runImpl
(
parseCode
,
translateCode
);
bool
res
=
runImpl
(
parseCode
,
translateCode
);
qDestroyQuery
(
query_
);
qDestroyQuery
(
query_
);
if
(
!
res
)
{
dump
();
}
return
res
;
return
res
;
}
}
...
@@ -53,24 +56,38 @@ private:
...
@@ -53,24 +56,38 @@ private:
bool
runImpl
(
int32_t
parseCode
,
int32_t
translateCode
)
{
bool
runImpl
(
int32_t
parseCode
,
int32_t
translateCode
)
{
int32_t
code
=
doParse
(
&
cxt_
,
&
query_
);
int32_t
code
=
doParse
(
&
cxt_
,
&
query_
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
cout
<<
"sql:["
<<
cxt_
.
pSql
<<
"] parser code:"
<<
tstrerror
(
code
)
<<
", msg:"
<<
errMagBuf_
<<
endl
;
parseErrStr_
=
string
(
"code:"
)
+
tstrerror
(
code
)
+
string
(
", msg:"
)
+
errMagBuf_
;
return
(
TSDB_CODE_SUCCESS
!
=
parseCode
);
return
(
terrno
=
=
parseCode
);
}
}
if
(
TSDB_CODE_SUCCESS
!=
parseCode
)
{
if
(
TSDB_CODE_SUCCESS
!=
parseCode
)
{
return
false
;
return
false
;
}
}
string
parserStr
=
toString
(
query_
->
pRoot
);
parsedAstStr_
=
toString
(
query_
->
pRoot
);
code
=
doTranslate
(
&
cxt_
,
query_
);
code
=
doTranslate
(
&
cxt_
,
query_
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
cout
<<
"sql:["
<<
cxt_
.
pSql
<<
"] translate code:"
<<
code
<<
", "
<<
translateCode
<<
", msg:"
<<
errMagBuf_
<<
endl
;
translateErrStr_
=
string
(
"code:"
)
+
tstrerror
(
code
)
+
string
(
", msg:"
)
+
errMagBuf_
;
return
(
code
==
translateCode
);
return
(
terrno
==
translateCode
);
}
translatedAstStr_
=
toString
(
query_
->
pRoot
);
return
(
TSDB_CODE_SUCCESS
==
translateCode
);
}
}
void
dump
()
{
cout
<<
"input sql : ["
<<
cxt_
.
pSql
<<
"]"
<<
endl
;
cout
<<
"input sql : ["
<<
cxt_
.
pSql
<<
"]"
<<
endl
;
cout
<<
"parser output: "
<<
endl
;
if
(
!
parseErrStr_
.
empty
())
{
cout
<<
parserStr
<<
endl
;
cout
<<
"parse error: "
<<
parseErrStr_
<<
endl
;
}
if
(
!
parsedAstStr_
.
empty
())
{
cout
<<
"parse output: "
<<
endl
;
cout
<<
parsedAstStr_
<<
endl
;
}
if
(
!
translateErrStr_
.
empty
())
{
cout
<<
"translate error: "
<<
translateErrStr_
<<
endl
;
}
if
(
!
translatedAstStr_
.
empty
())
{
cout
<<
"translate output: "
<<
endl
;
cout
<<
"translate output: "
<<
endl
;
cout
<<
toString
(
query_
->
pRoot
)
<<
endl
;
cout
<<
translatedAstStr_
<<
endl
;
return
(
TSDB_CODE_SUCCESS
==
translateCode
);
}
}
}
string
toString
(
const
SNode
*
pRoot
,
bool
format
=
false
)
{
string
toString
(
const
SNode
*
pRoot
,
bool
format
=
false
)
{
...
@@ -91,6 +108,10 @@ private:
...
@@ -91,6 +108,10 @@ private:
memset
(
errMagBuf_
,
0
,
max_err_len
);
memset
(
errMagBuf_
,
0
,
max_err_len
);
cxt_
.
pMsg
=
errMagBuf_
;
cxt_
.
pMsg
=
errMagBuf_
;
cxt_
.
msgLen
=
max_err_len
;
cxt_
.
msgLen
=
max_err_len
;
parseErrStr_
.
clear
();
parsedAstStr_
.
clear
();
translateErrStr_
.
clear
();
translatedAstStr_
.
clear
();
}
}
string
acctId_
;
string
acctId_
;
...
@@ -99,8 +120,50 @@ private:
...
@@ -99,8 +120,50 @@ private:
string
sqlBuf_
;
string
sqlBuf_
;
SParseContext
cxt_
;
SParseContext
cxt_
;
SQuery
*
query_
;
SQuery
*
query_
;
string
parseErrStr_
;
string
parsedAstStr_
;
string
translateErrStr_
;
string
translatedAstStr_
;
};
};
TEST_F
(
ParserTest
,
createAccount
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"create account ac_wxy pass '123456'"
);
ASSERT_TRUE
(
run
(
TSDB_CODE_PAR_EXPRIE_STATEMENT
));
}
TEST_F
(
ParserTest
,
alterAccount
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"alter account ac_wxy pass '123456'"
);
ASSERT_TRUE
(
run
(
TSDB_CODE_PAR_EXPRIE_STATEMENT
));
}
TEST_F
(
ParserTest
,
createUser
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"create user wxy pass '123456'"
);
ASSERT_TRUE
(
run
());
}
TEST_F
(
ParserTest
,
alterUser
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"alter user wxy pass '123456'"
);
ASSERT_TRUE
(
run
());
bind
(
"alter user wxy privilege 'write'"
);
ASSERT_TRUE
(
run
());
}
TEST_F
(
ParserTest
,
dropUser
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"drop user wxy"
);
ASSERT_TRUE
(
run
());
}
TEST_F
(
ParserTest
,
selectSimple
)
{
TEST_F
(
ParserTest
,
selectSimple
)
{
setDatabase
(
"root"
,
"test"
);
setDatabase
(
"root"
,
"test"
);
...
@@ -295,12 +358,6 @@ TEST_F(ParserTest, selectSemanticError) {
...
@@ -295,12 +358,6 @@ TEST_F(ParserTest, selectSemanticError) {
ASSERT_TRUE
(
run
(
TSDB_CODE_SUCCESS
,
TSDB_CODE_PAR_NOT_SELECTED_EXPRESSION
));
ASSERT_TRUE
(
run
(
TSDB_CODE_SUCCESS
,
TSDB_CODE_PAR_NOT_SELECTED_EXPRESSION
));
}
}
TEST_F
(
ParserTest
,
createUser
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"create user wxy pass '123456'"
);
ASSERT_TRUE
(
run
());
}
TEST_F
(
ParserTest
,
showUsers
)
{
TEST_F
(
ParserTest
,
showUsers
)
{
setDatabase
(
"root"
,
"test"
);
setDatabase
(
"root"
,
"test"
);
...
@@ -309,12 +366,7 @@ TEST_F(ParserTest, showUsers) {
...
@@ -309,12 +366,7 @@ TEST_F(ParserTest, showUsers) {
ASSERT_TRUE
(
run
());
ASSERT_TRUE
(
run
());
}
}
TEST_F
(
ParserTest
,
alterAccount
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"alter account ac_wxy pass '123456'"
);
ASSERT_TRUE
(
run
(
TSDB_CODE_PAR_EXPRIE_STATEMENT
));
}
TEST_F
(
ParserTest
,
createDnode
)
{
TEST_F
(
ParserTest
,
createDnode
)
{
setDatabase
(
"root"
,
"test"
);
setDatabase
(
"root"
,
"test"
);
...
...
source/libs/planner/inc/planInt.h
浏览文件 @
3e455e37
...
@@ -56,9 +56,10 @@ extern "C" {
...
@@ -56,9 +56,10 @@ extern "C" {
#define planTrace(param, ...) qTrace("PLAN: " param, __VA_ARGS__)
#define planTrace(param, ...) qTrace("PLAN: " param, __VA_ARGS__)
int32_t
createLogicPlan
(
SPlanContext
*
pCxt
,
SLogicNode
**
pLogicNode
);
int32_t
createLogicPlan
(
SPlanContext
*
pCxt
,
SLogicNode
**
pLogicNode
);
int32_t
optimize
(
SPlanContext
*
pCxt
,
SLogicNode
*
pLogicNode
);
int32_t
optimizeLogicPlan
(
SPlanContext
*
pCxt
,
SLogicNode
*
pLogicNode
);
int32_t
applySplitRule
(
SSubLogicPlan
*
pSubplan
);
int32_t
splitLogicPlan
(
SPlanContext
*
pCxt
,
SLogicNode
*
pLogicNode
,
SLogicSubplan
**
pLogicSubplan
);
int32_t
createPhysiPlan
(
SPlanContext
*
pCxt
,
SLogicNode
*
pLogicNode
,
SQueryPlan
**
pPlan
,
SArray
*
pExecNodeList
);
int32_t
scaleOutLogicPlan
(
SPlanContext
*
pCxt
,
SLogicSubplan
*
pLogicSubplan
,
SQueryLogicPlan
**
pLogicPlan
);
int32_t
createPhysiPlan
(
SPlanContext
*
pCxt
,
SQueryLogicPlan
*
pLogicPlan
,
SQueryPlan
**
pPlan
,
SArray
*
pExecNodeList
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/libs/planner/src/planLogicCreater.c
浏览文件 @
3e455e37
...
@@ -411,6 +411,38 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect,
...
@@ -411,6 +411,38 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect,
return
code
;
return
code
;
}
}
static
int32_t
createWindowLogicNodeFinalize
(
SLogicPlanContext
*
pCxt
,
SSelectStmt
*
pSelect
,
SWindowLogicNode
*
pWindow
,
SLogicNode
**
pLogicNode
)
{
int32_t
code
=
nodesCollectFuncs
(
pSelect
,
fmIsAggFunc
,
&
pWindow
->
pFuncs
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
rewriteExpr
(
pWindow
->
pFuncs
,
pSelect
,
SQL_CLAUSE_WINDOW
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createColumnByRewriteExps
(
pCxt
,
pWindow
->
pFuncs
,
&
pWindow
->
node
.
pTargets
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pLogicNode
=
(
SLogicNode
*
)
pWindow
;
}
else
{
nodesDestroyNode
(
pWindow
);
}
return
code
;
}
static
int32_t
createWindowLogicNodeBySession
(
SLogicPlanContext
*
pCxt
,
SSessionWindowNode
*
pSession
,
SSelectStmt
*
pSelect
,
SLogicNode
**
pLogicNode
)
{
SWindowLogicNode
*
pWindow
=
nodesMakeNode
(
QUERY_NODE_LOGIC_PLAN_WINDOW
);
if
(
NULL
==
pWindow
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pWindow
->
winType
=
WINDOW_TYPE_SESSION
;
pWindow
->
sessionGap
=
((
SValueNode
*
)
pSession
->
pGap
)
->
datum
.
i
;
return
createWindowLogicNodeFinalize
(
pCxt
,
pSelect
,
pWindow
,
pLogicNode
);
}
static
int32_t
createWindowLogicNodeByInterval
(
SLogicPlanContext
*
pCxt
,
SIntervalWindowNode
*
pInterval
,
SSelectStmt
*
pSelect
,
SLogicNode
**
pLogicNode
)
{
static
int32_t
createWindowLogicNodeByInterval
(
SLogicPlanContext
*
pCxt
,
SIntervalWindowNode
*
pInterval
,
SSelectStmt
*
pSelect
,
SLogicNode
**
pLogicNode
)
{
SWindowLogicNode
*
pWindow
=
nodesMakeNode
(
QUERY_NODE_LOGIC_PLAN_WINDOW
);
SWindowLogicNode
*
pWindow
=
nodesMakeNode
(
QUERY_NODE_LOGIC_PLAN_WINDOW
);
if
(
NULL
==
pWindow
)
{
if
(
NULL
==
pWindow
)
{
...
@@ -424,34 +456,15 @@ static int32_t createWindowLogicNodeByInterval(SLogicPlanContext* pCxt, SInterva
...
@@ -424,34 +456,15 @@ static int32_t createWindowLogicNodeByInterval(SLogicPlanContext* pCxt, SInterva
pWindow
->
sliding
=
(
NULL
!=
pInterval
->
pSliding
?
((
SValueNode
*
)
pInterval
->
pSliding
)
->
datum
.
i
:
pWindow
->
interval
);
pWindow
->
sliding
=
(
NULL
!=
pInterval
->
pSliding
?
((
SValueNode
*
)
pInterval
->
pSliding
)
->
datum
.
i
:
pWindow
->
interval
);
pWindow
->
slidingUnit
=
(
NULL
!=
pInterval
->
pSliding
?
((
SValueNode
*
)
pInterval
->
pSliding
)
->
unit
:
pWindow
->
intervalUnit
);
pWindow
->
slidingUnit
=
(
NULL
!=
pInterval
->
pSliding
?
((
SValueNode
*
)
pInterval
->
pSliding
)
->
unit
:
pWindow
->
intervalUnit
);
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
(
NULL
!=
pInterval
->
pFill
)
{
if
(
NULL
!=
pInterval
->
pFill
)
{
pWindow
->
pFill
=
nodesCloneNode
(
pInterval
->
pFill
);
pWindow
->
pFill
=
nodesCloneNode
(
pInterval
->
pFill
);
if
(
NULL
==
pWindow
->
pFill
)
{
if
(
NULL
==
pWindow
->
pFill
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesCollectFuncs
(
pSelect
,
fmIsAggFunc
,
&
pWindow
->
pFuncs
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
rewriteExpr
(
pWindow
->
pFuncs
,
pSelect
,
SQL_CLAUSE_WINDOW
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createColumnByRewriteExps
(
pCxt
,
pWindow
->
pFuncs
,
&
pWindow
->
node
.
pTargets
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pLogicNode
=
(
SLogicNode
*
)
pWindow
;
}
else
{
nodesDestroyNode
(
pWindow
);
nodesDestroyNode
(
pWindow
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
}
return
c
ode
;
return
c
reateWindowLogicNodeFinalize
(
pCxt
,
pSelect
,
pWindow
,
pLogicNode
)
;
}
}
static
int32_t
createWindowLogicNode
(
SLogicPlanContext
*
pCxt
,
SSelectStmt
*
pSelect
,
SLogicNode
**
pLogicNode
)
{
static
int32_t
createWindowLogicNode
(
SLogicPlanContext
*
pCxt
,
SSelectStmt
*
pSelect
,
SLogicNode
**
pLogicNode
)
{
...
@@ -460,6 +473,8 @@ static int32_t createWindowLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele
...
@@ -460,6 +473,8 @@ static int32_t createWindowLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele
}
}
switch
(
nodeType
(
pSelect
->
pWindow
))
{
switch
(
nodeType
(
pSelect
->
pWindow
))
{
case
QUERY_NODE_SESSION_WINDOW
:
return
createWindowLogicNodeBySession
(
pCxt
,
(
SSessionWindowNode
*
)
pSelect
->
pWindow
,
pSelect
,
pLogicNode
);
case
QUERY_NODE_INTERVAL_WINDOW
:
case
QUERY_NODE_INTERVAL_WINDOW
:
return
createWindowLogicNodeByInterval
(
pCxt
,
(
SIntervalWindowNode
*
)
pSelect
->
pWindow
,
pSelect
,
pLogicNode
);
return
createWindowLogicNodeByInterval
(
pCxt
,
(
SIntervalWindowNode
*
)
pSelect
->
pWindow
,
pSelect
,
pLogicNode
);
default:
default:
...
...
source/libs/planner/src/planOptimizer.c
0 → 100644
浏览文件 @
3e455e37
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "planInt.h"
int32_t
optimizeLogicPlan
(
SPlanContext
*
pCxt
,
SLogicNode
*
pLogicNode
)
{
return
TSDB_CODE_SUCCESS
;
}
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
3e455e37
...
@@ -28,7 +28,6 @@ typedef struct SPhysiPlanContext {
...
@@ -28,7 +28,6 @@ typedef struct SPhysiPlanContext {
int16_t
nextDataBlockId
;
int16_t
nextDataBlockId
;
SArray
*
pLocationHelper
;
SArray
*
pLocationHelper
;
SArray
*
pExecNodeList
;
SArray
*
pExecNodeList
;
int32_t
subplanId
;
}
SPhysiPlanContext
;
}
SPhysiPlanContext
;
static
int32_t
getSlotKey
(
SNode
*
pNode
,
char
*
pKey
)
{
static
int32_t
getSlotKey
(
SNode
*
pNode
,
char
*
pKey
)
{
...
@@ -124,35 +123,52 @@ static EDealRes doSetSlotId(SNode* pNode, void* pContext) {
...
@@ -124,35 +123,52 @@ static EDealRes doSetSlotId(SNode* pNode, void* pContext) {
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
static
SNode
*
setNodeSlotId
(
SPhysiPlanContext
*
pCxt
,
int16_t
leftDataBlockId
,
int16_t
rightDataBlockId
,
SNode
*
pNode
)
{
static
int32_t
setNodeSlotId
(
SPhysiPlanContext
*
pCxt
,
int16_t
leftDataBlockId
,
int16_t
rightDataBlockId
,
SNode
*
pNode
,
SNode
**
pOutput
)
{
SNode
*
pRes
=
nodesCloneNode
(
pNode
);
SNode
*
pRes
=
nodesCloneNode
(
pNode
);
CHECK_ALLOC
(
pRes
,
NULL
);
if
(
NULL
==
pRes
)
{
SSetSlotIdCxt
cxt
=
{
.
errCode
=
TSDB_CODE_SUCCESS
,
.
pLeftHash
=
taosArrayGetP
(
pCxt
->
pLocationHelper
,
leftDataBlockId
),
return
TSDB_CODE_OUT_OF_MEMORY
;
.
pRightHash
=
(
rightDataBlockId
<
0
?
NULL
:
taosArrayGetP
(
pCxt
->
pLocationHelper
,
rightDataBlockId
))
};
}
SSetSlotIdCxt
cxt
=
{
.
errCode
=
TSDB_CODE_SUCCESS
,
.
pLeftHash
=
taosArrayGetP
(
pCxt
->
pLocationHelper
,
leftDataBlockId
),
.
pRightHash
=
(
rightDataBlockId
<
0
?
NULL
:
taosArrayGetP
(
pCxt
->
pLocationHelper
,
rightDataBlockId
))
};
nodesWalkNode
(
pRes
,
doSetSlotId
,
&
cxt
);
nodesWalkNode
(
pRes
,
doSetSlotId
,
&
cxt
);
if
(
TSDB_CODE_SUCCESS
!=
cxt
.
errCode
)
{
if
(
TSDB_CODE_SUCCESS
!=
cxt
.
errCode
)
{
nodesDestroyNode
(
pRes
);
nodesDestroyNode
(
pRes
);
return
NULL
;
return
cxt
.
errCode
;
}
}
return
pRes
;
*
pOutput
=
pRes
;
return
TSDB_CODE_SUCCESS
;
}
}
static
SNodeList
*
setListSlotId
(
SPhysiPlanContext
*
pCxt
,
int16_t
leftDataBlockId
,
int16_t
rightDataBlockId
,
SNodeList
*
pLis
t
)
{
static
int32_t
setListSlotId
(
SPhysiPlanContext
*
pCxt
,
int16_t
leftDataBlockId
,
int16_t
rightDataBlockId
,
SNodeList
*
pList
,
SNodeList
**
pOutpu
t
)
{
SNodeList
*
pRes
=
nodesCloneList
(
pList
);
SNodeList
*
pRes
=
nodesCloneList
(
pList
);
CHECK_ALLOC
(
pRes
,
NULL
);
if
(
NULL
==
pRes
)
{
SSetSlotIdCxt
cxt
=
{
.
errCode
=
TSDB_CODE_SUCCESS
,
.
pLeftHash
=
taosArrayGetP
(
pCxt
->
pLocationHelper
,
leftDataBlockId
),
return
TSDB_CODE_OUT_OF_MEMORY
;
.
pRightHash
=
(
rightDataBlockId
<
0
?
NULL
:
taosArrayGetP
(
pCxt
->
pLocationHelper
,
rightDataBlockId
))
};
}
SSetSlotIdCxt
cxt
=
{
.
errCode
=
TSDB_CODE_SUCCESS
,
.
pLeftHash
=
taosArrayGetP
(
pCxt
->
pLocationHelper
,
leftDataBlockId
),
.
pRightHash
=
(
rightDataBlockId
<
0
?
NULL
:
taosArrayGetP
(
pCxt
->
pLocationHelper
,
rightDataBlockId
))
};
nodesWalkList
(
pRes
,
doSetSlotId
,
&
cxt
);
nodesWalkList
(
pRes
,
doSetSlotId
,
&
cxt
);
if
(
TSDB_CODE_SUCCESS
!=
cxt
.
errCode
)
{
if
(
TSDB_CODE_SUCCESS
!=
cxt
.
errCode
)
{
nodesDestroyList
(
pRes
);
nodesDestroyList
(
pRes
);
return
NULL
;
return
cxt
.
errCode
;
}
}
return
pRes
;
*
pOutput
=
pRes
;
return
TSDB_CODE_SUCCESS
;
}
}
static
SPhysiNode
*
makePhysiNode
(
SPhysiPlanContext
*
pCxt
,
ENodeType
type
)
{
static
SPhysiNode
*
makePhysiNode
(
SPhysiPlanContext
*
pCxt
,
ENodeType
type
)
{
SPhysiNode
*
pPhysiNode
=
(
SPhysiNode
*
)
nodesMakeNode
(
type
);
SPhysiNode
*
pPhysiNode
=
(
SPhysiNode
*
)
nodesMakeNode
(
type
);
CHECK_ALLOC
(
pPhysiNode
,
NULL
);
if
(
NULL
==
pPhysiNode
)
{
return
NULL
;
}
pPhysiNode
->
pOutputDataBlockDesc
=
nodesMakeNode
(
QUERY_NODE_DATABLOCK_DESC
);
pPhysiNode
->
pOutputDataBlockDesc
=
nodesMakeNode
(
QUERY_NODE_DATABLOCK_DESC
);
if
(
NULL
==
pPhysiNode
->
pOutputDataBlockDesc
)
{
if
(
NULL
==
pPhysiNode
->
pOutputDataBlockDesc
)
{
nodesDestroyNode
(
pPhysiNode
);
nodesDestroyNode
(
pPhysiNode
);
...
@@ -165,8 +181,7 @@ static SPhysiNode* makePhysiNode(SPhysiPlanContext* pCxt, ENodeType type) {
...
@@ -165,8 +181,7 @@ static SPhysiNode* makePhysiNode(SPhysiPlanContext* pCxt, ENodeType type) {
static
int32_t
setConditionsSlotId
(
SPhysiPlanContext
*
pCxt
,
const
SLogicNode
*
pLogicNode
,
SPhysiNode
*
pPhysiNode
)
{
static
int32_t
setConditionsSlotId
(
SPhysiPlanContext
*
pCxt
,
const
SLogicNode
*
pLogicNode
,
SPhysiNode
*
pPhysiNode
)
{
if
(
NULL
!=
pLogicNode
->
pConditions
)
{
if
(
NULL
!=
pLogicNode
->
pConditions
)
{
pPhysiNode
->
pConditions
=
setNodeSlotId
(
pCxt
,
pPhysiNode
->
pOutputDataBlockDesc
->
dataBlockId
,
-
1
,
pLogicNode
->
pConditions
);
return
setNodeSlotId
(
pCxt
,
pPhysiNode
->
pOutputDataBlockDesc
->
dataBlockId
,
-
1
,
pLogicNode
->
pConditions
,
&
pPhysiNode
->
pConditions
);
CHECK_ALLOC
(
pPhysiNode
->
pConditions
,
TSDB_CODE_OUT_OF_MEMORY
);
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -223,24 +238,34 @@ static int32_t createScanCols(SPhysiPlanContext* pCxt, SScanPhysiNode* pScanPhys
...
@@ -223,24 +238,34 @@ static int32_t createScanCols(SPhysiPlanContext* pCxt, SScanPhysiNode* pScanPhys
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
initScanPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SScanLogicNode
*
pScanLogicNode
,
SScanPhysiNode
*
pScanPhysi
Node
)
{
static
int32_t
createScanPhysiNodeFinalize
(
SPhysiPlanContext
*
pCxt
,
SScanLogicNode
*
pScanLogicNode
,
SScanPhysiNode
*
pScanPhysiNode
,
SPhysiNode
**
pPhy
Node
)
{
CHECK_CODE
(
createScanCols
(
pCxt
,
pScanPhysiNode
,
pScanLogicNode
->
pScanCols
),
TSDB_CODE_OUT_OF_MEMORY
);
int32_t
code
=
createScanCols
(
pCxt
,
pScanPhysiNode
,
pScanLogicNode
->
pScanCols
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
// Data block describe also needs to be set without scanning column, such as SELECT COUNT(*) FROM t
// Data block describe also needs to be set without scanning column, such as SELECT COUNT(*) FROM t
CHECK_CODE
(
addDataBlockDesc
(
pCxt
,
pScanPhysiNode
->
pScanCols
,
pScanPhysiNode
->
node
.
pOutputDataBlockDesc
),
TSDB_CODE_OUT_OF_MEMORY
);
code
=
addDataBlockDesc
(
pCxt
,
pScanPhysiNode
->
pScanCols
,
pScanPhysiNode
->
node
.
pOutputDataBlockDesc
);
}
CHECK_CODE
(
setConditionsSlotId
(
pCxt
,
(
const
SLogicNode
*
)
pScanLogicNode
,
(
SPhysiNode
*
)
pScanPhysiNode
),
TSDB_CODE_OUT_OF_MEMORY
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
setConditionsSlotId
(
pCxt
,
(
const
SLogicNode
*
)
pScanLogicNode
,
(
SPhysiNode
*
)
pScanPhysiNode
);
CHECK_CODE
(
setSlotOutput
(
pCxt
,
pScanLogicNode
->
node
.
pTargets
,
pScanPhysiNode
->
node
.
pOutputDataBlockDesc
),
TSDB_CODE_OUT_OF_MEMORY
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
setSlotOutput
(
pCxt
,
pScanLogicNode
->
node
.
pTargets
,
pScanPhysiNode
->
node
.
pOutputDataBlockDesc
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pScanPhysiNode
->
uid
=
pScanLogicNode
->
pMeta
->
uid
;
pScanPhysiNode
->
uid
=
pScanLogicNode
->
pMeta
->
uid
;
pScanPhysiNode
->
tableType
=
pScanLogicNode
->
pMeta
->
tableType
;
pScanPhysiNode
->
tableType
=
pScanLogicNode
->
pMeta
->
tableType
;
pScanPhysiNode
->
order
=
TSDB_ORDER_ASC
;
pScanPhysiNode
->
order
=
TSDB_ORDER_ASC
;
pScanPhysiNode
->
count
=
1
;
pScanPhysiNode
->
count
=
1
;
pScanPhysiNode
->
reverse
=
0
;
pScanPhysiNode
->
reverse
=
0
;
memcpy
(
&
pScanPhysiNode
->
tableName
,
&
pScanLogicNode
->
tableName
,
sizeof
(
SName
));
memcpy
(
&
pScanPhysiNode
->
tableName
,
&
pScanLogicNode
->
tableName
,
sizeof
(
SName
));
}
return
TSDB_CODE_SUCCESS
;
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pPhyNode
=
(
SPhysiNode
*
)
pScanPhysiNode
;
}
else
{
nodesDestroyNode
(
pScanPhysiNode
);
}
return
code
;
}
}
static
void
vgroupInfoToNodeAddr
(
const
SVgroupInfo
*
vg
,
SQueryNodeAddr
*
pNodeAddr
)
{
static
void
vgroupInfoToNodeAddr
(
const
SVgroupInfo
*
vg
,
SQueryNodeAddr
*
pNodeAddr
)
{
...
@@ -248,30 +273,36 @@ static void vgroupInfoToNodeAddr(const SVgroupInfo* vg, SQueryNodeAddr* pNodeAdd
...
@@ -248,30 +273,36 @@ static void vgroupInfoToNodeAddr(const SVgroupInfo* vg, SQueryNodeAddr* pNodeAdd
pNodeAddr
->
epSet
=
vg
->
epSet
;
pNodeAddr
->
epSet
=
vg
->
epSet
;
}
}
static
SPhysiNode
*
createTagScanPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SScanLogicNode
*
pScanLogic
Node
)
{
static
int32_t
createTagScanPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SScanLogicNode
*
pScanLogicNode
,
SPhysiNode
**
pPhy
Node
)
{
STagScanPhysiNode
*
pTagScan
=
(
STagScanPhysiNode
*
)
makePhysiNode
(
pCxt
,
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN
);
STagScanPhysiNode
*
pTagScan
=
(
STagScanPhysiNode
*
)
makePhysiNode
(
pCxt
,
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN
);
CHECK_ALLOC
(
pTagScan
,
NULL
);
if
(
NULL
==
pTagScan
)
{
CHECK_CODE
(
initScanPhysiNode
(
pCxt
,
pScanLogicNode
,
(
SScanPhysiNode
*
)
pTagScan
),
(
SPhysiNode
*
)
pTagScan
);
return
TSDB_CODE_OUT_OF_MEMORY
;
return
(
SPhysiNode
*
)
pTagScan
;
}
return
createScanPhysiNodeFinalize
(
pCxt
,
pScanLogicNode
,
(
SScanPhysiNode
*
)
pTagScan
,
pPhyNode
);
}
}
static
SPhysiNode
*
createTableScanPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SSubplan
*
pSubplan
,
SScanLogicNode
*
pScanLogic
Node
)
{
static
int32_t
createTableScanPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SSubplan
*
pSubplan
,
SScanLogicNode
*
pScanLogicNode
,
SPhysiNode
**
pPhy
Node
)
{
STableScanPhysiNode
*
pTableScan
=
(
STableScanPhysiNode
*
)
makePhysiNode
(
pCxt
,
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
);
STableScanPhysiNode
*
pTableScan
=
(
STableScanPhysiNode
*
)
makePhysiNode
(
pCxt
,
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
);
CHECK_ALLOC
(
pTableScan
,
NULL
);
if
(
NULL
==
pTableScan
)
{
CHECK_CODE
(
initScanPhysiNode
(
pCxt
,
pScanLogicNode
,
(
SScanPhysiNode
*
)
pTableScan
),
(
SPhysiNode
*
)
pTableScan
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pTableScan
->
scanFlag
=
pScanLogicNode
->
scanFlag
;
pTableScan
->
scanFlag
=
pScanLogicNode
->
scanFlag
;
pTableScan
->
scanRange
=
pScanLogicNode
->
scanRange
;
pTableScan
->
scanRange
=
pScanLogicNode
->
scanRange
;
vgroupInfoToNodeAddr
(
pScanLogicNode
->
pVgroupList
->
vgroups
,
&
pSubplan
->
execNode
);
vgroupInfoToNodeAddr
(
pScanLogicNode
->
pVgroupList
->
vgroups
,
&
pSubplan
->
execNode
);
taosArrayPush
(
pCxt
->
pExecNodeList
,
&
pSubplan
->
execNode
);
taosArrayPush
(
pCxt
->
pExecNodeList
,
&
pSubplan
->
execNode
);
pSubplan
->
execNodeStat
.
tableNum
=
pScanLogicNode
->
pVgroupList
->
vgroups
[
0
].
numOfTable
;
pSubplan
->
execNodeStat
.
tableNum
=
pScanLogicNode
->
pVgroupList
->
vgroups
[
0
].
numOfTable
;
tNameGetFullDbName
(
&
pScanLogicNode
->
tableName
,
pSubplan
->
dbFName
);
tNameGetFullDbName
(
&
pScanLogicNode
->
tableName
,
pSubplan
->
dbFName
);
return
(
SPhysiNode
*
)
pTableScan
;
return
createScanPhysiNodeFinalize
(
pCxt
,
pScanLogicNode
,
(
SScanPhysiNode
*
)
pTableScan
,
pPhyNode
);
}
}
static
SPhysiNode
*
createSystemTableScanPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SSubplan
*
pSubplan
,
SScanLogicNode
*
pScanLogic
Node
)
{
static
int32_t
createSystemTableScanPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SSubplan
*
pSubplan
,
SScanLogicNode
*
pScanLogicNode
,
SPhysiNode
**
pPhy
Node
)
{
SSystemTableScanPhysiNode
*
pScan
=
(
SSystemTableScanPhysiNode
*
)
makePhysiNode
(
pCxt
,
QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN
);
SSystemTableScanPhysiNode
*
pScan
=
(
SSystemTableScanPhysiNode
*
)
makePhysiNode
(
pCxt
,
QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN
);
CHECK_ALLOC
(
pScan
,
NULL
);
if
(
NULL
==
pScan
)
{
CHECK_CODE
(
initScanPhysiNode
(
pCxt
,
pScanLogicNode
,
(
SScanPhysiNode
*
)
pScan
),
(
SPhysiNode
*
)
pScan
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
if
(
0
==
strcmp
(
pScanLogicNode
->
tableName
.
tname
,
TSDB_INS_TABLE_USER_TABLES
))
{
if
(
0
==
strcmp
(
pScanLogicNode
->
tableName
.
tname
,
TSDB_INS_TABLE_USER_TABLES
))
{
vgroupInfoToNodeAddr
(
pScanLogicNode
->
pVgroupList
->
vgroups
,
&
pSubplan
->
execNode
);
vgroupInfoToNodeAddr
(
pScanLogicNode
->
pVgroupList
->
vgroups
,
&
pSubplan
->
execNode
);
taosArrayPush
(
pCxt
->
pExecNodeList
,
&
pSubplan
->
execNode
);
taosArrayPush
(
pCxt
->
pExecNodeList
,
&
pSubplan
->
execNode
);
...
@@ -284,88 +315,104 @@ static SPhysiNode* createSystemTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubp
...
@@ -284,88 +315,104 @@ static SPhysiNode* createSystemTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubp
}
}
pScan
->
mgmtEpSet
=
pCxt
->
pPlanCxt
->
mgmtEpSet
;
pScan
->
mgmtEpSet
=
pCxt
->
pPlanCxt
->
mgmtEpSet
;
tNameGetFullDbName
(
&
pScanLogicNode
->
tableName
,
pSubplan
->
dbFName
);
tNameGetFullDbName
(
&
pScanLogicNode
->
tableName
,
pSubplan
->
dbFName
);
return
(
SPhysiNode
*
)
pScan
;
return
createScanPhysiNodeFinalize
(
pCxt
,
pScanLogicNode
,
(
SScanPhysiNode
*
)
pScan
,
pPhyNode
);
}
}
static
SPhysiNode
*
createStreamScanPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SSubplan
*
pSubplan
,
SScanLogicNode
*
pScanLogicNode
)
{
static
int32_t
createStreamScanPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SSubplan
*
pSubplan
,
SScanLogicNode
*
pScanLogicNode
,
SPhysiNode
**
pPhyNode
)
{
SStreamScanPhysiNode
*
pTableScan
=
(
SStreamScanPhysiNode
*
)
makePhysiNode
(
pCxt
,
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
);
SStreamScanPhysiNode
*
pScan
=
(
SStreamScanPhysiNode
*
)
makePhysiNode
(
pCxt
,
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
);
CHECK_ALLOC
(
pTableScan
,
NULL
);
if
(
NULL
==
pScan
)
{
CHECK_CODE
(
initScanPhysiNode
(
pCxt
,
pScanLogicNode
,
(
SScanPhysiNode
*
)
pTableScan
),
(
SPhysiNode
*
)
pTableScan
);
return
TSDB_CODE_OUT_OF_MEMORY
;
return
(
SPhysiNode
*
)
pTableScan
;
}
return
createScanPhysiNodeFinalize
(
pCxt
,
pScanLogicNode
,
(
SScanPhysiNode
*
)
pScan
,
pPhyNode
);
}
}
static
SPhysiNode
*
createScanPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SSubplan
*
pSubplan
,
SScanLogicNode
*
pScanLogic
Node
)
{
static
int32_t
createScanPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SSubplan
*
pSubplan
,
SScanLogicNode
*
pScanLogicNode
,
SPhysiNode
**
pPhy
Node
)
{
switch
(
pScanLogicNode
->
scanType
)
{
switch
(
pScanLogicNode
->
scanType
)
{
case
SCAN_TYPE_TAG
:
case
SCAN_TYPE_TAG
:
return
createTagScanPhysiNode
(
pCxt
,
pScanLogicNode
);
return
createTagScanPhysiNode
(
pCxt
,
pScanLogicNode
,
pPhyNode
);
case
SCAN_TYPE_TABLE
:
case
SCAN_TYPE_TABLE
:
return
createTableScanPhysiNode
(
pCxt
,
pSubplan
,
pScanLogicNode
);
return
createTableScanPhysiNode
(
pCxt
,
pSubplan
,
pScanLogicNode
,
pPhyNode
);
case
SCAN_TYPE_SYSTEM_TABLE
:
case
SCAN_TYPE_SYSTEM_TABLE
:
return
createSystemTableScanPhysiNode
(
pCxt
,
pSubplan
,
pScanLogicNode
);
return
createSystemTableScanPhysiNode
(
pCxt
,
pSubplan
,
pScanLogicNode
,
pPhyNode
);
case
SCAN_TYPE_STREAM
:
case
SCAN_TYPE_STREAM
:
return
createStreamScanPhysiNode
(
pCxt
,
pSubplan
,
pScanLogicNode
);
return
createStreamScanPhysiNode
(
pCxt
,
pSubplan
,
pScanLogicNode
,
pPhyNode
);
default:
default:
break
;
break
;
}
}
return
NULL
;
return
TSDB_CODE_FAILED
;
}
}
static
SNodeList
*
createJoinOutputCols
(
SPhysiPlanContext
*
pCxt
,
SDataBlockDescNode
*
pLeftDesc
,
SDataBlockDescNode
*
pRightDesc
)
{
static
int32_t
createColFromDataBlockDesc
(
SDataBlockDescNode
*
pDesc
,
SNodeList
*
pCols
)
{
SNodeList
*
pCols
=
nodesMakeList
();
CHECK_ALLOC
(
pCols
,
NULL
);
SNode
*
pNode
;
SNode
*
pNode
;
FOREACH
(
pNode
,
p
Left
Desc
->
pSlots
)
{
FOREACH
(
pNode
,
pDesc
->
pSlots
)
{
SSlotDescNode
*
pSlot
=
(
SSlotDescNode
*
)
pNode
;
SSlotDescNode
*
pSlot
=
(
SSlotDescNode
*
)
pNode
;
SColumnNode
*
pCol
=
(
SColumnNode
*
)
nodesMakeNode
(
QUERY_NODE_COLUMN
);
SColumnNode
*
pCol
=
(
SColumnNode
*
)
nodesMakeNode
(
QUERY_NODE_COLUMN
);
if
(
NULL
==
pCol
)
{
if
(
NULL
==
pCol
)
{
goto
error
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
pCol
->
node
.
resType
=
pSlot
->
dataType
;
pCol
->
node
.
resType
=
pSlot
->
dataType
;
pCol
->
dataBlockId
=
p
Left
Desc
->
dataBlockId
;
pCol
->
dataBlockId
=
pDesc
->
dataBlockId
;
pCol
->
slotId
=
pSlot
->
slotId
;
pCol
->
slotId
=
pSlot
->
slotId
;
pCol
->
colId
=
-
1
;
pCol
->
colId
=
-
1
;
i
f
(
TSDB_CODE_SUCCESS
!=
nodesListAppend
(
pCols
,
(
SNode
*
)
pCol
))
{
i
nt32_t
code
=
nodesListStrictAppend
(
pCols
,
pCol
);
goto
error
;
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
}
return
code
;
}
}
FOREACH
(
pNode
,
pRightDesc
->
pSlots
)
{
SSlotDescNode
*
pSlot
=
(
SSlotDescNode
*
)
pNode
;
SColumnNode
*
pCol
=
(
SColumnNode
*
)
nodesMakeNode
(
QUERY_NODE_COLUMN
);
if
(
NULL
==
pCol
)
{
goto
error
;
}
}
pCol
->
node
.
resType
=
pSlot
->
dataType
;
return
TSDB_CODE_SUCCESS
;
pCol
->
dataBlockId
=
pRightDesc
->
dataBlockId
;
}
pCol
->
slotId
=
pSlot
->
slotId
;
pCol
->
colId
=
-
1
;
static
int32_t
createJoinOutputCols
(
SPhysiPlanContext
*
pCxt
,
SDataBlockDescNode
*
pLeftDesc
,
SDataBlockDescNode
*
pRightDesc
,
SNodeList
**
pList
)
{
if
(
TSDB_CODE_SUCCESS
!=
nodesListAppend
(
pCols
,
(
SNode
*
)
pCol
))
{
SNodeList
*
pCols
=
nodesMakeList
();
goto
error
;
if
(
NULL
==
pCols
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
int32_t
code
=
createColFromDataBlockDesc
(
pLeftDesc
,
pCols
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createColFromDataBlockDesc
(
pRightDesc
,
pCols
);
}
}
return
pCols
;
error:
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pList
=
pCols
;
}
else
{
nodesDestroyList
(
pCols
);
nodesDestroyList
(
pCols
);
return
NULL
;
}
return
code
;
}
}
static
SPhysiNode
*
createJoinPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SNodeList
*
pChildren
,
SJoinLogicNode
*
pJoinLogic
Node
)
{
static
int32_t
createJoinPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SNodeList
*
pChildren
,
SJoinLogicNode
*
pJoinLogicNode
,
SPhysiNode
**
pPhy
Node
)
{
SJoinPhysiNode
*
pJoin
=
(
SJoinPhysiNode
*
)
makePhysiNode
(
pCxt
,
QUERY_NODE_PHYSICAL_PLAN_JOIN
);
SJoinPhysiNode
*
pJoin
=
(
SJoinPhysiNode
*
)
makePhysiNode
(
pCxt
,
QUERY_NODE_PHYSICAL_PLAN_JOIN
);
CHECK_ALLOC
(
pJoin
,
NULL
);
if
(
NULL
==
pJoin
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
SDataBlockDescNode
*
pLeftDesc
=
((
SPhysiNode
*
)
nodesListGetNode
(
pChildren
,
0
))
->
pOutputDataBlockDesc
;
SDataBlockDescNode
*
pLeftDesc
=
((
SPhysiNode
*
)
nodesListGetNode
(
pChildren
,
0
))
->
pOutputDataBlockDesc
;
SDataBlockDescNode
*
pRightDesc
=
((
SPhysiNode
*
)
nodesListGetNode
(
pChildren
,
1
))
->
pOutputDataBlockDesc
;
SDataBlockDescNode
*
pRightDesc
=
((
SPhysiNode
*
)
nodesListGetNode
(
pChildren
,
1
))
->
pOutputDataBlockDesc
;
pJoin
->
pOnConditions
=
setNodeSlotId
(
pCxt
,
pLeftDesc
->
dataBlockId
,
pRightDesc
->
dataBlockId
,
pJoinLogicNode
->
pOnConditions
);
CHECK_ALLOC
(
pJoin
->
pOnConditions
,
(
SPhysiNode
*
)
pJoin
);
pJoin
->
pTargets
=
createJoinOutputCols
(
pCxt
,
pLeftDesc
,
pRightDesc
);
CHECK_ALLOC
(
pJoin
->
pTargets
,
(
SPhysiNode
*
)
pJoin
);
CHECK_CODE
(
addDataBlockDesc
(
pCxt
,
pJoin
->
pTargets
,
pJoin
->
node
.
pOutputDataBlockDesc
),
(
SPhysiNode
*
)
pJoin
);
CHECK_CODE
(
setConditionsSlotId
(
pCxt
,
(
const
SLogicNode
*
)
pJoinLogicNode
,
(
SPhysiNode
*
)
pJoin
),
(
SPhysiNode
*
)
pJoin
);
int32_t
code
=
setNodeSlotId
(
pCxt
,
pLeftDesc
->
dataBlockId
,
pRightDesc
->
dataBlockId
,
pJoinLogicNode
->
pOnConditions
,
&
pJoin
->
pOnConditions
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createJoinOutputCols
(
pCxt
,
pLeftDesc
,
pRightDesc
,
&
pJoin
->
pTargets
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
addDataBlockDesc
(
pCxt
,
pJoin
->
pTargets
,
pJoin
->
node
.
pOutputDataBlockDesc
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
setConditionsSlotId
(
pCxt
,
(
const
SLogicNode
*
)
pJoinLogicNode
,
(
SPhysiNode
*
)
pJoin
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
setSlotOutput
(
pCxt
,
pJoinLogicNode
->
node
.
pTargets
,
pJoin
->
node
.
pOutputDataBlockDesc
);
}
CHECK_CODE
(
setSlotOutput
(
pCxt
,
pJoinLogicNode
->
node
.
pTargets
,
pJoin
->
node
.
pOutputDataBlockDesc
),
(
SPhysiNode
*
)
pJoin
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pPhyNode
=
(
SPhysiNode
*
)
pJoin
;
}
else
{
nodesDestroyNode
(
pJoin
);
}
return
(
SPhysiNode
*
)
pJoin
;
return
code
;
}
}
typedef
struct
SRewritePrecalcExprsCxt
{
typedef
struct
SRewritePrecalcExprsCxt
{
...
@@ -451,76 +498,169 @@ static int32_t rewritePrecalcExprs(SPhysiPlanContext* pCxt, SNodeList* pList, SN
...
@@ -451,76 +498,169 @@ static int32_t rewritePrecalcExprs(SPhysiPlanContext* pCxt, SNodeList* pList, SN
return
cxt
.
errCode
;
return
cxt
.
errCode
;
}
}
static
SPhysiNode
*
createAggPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SNodeList
*
pChildren
,
SAggLogicNode
*
pAggLogic
Node
)
{
static
int32_t
createAggPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SNodeList
*
pChildren
,
SAggLogicNode
*
pAggLogicNode
,
SPhysiNode
**
pPhy
Node
)
{
SAggPhysiNode
*
pAgg
=
(
SAggPhysiNode
*
)
makePhysiNode
(
pCxt
,
QUERY_NODE_PHYSICAL_PLAN_AGG
);
SAggPhysiNode
*
pAgg
=
(
SAggPhysiNode
*
)
makePhysiNode
(
pCxt
,
QUERY_NODE_PHYSICAL_PLAN_AGG
);
CHECK_ALLOC
(
pAgg
,
NULL
);
if
(
NULL
==
pAgg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
SNodeList
*
pPrecalcExprs
=
NULL
;
SNodeList
*
pPrecalcExprs
=
NULL
;
SNodeList
*
pGroupKeys
=
NULL
;
SNodeList
*
pGroupKeys
=
NULL
;
SNodeList
*
pAggFuncs
=
NULL
;
SNodeList
*
pAggFuncs
=
NULL
;
CHECK_CODE
(
rewritePrecalcExprs
(
pCxt
,
pAggLogicNode
->
pGroupKeys
,
&
pPrecalcExprs
,
&
pGroupKeys
),
(
SPhysiNode
*
)
pAgg
);
int32_t
code
=
rewritePrecalcExprs
(
pCxt
,
pAggLogicNode
->
pGroupKeys
,
&
pPrecalcExprs
,
&
pGroupKeys
);
CHECK_CODE
(
rewritePrecalcExprs
(
pCxt
,
pAggLogicNode
->
pAggFuncs
,
&
pPrecalcExprs
,
&
pAggFuncs
),
(
SPhysiNode
*
)
pAgg
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
rewritePrecalcExprs
(
pCxt
,
pAggLogicNode
->
pAggFuncs
,
&
pPrecalcExprs
,
&
pAggFuncs
);
}
SDataBlockDescNode
*
pChildTupe
=
(((
SPhysiNode
*
)
nodesListGetNode
(
pChildren
,
0
))
->
pOutputDataBlockDesc
);
SDataBlockDescNode
*
pChildTupe
=
(((
SPhysiNode
*
)
nodesListGetNode
(
pChildren
,
0
))
->
pOutputDataBlockDesc
);
// push down expression to pOutputDataBlockDesc of child node
// push down expression to pOutputDataBlockDesc of child node
if
(
NULL
!=
pPrecalcExprs
)
{
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pPrecalcExprs
)
{
pAgg
->
pExprs
=
setListSlotId
(
pCxt
,
pChildTupe
->
dataBlockId
,
-
1
,
pPrecalcExprs
);
code
=
setListSlotId
(
pCxt
,
pChildTupe
->
dataBlockId
,
-
1
,
pPrecalcExprs
,
&
pAgg
->
pExprs
);
CHECK_ALLOC
(
pAgg
->
pExprs
,
(
SPhysiNode
*
)
pAgg
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
CHECK_CODE
(
addDataBlockDesc
(
pCxt
,
pAgg
->
pExprs
,
pChildTupe
),
(
SPhysiNode
*
)
pAgg
);
code
=
addDataBlockDesc
(
pCxt
,
pAgg
->
pExprs
,
pChildTupe
);
}
}
}
if
(
NULL
!=
pGroupKeys
)
{
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pGroupKeys
)
{
pAgg
->
pGroupKeys
=
setListSlotId
(
pCxt
,
pChildTupe
->
dataBlockId
,
-
1
,
pGroupKeys
);
code
=
setListSlotId
(
pCxt
,
pChildTupe
->
dataBlockId
,
-
1
,
pGroupKeys
,
&
pAgg
->
pGroupKeys
);
CHECK_ALLOC
(
pAgg
->
pGroupKeys
,
(
SPhysiNode
*
)
pAgg
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
CHECK_CODE
(
addDataBlockDesc
(
pCxt
,
pAgg
->
pGroupKeys
,
pAgg
->
node
.
pOutputDataBlockDesc
),
(
SPhysiNode
*
)
pAgg
);
code
=
addDataBlockDesc
(
pCxt
,
pAgg
->
pGroupKeys
,
pAgg
->
node
.
pOutputDataBlockDesc
);
}
}
}
if
(
NULL
!=
pAggFuncs
)
{
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pAggFuncs
)
{
pAgg
->
pAggFuncs
=
setListSlotId
(
pCxt
,
pChildTupe
->
dataBlockId
,
-
1
,
pAggFuncs
);
code
=
setListSlotId
(
pCxt
,
pChildTupe
->
dataBlockId
,
-
1
,
pAggFuncs
,
&
pAgg
->
pAggFuncs
);
CHECK_ALLOC
(
pAgg
->
pAggFuncs
,
(
SPhysiNode
*
)
pAgg
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
CHECK_CODE
(
addDataBlockDesc
(
pCxt
,
pAgg
->
pAggFuncs
,
pAgg
->
node
.
pOutputDataBlockDesc
),
(
SPhysiNode
*
)
pAgg
);
code
=
addDataBlockDesc
(
pCxt
,
pAgg
->
pAggFuncs
,
pAgg
->
node
.
pOutputDataBlockDesc
);
}
}
}
CHECK_CODE
(
setConditionsSlotId
(
pCxt
,
(
const
SLogicNode
*
)
pAggLogicNode
,
(
SPhysiNode
*
)
pAgg
),
(
SPhysiNode
*
)
pAgg
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
setConditionsSlotId
(
pCxt
,
(
const
SLogicNode
*
)
pAggLogicNode
,
(
SPhysiNode
*
)
pAgg
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
setSlotOutput
(
pCxt
,
pAggLogicNode
->
node
.
pTargets
,
pAgg
->
node
.
pOutputDataBlockDesc
);
}
CHECK_CODE
(
setSlotOutput
(
pCxt
,
pAggLogicNode
->
node
.
pTargets
,
pAgg
->
node
.
pOutputDataBlockDesc
),
(
SPhysiNode
*
)
pAgg
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pPhyNode
=
(
SPhysiNode
*
)
pAgg
;
}
else
{
nodesDestroyNode
(
pAgg
);
}
return
(
SPhysiNode
*
)
pAgg
;
return
code
;
}
}
static
SPhysiNode
*
createProjectPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SNodeList
*
pChildren
,
SProjectLogicNode
*
pProjectLogic
Node
)
{
static
int32_t
createProjectPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SNodeList
*
pChildren
,
SProjectLogicNode
*
pProjectLogicNode
,
SPhysiNode
**
pPhy
Node
)
{
SProjectPhysiNode
*
pProject
=
(
SProjectPhysiNode
*
)
makePhysiNode
(
pCxt
,
QUERY_NODE_PHYSICAL_PLAN_PROJECT
);
SProjectPhysiNode
*
pProject
=
(
SProjectPhysiNode
*
)
makePhysiNode
(
pCxt
,
QUERY_NODE_PHYSICAL_PLAN_PROJECT
);
CHECK_ALLOC
(
pProject
,
NULL
);
if
(
NULL
==
pProject
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pProject
->
pProjections
=
setListSlotId
(
pCxt
,
((
SPhysiNode
*
)
nodesListGetNode
(
pChildren
,
0
))
->
pOutputDataBlockDesc
->
dataBlockId
,
-
1
,
pProjectLogicNode
->
pProjections
);
int32_t
code
=
setListSlotId
(
pCxt
,
((
SPhysiNode
*
)
nodesListGetNode
(
pChildren
,
0
))
->
pOutputDataBlockDesc
->
dataBlockId
,
-
1
,
pProjectLogicNode
->
pProjections
,
&
pProject
->
pProjections
);
CHECK_ALLOC
(
pProject
->
pProjections
,
(
SPhysiNode
*
)
pProject
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
CHECK_CODE
(
addDataBlockDesc
(
pCxt
,
pProject
->
pProjections
,
pProject
->
node
.
pOutputDataBlockDesc
),
(
SPhysiNode
*
)
pProject
);
code
=
addDataBlockDesc
(
pCxt
,
pProject
->
pProjections
,
pProject
->
node
.
pOutputDataBlockDesc
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
setConditionsSlotId
(
pCxt
,
(
const
SLogicNode
*
)
pProjectLogicNode
,
(
SPhysiNode
*
)
pProject
);
}
CHECK_CODE
(
setConditionsSlotId
(
pCxt
,
(
const
SLogicNode
*
)
pProjectLogicNode
,
(
SPhysiNode
*
)
pProject
),
(
SPhysiNode
*
)
pProject
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pPhyNode
=
(
SPhysiNode
*
)
pProject
;
}
else
{
nodesDestroyNode
(
pProject
);
}
return
(
SPhysiNode
*
)
pProject
;
return
code
;
}
}
static
SPhysiNode
*
createExchangePhysiNode
(
SPhysiPlanContext
*
pCxt
,
SExchangeLogicNode
*
pExchangeLogicNode
)
{
static
int32_t
doCreateExchangePhysiNode
(
SPhysiPlanContext
*
pCxt
,
SExchangeLogicNode
*
pExchangeLogicNode
,
SPhysiNode
**
pPhyNode
)
{
if
(
pCxt
->
pPlanCxt
->
streamQuery
)
{
SExchangePhysiNode
*
pExchange
=
(
SExchangePhysiNode
*
)
makePhysiNode
(
pCxt
,
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
);
if
(
NULL
==
pExchange
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pExchange
->
srcGroupId
=
pExchangeLogicNode
->
srcGroupId
;
int32_t
code
=
addDataBlockDesc
(
pCxt
,
pExchangeLogicNode
->
node
.
pTargets
,
pExchange
->
node
.
pOutputDataBlockDesc
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pPhyNode
=
(
SPhysiNode
*
)
pExchange
;
}
else
{
nodesDestroyNode
(
pExchange
);
}
return
code
;
}
static
int32_t
createStreamScanPhysiNodeByExchange
(
SPhysiPlanContext
*
pCxt
,
SExchangeLogicNode
*
pExchangeLogicNode
,
SPhysiNode
**
pPhyNode
)
{
SStreamScanPhysiNode
*
pScan
=
(
SStreamScanPhysiNode
*
)
makePhysiNode
(
pCxt
,
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
);
SStreamScanPhysiNode
*
pScan
=
(
SStreamScanPhysiNode
*
)
makePhysiNode
(
pCxt
,
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
);
CHECK_ALLOC
(
pScan
,
NULL
);
if
(
NULL
==
pScan
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
int32_t
code
=
addDataBlockDesc
(
pCxt
,
pExchangeLogicNode
->
node
.
pTargets
,
pScan
->
node
.
pOutputDataBlockDesc
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pScan
->
pScanCols
=
nodesCloneList
(
pExchangeLogicNode
->
node
.
pTargets
);
pScan
->
pScanCols
=
nodesCloneList
(
pExchangeLogicNode
->
node
.
pTargets
);
CHECK_ALLOC
(
pScan
->
pScanCols
,
(
SPhysiNode
*
)
pScan
);
if
(
NULL
==
pScan
->
pScanCols
)
{
CHECK_CODE
(
addDataBlockDesc
(
pCxt
,
pExchangeLogicNode
->
node
.
pTargets
,
pScan
->
node
.
pOutputDataBlockDesc
),
(
SPhysiNode
*
)
pScan
);
code
=
TSDB_CODE_OUT_OF_MEMORY
;
return
(
SPhysiNode
*
)
pScan
;
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pPhyNode
=
(
SPhysiNode
*
)
pScan
;
}
else
{
}
else
{
SExchangePhysiNode
*
pExchange
=
(
SExchangePhysiNode
*
)
makePhysiNode
(
pCxt
,
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
);
nodesDestroyNode
(
pScan
);
CHECK_ALLOC
(
pExchange
,
NULL
);
CHECK_CODE
(
addDataBlockDesc
(
pCxt
,
pExchangeLogicNode
->
node
.
pTargets
,
pExchange
->
node
.
pOutputDataBlockDesc
),
(
SPhysiNode
*
)
pExchange
);
pExchange
->
srcGroupId
=
pExchangeLogicNode
->
srcGroupId
;
return
(
SPhysiNode
*
)
pExchange
;
}
}
return
code
;
}
}
static
SPhysiNode
*
createIntervalPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SNodeList
*
pChildren
,
SWindowLogicNode
*
pWindowLogicNode
)
{
static
int32_t
createExchangePhysiNode
(
SPhysiPlanContext
*
pCxt
,
SExchangeLogicNode
*
pExchangeLogicNode
,
SPhysiNode
**
pPhyNode
)
{
if
(
pCxt
->
pPlanCxt
->
streamQuery
)
{
return
createStreamScanPhysiNodeByExchange
(
pCxt
,
pExchangeLogicNode
,
pPhyNode
);
}
else
{
return
doCreateExchangePhysiNode
(
pCxt
,
pExchangeLogicNode
,
pPhyNode
);
}
}
static
int32_t
createWindowPhysiNodeFinalize
(
SPhysiPlanContext
*
pCxt
,
SNodeList
*
pChildren
,
SWinodwPhysiNode
*
pWindow
,
SWindowLogicNode
*
pWindowLogicNode
,
SPhysiNode
**
pPhyNode
)
{
SNodeList
*
pPrecalcExprs
=
NULL
;
SNodeList
*
pFuncs
=
NULL
;
int32_t
code
=
rewritePrecalcExprs
(
pCxt
,
pWindowLogicNode
->
pFuncs
,
&
pPrecalcExprs
,
&
pFuncs
);
SDataBlockDescNode
*
pChildTupe
=
(((
SPhysiNode
*
)
nodesListGetNode
(
pChildren
,
0
))
->
pOutputDataBlockDesc
);
// push down expression to pOutputDataBlockDesc of child node
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pPrecalcExprs
)
{
code
=
setListSlotId
(
pCxt
,
pChildTupe
->
dataBlockId
,
-
1
,
pPrecalcExprs
,
&
pWindow
->
pExprs
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
addDataBlockDesc
(
pCxt
,
pWindow
->
pExprs
,
pChildTupe
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pFuncs
)
{
code
=
setListSlotId
(
pCxt
,
pChildTupe
->
dataBlockId
,
-
1
,
pFuncs
,
&
pWindow
->
pFuncs
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
addDataBlockDesc
(
pCxt
,
pWindow
->
pFuncs
,
pWindow
->
node
.
pOutputDataBlockDesc
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
setSlotOutput
(
pCxt
,
pWindowLogicNode
->
node
.
pTargets
,
pWindow
->
node
.
pOutputDataBlockDesc
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pPhyNode
=
(
SPhysiNode
*
)
pWindow
;
}
else
{
nodesDestroyNode
(
pWindow
);
}
return
code
;
}
static
int32_t
createIntervalPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SNodeList
*
pChildren
,
SWindowLogicNode
*
pWindowLogicNode
,
SPhysiNode
**
pPhyNode
)
{
SIntervalPhysiNode
*
pInterval
=
(
SIntervalPhysiNode
*
)
makePhysiNode
(
pCxt
,
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
);
SIntervalPhysiNode
*
pInterval
=
(
SIntervalPhysiNode
*
)
makePhysiNode
(
pCxt
,
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
);
CHECK_ALLOC
(
pInterval
,
NULL
);
if
(
NULL
==
pInterval
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pInterval
->
interval
=
pWindowLogicNode
->
interval
;
pInterval
->
interval
=
pWindowLogicNode
->
interval
;
pInterval
->
offset
=
pWindowLogicNode
->
offset
;
pInterval
->
offset
=
pWindowLogicNode
->
offset
;
...
@@ -529,163 +669,178 @@ static SPhysiNode* createIntervalPhysiNode(SPhysiPlanContext* pCxt, SNodeList* p
...
@@ -529,163 +669,178 @@ static SPhysiNode* createIntervalPhysiNode(SPhysiPlanContext* pCxt, SNodeList* p
pInterval
->
slidingUnit
=
pWindowLogicNode
->
slidingUnit
;
pInterval
->
slidingUnit
=
pWindowLogicNode
->
slidingUnit
;
pInterval
->
pFill
=
nodesCloneNode
(
pWindowLogicNode
->
pFill
);
pInterval
->
pFill
=
nodesCloneNode
(
pWindowLogicNode
->
pFill
);
if
(
NULL
!=
pWindowLogicNode
->
pFill
&&
NULL
==
pInterval
->
pFill
)
{
SNodeList
*
pPrecalcExprs
=
NULL
;
nodesDestroyNode
(
pInterval
);
SNodeList
*
pFuncs
=
NULL
;
return
TSDB_CODE_OUT_OF_MEMORY
;
CHECK_CODE
(
rewritePrecalcExprs
(
pCxt
,
pWindowLogicNode
->
pFuncs
,
&
pPrecalcExprs
,
&
pFuncs
),
(
SPhysiNode
*
)
pInterval
);
SDataBlockDescNode
*
pChildTupe
=
(((
SPhysiNode
*
)
nodesListGetNode
(
pChildren
,
0
))
->
pOutputDataBlockDesc
);
// push down expression to pOutputDataBlockDesc of child node
if
(
NULL
!=
pPrecalcExprs
)
{
pInterval
->
pExprs
=
setListSlotId
(
pCxt
,
pChildTupe
->
dataBlockId
,
-
1
,
pPrecalcExprs
);
CHECK_ALLOC
(
pInterval
->
pExprs
,
(
SPhysiNode
*
)
pInterval
);
CHECK_CODE
(
addDataBlockDesc
(
pCxt
,
pInterval
->
pExprs
,
pChildTupe
),
(
SPhysiNode
*
)
pInterval
);
}
}
if
(
NULL
!=
pFuncs
)
{
return
createWindowPhysiNodeFinalize
(
pCxt
,
pChildren
,
&
pInterval
->
window
,
pWindowLogicNode
,
pPhyNode
);
pInterval
->
pFuncs
=
setListSlotId
(
pCxt
,
pChildTupe
->
dataBlockId
,
-
1
,
pFuncs
);
}
CHECK_ALLOC
(
pInterval
->
pFuncs
,
(
SPhysiNode
*
)
pInterval
);
CHECK_CODE
(
addDataBlockDesc
(
pCxt
,
pInterval
->
pFuncs
,
pInterval
->
node
.
pOutputDataBlockDesc
),
(
SPhysiNode
*
)
pInterval
);
static
int32_t
createSessionWindowPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SNodeList
*
pChildren
,
SWindowLogicNode
*
pWindowLogicNode
,
SPhysiNode
**
pPhyNode
)
{
SSessionWinodwPhysiNode
*
pSession
=
(
SSessionWinodwPhysiNode
*
)
makePhysiNode
(
pCxt
,
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW
);
if
(
NULL
==
pSession
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
CHECK_CODE
(
setSlotOutput
(
pCxt
,
pWindowLogicNode
->
node
.
pTargets
,
pInterval
->
node
.
pOutputDataBlockDesc
),
(
SPhysiNode
*
)
pInterval
)
;
pSession
->
gap
=
pWindowLogicNode
->
sessionGap
;
return
(
SPhysiNode
*
)
pInterval
;
return
createWindowPhysiNodeFinalize
(
pCxt
,
pChildren
,
&
pSession
->
window
,
pWindowLogicNode
,
pPhyNode
)
;
}
}
static
SPhysiNode
*
createWindowPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SNodeList
*
pChildren
,
SWindowLogicNode
*
pWindowLogic
Node
)
{
static
int32_t
createWindowPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SNodeList
*
pChildren
,
SWindowLogicNode
*
pWindowLogicNode
,
SPhysiNode
**
pPhy
Node
)
{
switch
(
pWindowLogicNode
->
winType
)
{
switch
(
pWindowLogicNode
->
winType
)
{
case
WINDOW_TYPE_INTERVAL
:
case
WINDOW_TYPE_INTERVAL
:
return
createIntervalPhysiNode
(
pCxt
,
pChildren
,
pWindowLogicNode
);
return
createIntervalPhysiNode
(
pCxt
,
pChildren
,
pWindowLogicNode
,
pPhyNode
);
case
WINDOW_TYPE_SESSION
:
case
WINDOW_TYPE_SESSION
:
return
createSessionWindowPhysiNode
(
pCxt
,
pChildren
,
pWindowLogicNode
,
pPhyNode
);
case
WINDOW_TYPE_STATE
:
case
WINDOW_TYPE_STATE
:
break
;
break
;
default:
default:
break
;
break
;
}
}
return
NULL
;
return
TSDB_CODE_FAILED
;
}
}
static
SPhysiNode
*
createPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SSubplan
*
pSubplan
,
SLogicNode
*
pLogicPlan
)
{
static
int32_t
doCreatePhysiNode
(
SPhysiPlanContext
*
pCxt
,
SLogicNode
*
pLogicNode
,
SSubplan
*
pSubplan
,
SNodeList
*
pChildren
,
SPhysiNode
**
pPhyNode
)
{
SNodeList
*
pChildren
=
nodesMakeList
();
switch
(
nodeType
(
pLogicNode
))
{
CHECK_ALLOC
(
pChildren
,
NULL
);
SNode
*
pLogicChild
;
FOREACH
(
pLogicChild
,
pLogicPlan
->
pChildren
)
{
if
(
TSDB_CODE_SUCCESS
!=
nodesListStrictAppend
(
pChildren
,
createPhysiNode
(
pCxt
,
pSubplan
,
(
SLogicNode
*
)
pLogicChild
)))
{
pCxt
->
errCode
=
TSDB_CODE_OUT_OF_MEMORY
;
nodesDestroyList
(
pChildren
);
return
NULL
;
}
}
SPhysiNode
*
pPhyNode
=
NULL
;
switch
(
nodeType
(
pLogicPlan
))
{
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
pPhyNode
=
createScanPhysiNode
(
pCxt
,
pSubplan
,
(
SScanLogicNode
*
)
pLogicPlan
);
return
createScanPhysiNode
(
pCxt
,
pSubplan
,
(
SScanLogicNode
*
)
pLogicNode
,
pPhyNode
);
break
;
case
QUERY_NODE_LOGIC_PLAN_JOIN
:
case
QUERY_NODE_LOGIC_PLAN_JOIN
:
pPhyNode
=
createJoinPhysiNode
(
pCxt
,
pChildren
,
(
SJoinLogicNode
*
)
pLogicPlan
);
return
createJoinPhysiNode
(
pCxt
,
pChildren
,
(
SJoinLogicNode
*
)
pLogicNode
,
pPhyNode
);
break
;
case
QUERY_NODE_LOGIC_PLAN_AGG
:
case
QUERY_NODE_LOGIC_PLAN_AGG
:
pPhyNode
=
createAggPhysiNode
(
pCxt
,
pChildren
,
(
SAggLogicNode
*
)
pLogicPlan
);
return
createAggPhysiNode
(
pCxt
,
pChildren
,
(
SAggLogicNode
*
)
pLogicNode
,
pPhyNode
);
break
;
case
QUERY_NODE_LOGIC_PLAN_PROJECT
:
case
QUERY_NODE_LOGIC_PLAN_PROJECT
:
pPhyNode
=
createProjectPhysiNode
(
pCxt
,
pChildren
,
(
SProjectLogicNode
*
)
pLogicPlan
);
return
createProjectPhysiNode
(
pCxt
,
pChildren
,
(
SProjectLogicNode
*
)
pLogicNode
,
pPhyNode
);
break
;
case
QUERY_NODE_LOGIC_PLAN_EXCHANGE
:
case
QUERY_NODE_LOGIC_PLAN_EXCHANGE
:
pPhyNode
=
createExchangePhysiNode
(
pCxt
,
(
SExchangeLogicNode
*
)
pLogicPlan
);
return
createExchangePhysiNode
(
pCxt
,
(
SExchangeLogicNode
*
)
pLogicNode
,
pPhyNode
);
break
;
case
QUERY_NODE_LOGIC_PLAN_WINDOW
:
case
QUERY_NODE_LOGIC_PLAN_WINDOW
:
pPhyNode
=
createWindowPhysiNode
(
pCxt
,
pChildren
,
(
SWindowLogicNode
*
)
pLogicPlan
);
return
createWindowPhysiNode
(
pCxt
,
pChildren
,
(
SWindowLogicNode
*
)
pLogicNode
,
pPhyNode
);
break
;
default:
default:
break
;
break
;
}
}
if
(
TSDB_CODE_SUCCESS
!=
pCxt
->
errCode
)
{
nodesDestroyNode
(
pPhyNode
);
return
TSDB_CODE_FAILED
;
return
NULL
;
}
static
int32_t
createPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SLogicNode
*
pLogicNode
,
SSubplan
*
pSubplan
,
SPhysiNode
**
pPhyNode
)
{
SNodeList
*
pChildren
=
nodesMakeList
();
if
(
NULL
==
pChildren
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
int32_t
code
=
TSDB_CODE_SUCCESS
;
SNode
*
pLogicChild
;
FOREACH
(
pLogicChild
,
pLogicNode
->
pChildren
)
{
SPhysiNode
*
pChild
=
NULL
;
code
=
createPhysiNode
(
pCxt
,
(
SLogicNode
*
)
pLogicChild
,
pSubplan
,
&
pChild
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesListStrictAppend
(
pChildren
,
pChild
);
}
}
}
pPhyNode
->
pChildren
=
pChildren
;
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
doCreatePhysiNode
(
pCxt
,
pLogicNode
,
pSubplan
,
pChildren
,
pPhyNode
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
(
*
pPhyNode
)
->
pChildren
=
pChildren
;
SNode
*
pChild
;
SNode
*
pChild
;
FOREACH
(
pChild
,
pPhyNode
->
pChildren
)
{
FOREACH
(
pChild
,
(
*
pPhyNode
)
->
pChildren
)
{
((
SPhysiNode
*
)
pChild
)
->
pParent
=
pPhyNode
;
((
SPhysiNode
*
)
pChild
)
->
pParent
=
(
*
pPhyNode
);
}
}
else
{
nodesDestroyList
(
pChildren
);
}
}
return
pPhyN
ode
;
return
c
ode
;
}
}
static
SDataSinkNode
*
createDataInserter
(
SPhysiPlanContext
*
pCxt
,
SVgDataBlocks
*
pBlocks
)
{
static
int32_t
createDataInserter
(
SPhysiPlanContext
*
pCxt
,
SVgDataBlocks
*
pBlocks
,
SDataSinkNode
**
pSink
)
{
SDataInserterNode
*
pInserter
=
nodesMakeNode
(
QUERY_NODE_PHYSICAL_PLAN_INSERT
);
SDataInserterNode
*
pInserter
=
nodesMakeNode
(
QUERY_NODE_PHYSICAL_PLAN_INSERT
);
CHECK_ALLOC
(
pInserter
,
NULL
);
if
(
NULL
==
pInserter
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pInserter
->
numOfTables
=
pBlocks
->
numOfTables
;
pInserter
->
numOfTables
=
pBlocks
->
numOfTables
;
pInserter
->
size
=
pBlocks
->
size
;
pInserter
->
size
=
pBlocks
->
size
;
TSWAP
(
pInserter
->
pData
,
pBlocks
->
pData
,
char
*
);
TSWAP
(
pInserter
->
pData
,
pBlocks
->
pData
,
char
*
);
return
(
SDataSinkNode
*
)
pInserter
;
*
pSink
=
(
SDataSinkNode
*
)
pInserter
;
return
TSDB_CODE_SUCCESS
;
}
}
static
SDataSinkNode
*
createDataDispatcher
(
SPhysiPlanContext
*
pCxt
,
const
SPhysiNode
*
pRoot
)
{
static
int32_t
createDataDispatcher
(
SPhysiPlanContext
*
pCxt
,
const
SPhysiNode
*
pRoot
,
SDataSinkNode
**
pSink
)
{
SDataDispatcherNode
*
pDispatcher
=
nodesMakeNode
(
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
);
SDataDispatcherNode
*
pDispatcher
=
nodesMakeNode
(
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
);
CHECK_ALLOC
(
pDispatcher
,
NULL
);
if
(
NULL
==
pDispatcher
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pDispatcher
->
sink
.
pInputDataBlockDesc
=
nodesCloneNode
(
pRoot
->
pOutputDataBlockDesc
);
pDispatcher
->
sink
.
pInputDataBlockDesc
=
nodesCloneNode
(
pRoot
->
pOutputDataBlockDesc
);
CHECK_ALLOC
(
pDispatcher
->
sink
.
pInputDataBlockDesc
,
(
SDataSinkNode
*
)
pDispatcher
);
if
(
NULL
==
pDispatcher
->
sink
.
pInputDataBlockDesc
)
{
return
(
SDataSinkNode
*
)
pDispatcher
;
nodesDestroyNode
(
pDispatcher
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
*
pSink
=
(
SDataSinkNode
*
)
pDispatcher
;
return
TSDB_CODE_SUCCESS
;
}
}
static
SSubplan
*
makeSubplan
(
SPhysiPlanContext
*
pCxt
,
S
SubLogicP
lan
*
pLogicSubplan
)
{
static
SSubplan
*
makeSubplan
(
SPhysiPlanContext
*
pCxt
,
S
LogicSubp
lan
*
pLogicSubplan
)
{
SSubplan
*
pSubplan
=
nodesMakeNode
(
QUERY_NODE_PHYSICAL_SUBPLAN
);
SSubplan
*
pSubplan
=
nodesMakeNode
(
QUERY_NODE_PHYSICAL_SUBPLAN
);
CHECK_ALLOC
(
pSubplan
,
NULL
);
if
(
NULL
==
pSubplan
)
{
return
NULL
;
}
pSubplan
->
id
=
pLogicSubplan
->
id
;
pSubplan
->
id
=
pLogicSubplan
->
id
;
pSubplan
->
subplanType
=
pLogicSubplan
->
subplanType
;
pSubplan
->
subplanType
=
pLogicSubplan
->
subplanType
;
pSubplan
->
level
=
pLogicSubplan
->
level
;
pSubplan
->
level
=
pLogicSubplan
->
level
;
return
pSubplan
;
return
pSubplan
;
}
}
static
SSubplan
*
createPhysiSubplan
(
SPhysiPlanContext
*
pCxt
,
SSubLogicPlan
*
pLogic
Subplan
)
{
static
int32_t
createPhysiSubplan
(
SPhysiPlanContext
*
pCxt
,
SLogicSubplan
*
pLogicSubplan
,
SSubplan
**
pPhysi
Subplan
)
{
SSubplan
*
pSubplan
=
makeSubplan
(
pCxt
,
pLogicSubplan
);
SSubplan
*
pSubplan
=
makeSubplan
(
pCxt
,
pLogicSubplan
);
CHECK_ALLOC
(
pSubplan
,
NULL
);
if
(
NULL
==
pSubplan
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
(
SUBPLAN_TYPE_MODIFY
==
pLogicSubplan
->
subplanType
)
{
if
(
SUBPLAN_TYPE_MODIFY
==
pLogicSubplan
->
subplanType
)
{
SVnodeModifLogicNode
*
pModif
=
(
SVnodeModifLogicNode
*
)
pLogicSubplan
->
pNode
;
SVnodeModifLogicNode
*
pModif
=
(
SVnodeModifLogicNode
*
)
pLogicSubplan
->
pNode
;
pSubplan
->
pDataSink
=
createDataInserter
(
pCxt
,
pModif
->
pVgDataBlocks
);
pSubplan
->
msgType
=
pModif
->
msgType
;
pSubplan
->
msgType
=
pModif
->
msgType
;
pSubplan
->
execNode
.
epSet
=
pModif
->
pVgDataBlocks
->
vg
.
epSet
;
pSubplan
->
execNode
.
epSet
=
pModif
->
pVgDataBlocks
->
vg
.
epSet
;
taosArrayPush
(
pCxt
->
pExecNodeList
,
&
pSubplan
->
execNode
);
taosArrayPush
(
pCxt
->
pExecNodeList
,
&
pSubplan
->
execNode
);
code
=
createDataInserter
(
pCxt
,
pModif
->
pVgDataBlocks
,
&
pSubplan
->
pDataSink
);
}
else
{
}
else
{
pSubplan
->
pNode
=
createPhysiNode
(
pCxt
,
pSubplan
,
pLogicSubplan
->
pNode
);
if
(
!
pCxt
->
pPlanCxt
->
streamQuery
&&
!
pCxt
->
pPlanCxt
->
topicQuery
)
{
pSubplan
->
pDataSink
=
createDataDispatcher
(
pCxt
,
pSubplan
->
pNode
);
}
pSubplan
->
msgType
=
TDMT_VND_QUERY
;
pSubplan
->
msgType
=
TDMT_VND_QUERY
;
code
=
createPhysiNode
(
pCxt
,
pLogicSubplan
->
pNode
,
pSubplan
,
&
pSubplan
->
pNode
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
!
pCxt
->
pPlanCxt
->
streamQuery
&&
!
pCxt
->
pPlanCxt
->
topicQuery
)
{
code
=
createDataDispatcher
(
pCxt
,
pSubplan
->
pNode
,
&
pSubplan
->
pDataSink
);
}
}
}
return
pSubplan
;
}
static
void
doSetLogicNodeParent
(
SLogicNode
*
pNode
,
SLogicNode
*
pParent
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pNode
->
pParent
=
pParent
;
*
pPhysiSubplan
=
pSubplan
;
SNode
*
pChild
;
}
else
{
FOREACH
(
pChild
,
pNode
->
pChildren
)
{
nodesDestroyNode
(
pSubplan
);
doSetLogicNodeParent
((
SLogicNode
*
)
pChild
,
pNode
);
}
}
}
static
void
setLogicNodeParent
(
SLogicNode
*
pNode
)
{
return
code
;
doSetLogicNodeParent
(
pNode
,
NULL
);
}
}
static
int32_t
splitLogicPlan
(
SPhysiPlanContext
*
pCxt
,
SLogicNode
*
pLogicNode
,
SSubLogicPlan
**
pSubLogicPlan
)
{
static
SQueryPlan
*
makeQueryPhysiPlan
(
SPhysiPlanContext
*
pCxt
)
{
*
pSubLogicPlan
=
(
SSubLogicPlan
*
)
nodesMakeNode
(
QUERY_NODE_LOGIC_SUB
PLAN
);
SQueryPlan
*
pPlan
=
nodesMakeNode
(
QUERY_NODE_PHYSICAL_
PLAN
);
CHECK_ALLOC
(
*
pSubLogicPlan
,
TSDB_CODE_OUT_OF_MEMORY
);
if
(
NULL
==
pPlan
)
{
(
*
pSubLogicPlan
)
->
pNode
=
nodesCloneNode
(
pLogicNode
)
;
return
NULL
;
if
(
QUERY_NODE_LOGIC_PLAN_VNODE_MODIF
==
nodeType
(
pLogicNode
))
{
}
(
*
pSubLogicPlan
)
->
subplanType
=
SUBPLAN_TYPE_MODIFY
;
pPlan
->
pSubplans
=
nodesMakeList
()
;
TSWAP
(((
SVnodeModifLogicNode
*
)
pLogicNode
)
->
pDataBlocks
,
((
SVnodeModifLogicNode
*
)(
*
pSubLogicPlan
)
->
pNode
)
->
pDataBlocks
,
SArray
*
);
if
(
NULL
==
pPlan
->
pSubplans
)
{
}
else
{
nodesDestroyNode
(
pPlan
);
(
*
pSubLogicPlan
)
->
subplanType
=
SUBPLAN_TYPE_SCAN
;
return
NULL
;
}
}
(
*
pSubLogicPlan
)
->
id
.
queryId
=
pCxt
->
pPlanCxt
->
queryId
;
pPlan
->
queryId
=
pCxt
->
pPlanCxt
->
queryId
;
setLogicNodeParent
((
*
pSubLogicPlan
)
->
pNode
);
return
pPlan
;
return
applySplitRule
(
*
pSubLogicPlan
);
}
}
static
int32_t
pushSubplan
(
SPhysiPlanContext
*
pCxt
,
SNodeptr
pSubplan
,
int32_t
level
,
SNodeList
*
pSubplans
)
{
static
int32_t
pushSubplan
(
SPhysiPlanContext
*
pCxt
,
SNodeptr
pSubplan
,
int32_t
level
,
SNodeList
*
pSubplans
)
{
...
@@ -705,193 +860,65 @@ static int32_t pushSubplan(SPhysiPlanContext* pCxt, SNodeptr pSubplan, int32_t l
...
@@ -705,193 +860,65 @@ static int32_t pushSubplan(SPhysiPlanContext* pCxt, SNodeptr pSubplan, int32_t l
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
SSubLogicPlan
*
singleCloneSubLogicPlan
(
SPhysiPlanContext
*
pCxt
,
SSubLogicPlan
*
pSrc
,
int32_t
level
)
{
static
int32_t
buildPhysiPlan
(
SPhysiPlanContext
*
pCxt
,
SLogicSubplan
*
pLogicSubplan
,
SSubplan
*
pParent
,
SQueryPlan
*
pQueryPlan
)
{
SSubLogicPlan
*
pDst
=
nodesMakeNode
(
QUERY_NODE_LOGIC_SUBPLAN
);
SSubplan
*
pSubplan
=
NULL
;
CHECK_ALLOC
(
pDst
,
NULL
);
int32_t
code
=
createPhysiSubplan
(
pCxt
,
pLogicSubplan
,
&
pSubplan
);
pDst
->
pNode
=
nodesCloneNode
(
pSrc
->
pNode
);
if
(
NULL
==
pDst
->
pNode
)
{
nodesDestroyNode
(
pDst
);
return
NULL
;
}
pDst
->
subplanType
=
pSrc
->
subplanType
;
pDst
->
level
=
level
;
pDst
->
id
.
queryId
=
pSrc
->
id
.
queryId
;
pDst
->
id
.
groupId
=
pSrc
->
id
.
groupId
;
pDst
->
id
.
subplanId
=
pCxt
->
subplanId
++
;
return
pDst
;
}
static
int32_t
scaleOutForModify
(
SPhysiPlanContext
*
pCxt
,
SSubLogicPlan
*
pSubplan
,
int32_t
level
,
SNodeList
*
pGroup
)
{
SVnodeModifLogicNode
*
pNode
=
(
SVnodeModifLogicNode
*
)
pSubplan
->
pNode
;
size_t
numOfVgroups
=
taosArrayGetSize
(
pNode
->
pDataBlocks
);
for
(
int32_t
i
=
0
;
i
<
numOfVgroups
;
++
i
)
{
SSubLogicPlan
*
pNewSubplan
=
singleCloneSubLogicPlan
(
pCxt
,
pSubplan
,
level
);
CHECK_ALLOC
(
pNewSubplan
,
TSDB_CODE_OUT_OF_MEMORY
);
SVgDataBlocks
*
blocks
=
(
SVgDataBlocks
*
)
taosArrayGetP
(
pNode
->
pDataBlocks
,
i
);
((
SVnodeModifLogicNode
*
)
pNewSubplan
->
pNode
)
->
pVgDataBlocks
=
blocks
;
CHECK_CODE_EXT
(
nodesListAppend
(
pGroup
,
pNewSubplan
));
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
scaleOutForMerge
(
SPhysiPlanContext
*
pCxt
,
SSubLogicPlan
*
pSubplan
,
int32_t
level
,
SNodeList
*
pGroup
)
{
return
nodesListStrictAppend
(
pGroup
,
singleCloneSubLogicPlan
(
pCxt
,
pSubplan
,
level
));
}
static
int32_t
doSetScanVgroup
(
SPhysiPlanContext
*
pCxt
,
SLogicNode
*
pNode
,
const
SVgroupInfo
*
pVgroup
,
bool
*
pFound
)
{
if
(
QUERY_NODE_LOGIC_PLAN_SCAN
==
nodeType
(
pNode
))
{
SScanLogicNode
*
pScan
=
(
SScanLogicNode
*
)
pNode
;
pScan
->
pVgroupList
=
calloc
(
1
,
sizeof
(
SVgroupsInfo
)
+
sizeof
(
SVgroupInfo
));
CHECK_ALLOC
(
pScan
->
pVgroupList
,
TSDB_CODE_OUT_OF_MEMORY
);
memcpy
(
pScan
->
pVgroupList
->
vgroups
,
pVgroup
,
sizeof
(
SVgroupInfo
));
*
pFound
=
true
;
return
TSDB_CODE_SUCCESS
;
}
SNode
*
pChild
=
NULL
;
FOREACH
(
pChild
,
pNode
->
pChildren
)
{
int32_t
code
=
doSetScanVgroup
(
pCxt
,
(
SLogicNode
*
)
pChild
,
pVgroup
,
pFound
);
if
(
TSDB_CODE_SUCCESS
!=
code
||
*
pFound
)
{
return
code
;
}
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
setScanVgroup
(
SPhysiPlanContext
*
pCxt
,
SLogicNode
*
pNode
,
const
SVgroupInfo
*
pVgroup
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
bool
found
=
false
;
code
=
pushSubplan
(
pCxt
,
pSubplan
,
pLogicSubplan
->
level
,
pQueryPlan
->
pSubplans
);
return
doSetScanVgroup
(
pCxt
,
pNode
,
pVgroup
,
&
found
);
++
(
pQueryPlan
->
numOfSubplans
);
}
static
int32_t
scaleOutForScan
(
SPhysiPlanContext
*
pCxt
,
SSubLogicPlan
*
pSubplan
,
int32_t
level
,
SNodeList
*
pGroup
)
{
if
(
pSubplan
->
pVgroupList
)
{
for
(
int32_t
i
=
0
;
i
<
pSubplan
->
pVgroupList
->
numOfVgroups
;
++
i
)
{
SSubLogicPlan
*
pNewSubplan
=
singleCloneSubLogicPlan
(
pCxt
,
pSubplan
,
level
);
CHECK_ALLOC
(
pNewSubplan
,
TSDB_CODE_OUT_OF_MEMORY
);
CHECK_CODE_EXT
(
setScanVgroup
(
pCxt
,
pNewSubplan
->
pNode
,
pSubplan
->
pVgroupList
->
vgroups
+
i
));
CHECK_CODE_EXT
(
nodesListAppend
(
pGroup
,
pNewSubplan
));
}
return
TSDB_CODE_SUCCESS
;
}
else
{
return
scaleOutForMerge
(
pCxt
,
pSubplan
,
level
,
pGroup
);
}
}
}
static
int32_t
appendWithMakeList
(
SNodeList
**
pList
,
SNodeptr
pNode
)
{
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pParent
)
{
if
(
NULL
==
*
pList
)
{
code
=
nodesListMakeAppend
(
&
pParent
->
pChildren
,
pSubplan
);
*
pList
=
nodesMakeList
();
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
NULL
==
*
pList
)
{
code
=
nodesListMakeAppend
(
&
pSubplan
->
pParents
,
pParent
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
}
}
return
nodesListAppend
(
*
pList
,
pNode
);
}
static
int32_t
pushHierarchicalPlan
(
SPhysiPlanContext
*
pCxt
,
SNodeList
*
pParentsGroup
,
SNodeList
*
pCurrentGroup
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
bool
topLevel
=
(
0
==
LIST_LENGTH
(
pParentsGroup
));
SNode
*
pChild
=
NULL
;
SNode
*
pChild
=
NULL
;
FOREACH
(
pChild
,
pCurrentGroup
)
{
FOREACH
(
pChild
,
pLogicSubplan
->
pChildren
)
{
if
(
topLevel
)
{
code
=
buildPhysiPlan
(
pCxt
,
(
SLogicSubplan
*
)
pChild
,
pSubplan
,
pQueryPlan
);
CHECK_CODE_EXT
(
nodesListAppend
(
pParentsGroup
,
pChild
));
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
}
else
{
break
;
SNode
*
pParent
=
NULL
;
FOREACH
(
pParent
,
pParentsGroup
)
{
CHECK_CODE_EXT
(
appendWithMakeList
(
&
(((
SSubLogicPlan
*
)
pParent
)
->
pChildren
),
pChild
));
CHECK_CODE_EXT
(
appendWithMakeList
(
&
(((
SSubLogicPlan
*
)
pChild
)
->
pParents
),
pParent
));
}
}
}
}
}
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
doScaleOut
(
SPhysiPlanContext
*
pCxt
,
SSubLogicPlan
*
pSubplan
,
int32_t
*
pLevel
,
SNodeList
*
pParentsGroup
)
{
SNodeList
*
pCurrentGroup
=
nodesMakeList
();
CHECK_ALLOC
(
pCurrentGroup
,
TSDB_CODE_OUT_OF_MEMORY
);
int32_t
code
=
TSDB_CODE_SUCCESS
;
switch
(
pSubplan
->
subplanType
)
{
case
SUBPLAN_TYPE_MERGE
:
code
=
scaleOutForMerge
(
pCxt
,
pSubplan
,
*
pLevel
,
pCurrentGroup
);
break
;
case
SUBPLAN_TYPE_SCAN
:
code
=
scaleOutForScan
(
pCxt
,
pSubplan
,
*
pLevel
,
pCurrentGroup
);
break
;
case
SUBPLAN_TYPE_MODIFY
:
code
=
scaleOutForModify
(
pCxt
,
pSubplan
,
*
pLevel
,
pCurrentGroup
);
break
;
default:
break
;
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
code
;
nodesDestroyNode
(
pSubplan
)
;
}
}
CHECK_CODE_EXT
(
pushHierarchicalPlan
(
pCxt
,
pParentsGroup
,
pCurrentGroup
));
return
code
;
++
(
*
pLevel
);
SNode
*
pChild
;
FOREACH
(
pChild
,
pSubplan
->
pChildren
)
{
CHECK_CODE_EXT
(
doScaleOut
(
pCxt
,
(
SSubLogicPlan
*
)
pChild
,
pLevel
,
pCurrentGroup
));
}
return
TSDB_CODE_SUCCESS
;
}
}
static
SQueryLogicPlan
*
makeQueryLogicPlan
(
SPhysiPlanContext
*
pCxt
)
{
static
int32_t
doCreatePhysiPlan
(
SPhysiPlanContext
*
pCxt
,
SQueryLogicPlan
*
pLogicPlan
,
SQueryPlan
**
pPhysiPlan
)
{
SQueryLogicPlan
*
pLogicPlan
=
(
SQueryLogicPlan
*
)
nodesMakeNode
(
QUERY_NODE_LOGIC_PLAN
);
SQueryPlan
*
pPlan
=
makeQueryPhysiPlan
(
pCxt
);
CHECK_ALLOC
(
pLogicPlan
,
NULL
);
if
(
NULL
==
pPlan
)
{
pLogicPlan
->
pTopSubplans
=
nodesMakeList
();
return
TSDB_CODE_OUT_OF_MEMORY
;
if
(
NULL
==
pLogicPlan
->
pTopSubplans
)
{
nodesDestroyNode
(
pLogicPlan
);
return
NULL
;
}
}
return
pLogicPlan
;
}
static
int32_t
scaleOutLogicPlan
(
SPhysiPlanContext
*
pCxt
,
SSubLogicPlan
*
pRootSubLogicPlan
,
SQueryLogicPlan
**
pLogicPlan
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
*
pLogicPlan
=
makeQueryLogicPlan
(
pCxt
);
CHECK_ALLOC
(
*
pLogicPlan
,
TSDB_CODE_OUT_OF_MEMORY
);
return
doScaleOut
(
pCxt
,
pRootSubLogicPlan
,
&
((
*
pLogicPlan
)
->
totalLevel
),
(
*
pLogicPlan
)
->
pTopSubplans
);
}
static
SQueryPlan
*
makeQueryPhysiPlan
(
SPhysiPlanContext
*
pCxt
)
{
SNode
*
pSubplan
=
NULL
;
SQueryPlan
*
pPlan
=
nodesMakeNode
(
QUERY_NODE_PHYSICAL_PLAN
);
FOREACH
(
pSubplan
,
pLogicPlan
->
pTopSubplans
)
{
CHECK_ALLOC
(
pPlan
,
NULL
);
code
=
buildPhysiPlan
(
pCxt
,
(
SLogicSubplan
*
)
pSubplan
,
NULL
,
pPlan
);
pPlan
->
pSubplans
=
nodesMakeList
();
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
NULL
==
pPlan
->
pSubplans
)
{
break
;
nodesDestroyNode
(
pPlan
);
return
NULL
;
}
}
pPlan
->
queryId
=
pCxt
->
pPlanCxt
->
queryId
;
return
pPlan
;
}
static
int32_t
doBuildPhysiPlan
(
SPhysiPlanContext
*
pCxt
,
SSubLogicPlan
*
pLogicSubplan
,
SSubplan
*
pParent
,
SQueryPlan
*
pQueryPlan
)
{
SSubplan
*
pSubplan
=
createPhysiSubplan
(
pCxt
,
pLogicSubplan
);
CHECK_ALLOC
(
pSubplan
,
TSDB_CODE_OUT_OF_MEMORY
);
CHECK_CODE_EXT
(
pushSubplan
(
pCxt
,
pSubplan
,
pLogicSubplan
->
level
,
pQueryPlan
->
pSubplans
));
++
(
pQueryPlan
->
numOfSubplans
);
if
(
NULL
!=
pParent
)
{
CHECK_CODE_EXT
(
appendWithMakeList
(
&
pParent
->
pChildren
,
pSubplan
));
CHECK_CODE_EXT
(
appendWithMakeList
(
&
pSubplan
->
pParents
,
pParent
));
}
}
SNode
*
pChild
=
NULL
;
if
(
TSDB_CODE_SUCCESS
==
code
)
{
FOREACH
(
pChild
,
pLogicSubplan
->
pChildren
)
{
*
pPhysiPlan
=
pPlan
;
CHECK_CODE_EXT
(
doBuildPhysiPlan
(
pCxt
,
(
SSubLogicPlan
*
)
pChild
,
pSubplan
,
pQueryPlan
));
}
else
{
nodesDestroyNode
(
pPlan
);
}
}
return
TSDB_CODE_SUCCESS
;
return
code
;
}
static
int32_t
buildPhysiPlan
(
SPhysiPlanContext
*
pCxt
,
SQueryLogicPlan
*
pLogicPlan
,
SQueryPlan
**
pPlan
)
{
*
pPlan
=
makeQueryPhysiPlan
(
pCxt
);
CHECK_ALLOC
(
*
pPlan
,
TSDB_CODE_OUT_OF_MEMORY
);
SNode
*
pSubplan
=
NULL
;
FOREACH
(
pSubplan
,
pLogicPlan
->
pTopSubplans
)
{
CHECK_CODE_EXT
(
doBuildPhysiPlan
(
pCxt
,
(
SSubLogicPlan
*
)
pSubplan
,
NULL
,
*
pPlan
));
}
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
createPhysiPlan
(
SPlanContext
*
pCxt
,
S
LogicNode
*
pLogicNode
,
SQueryPlan
**
pPlan
,
SArray
*
pExecNodeList
)
{
int32_t
createPhysiPlan
(
SPlanContext
*
pCxt
,
S
QueryLogicPlan
*
pLogicPlan
,
SQueryPlan
**
pPlan
,
SArray
*
pExecNodeList
)
{
SPhysiPlanContext
cxt
=
{
SPhysiPlanContext
cxt
=
{
.
pPlanCxt
=
pCxt
,
.
pPlanCxt
=
pCxt
,
.
errCode
=
TSDB_CODE_SUCCESS
,
.
errCode
=
TSDB_CODE_SUCCESS
,
...
@@ -902,16 +929,5 @@ int32_t createPhysiPlan(SPlanContext* pCxt, SLogicNode* pLogicNode, SQueryPlan**
...
@@ -902,16 +929,5 @@ int32_t createPhysiPlan(SPlanContext* pCxt, SLogicNode* pLogicNode, SQueryPlan**
if
(
NULL
==
cxt
.
pLocationHelper
)
{
if
(
NULL
==
cxt
.
pLocationHelper
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
SQueryLogicPlan
*
pLogicPlan
=
NULL
;
return
doCreatePhysiPlan
(
&
cxt
,
pLogicPlan
,
pPlan
);
SSubLogicPlan
*
pSubLogicPlan
=
NULL
;
int32_t
code
=
splitLogicPlan
(
&
cxt
,
pLogicNode
,
&
pSubLogicPlan
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
scaleOutLogicPlan
(
&
cxt
,
pSubLogicPlan
,
&
pLogicPlan
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
buildPhysiPlan
(
&
cxt
,
pLogicPlan
,
pPlan
);
}
nodesDestroyNode
(
pSubLogicPlan
);
nodesDestroyNode
(
pLogicPlan
);
return
code
;
}
}
source/libs/planner/src/planScaleOut.c
0 → 100644
浏览文件 @
3e455e37
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "planInt.h"
typedef
struct
SScaleOutContext
{
SPlanContext
*
pPlanCxt
;
int32_t
subplanId
;
}
SScaleOutContext
;
static
SLogicSubplan
*
singleCloneSubLogicPlan
(
SScaleOutContext
*
pCxt
,
SLogicSubplan
*
pSrc
,
int32_t
level
)
{
SLogicSubplan
*
pDst
=
nodesMakeNode
(
QUERY_NODE_LOGIC_SUBPLAN
);
if
(
NULL
==
pDst
)
{
return
NULL
;
}
pDst
->
pNode
=
nodesCloneNode
(
pSrc
->
pNode
);
if
(
NULL
==
pDst
->
pNode
)
{
nodesDestroyNode
(
pDst
);
return
NULL
;
}
pDst
->
subplanType
=
pSrc
->
subplanType
;
pDst
->
level
=
level
;
pDst
->
id
.
queryId
=
pSrc
->
id
.
queryId
;
pDst
->
id
.
groupId
=
pSrc
->
id
.
groupId
;
pDst
->
id
.
subplanId
=
pCxt
->
subplanId
++
;
return
pDst
;
}
static
int32_t
scaleOutForModify
(
SScaleOutContext
*
pCxt
,
SLogicSubplan
*
pSubplan
,
int32_t
level
,
SNodeList
*
pGroup
)
{
SVnodeModifLogicNode
*
pNode
=
(
SVnodeModifLogicNode
*
)
pSubplan
->
pNode
;
size_t
numOfVgroups
=
taosArrayGetSize
(
pNode
->
pDataBlocks
);
for
(
int32_t
i
=
0
;
i
<
numOfVgroups
;
++
i
)
{
SLogicSubplan
*
pNewSubplan
=
singleCloneSubLogicPlan
(
pCxt
,
pSubplan
,
level
);
if
(
NULL
==
pNewSubplan
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
((
SVnodeModifLogicNode
*
)
pNewSubplan
->
pNode
)
->
pVgDataBlocks
=
(
SVgDataBlocks
*
)
taosArrayGetP
(
pNode
->
pDataBlocks
,
i
);
if
(
TSDB_CODE_SUCCESS
!=
nodesListStrictAppend
(
pGroup
,
pNewSubplan
))
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
scaleOutForMerge
(
SScaleOutContext
*
pCxt
,
SLogicSubplan
*
pSubplan
,
int32_t
level
,
SNodeList
*
pGroup
)
{
return
nodesListStrictAppend
(
pGroup
,
singleCloneSubLogicPlan
(
pCxt
,
pSubplan
,
level
));
}
static
int32_t
doSetScanVgroup
(
SLogicNode
*
pNode
,
const
SVgroupInfo
*
pVgroup
,
bool
*
pFound
)
{
if
(
QUERY_NODE_LOGIC_PLAN_SCAN
==
nodeType
(
pNode
))
{
SScanLogicNode
*
pScan
=
(
SScanLogicNode
*
)
pNode
;
pScan
->
pVgroupList
=
calloc
(
1
,
sizeof
(
SVgroupsInfo
)
+
sizeof
(
SVgroupInfo
));
if
(
NULL
==
pScan
->
pVgroupList
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
memcpy
(
pScan
->
pVgroupList
->
vgroups
,
pVgroup
,
sizeof
(
SVgroupInfo
));
*
pFound
=
true
;
return
TSDB_CODE_SUCCESS
;
}
SNode
*
pChild
=
NULL
;
FOREACH
(
pChild
,
pNode
->
pChildren
)
{
int32_t
code
=
doSetScanVgroup
((
SLogicNode
*
)
pChild
,
pVgroup
,
pFound
);
if
(
TSDB_CODE_SUCCESS
!=
code
||
*
pFound
)
{
return
code
;
}
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
setScanVgroup
(
SLogicNode
*
pNode
,
const
SVgroupInfo
*
pVgroup
)
{
bool
found
=
false
;
return
doSetScanVgroup
(
pNode
,
pVgroup
,
&
found
);
}
static
int32_t
scaleOutForScan
(
SScaleOutContext
*
pCxt
,
SLogicSubplan
*
pSubplan
,
int32_t
level
,
SNodeList
*
pGroup
)
{
if
(
pSubplan
->
pVgroupList
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
for
(
int32_t
i
=
0
;
i
<
pSubplan
->
pVgroupList
->
numOfVgroups
;
++
i
)
{
SLogicSubplan
*
pNewSubplan
=
singleCloneSubLogicPlan
(
pCxt
,
pSubplan
,
level
);
if
(
NULL
==
pNewSubplan
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
code
=
setScanVgroup
(
pNewSubplan
->
pNode
,
pSubplan
->
pVgroupList
->
vgroups
+
i
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesListStrictAppend
(
pGroup
,
pNewSubplan
);
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
break
;
}
}
return
code
;
}
else
{
return
scaleOutForMerge
(
pCxt
,
pSubplan
,
level
,
pGroup
);
}
}
static
int32_t
pushHierarchicalPlan
(
SNodeList
*
pParentsGroup
,
SNodeList
*
pCurrentGroup
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
bool
topLevel
=
(
0
==
LIST_LENGTH
(
pParentsGroup
));
SNode
*
pChild
=
NULL
;
FOREACH
(
pChild
,
pCurrentGroup
)
{
if
(
topLevel
)
{
code
=
nodesListAppend
(
pParentsGroup
,
pChild
);
}
else
{
SNode
*
pParent
=
NULL
;
FOREACH
(
pParent
,
pParentsGroup
)
{
code
=
nodesListMakeAppend
(
&
(((
SLogicSubplan
*
)
pParent
)
->
pChildren
),
pChild
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesListMakeAppend
(
&
(((
SLogicSubplan
*
)
pChild
)
->
pParents
),
pParent
);
}
}
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
break
;
}
}
return
code
;
}
static
int32_t
doScaleOut
(
SScaleOutContext
*
pCxt
,
SLogicSubplan
*
pSubplan
,
int32_t
*
pLevel
,
SNodeList
*
pParentsGroup
)
{
SNodeList
*
pCurrentGroup
=
nodesMakeList
();
if
(
NULL
==
pCurrentGroup
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
int32_t
code
=
TSDB_CODE_SUCCESS
;
switch
(
pSubplan
->
subplanType
)
{
case
SUBPLAN_TYPE_MERGE
:
code
=
scaleOutForMerge
(
pCxt
,
pSubplan
,
*
pLevel
,
pCurrentGroup
);
break
;
case
SUBPLAN_TYPE_SCAN
:
code
=
scaleOutForScan
(
pCxt
,
pSubplan
,
*
pLevel
,
pCurrentGroup
);
break
;
case
SUBPLAN_TYPE_MODIFY
:
code
=
scaleOutForModify
(
pCxt
,
pSubplan
,
*
pLevel
,
pCurrentGroup
);
break
;
default:
break
;
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
pushHierarchicalPlan
(
pParentsGroup
,
pCurrentGroup
);
++
(
*
pLevel
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
SNode
*
pChild
;
FOREACH
(
pChild
,
pSubplan
->
pChildren
)
{
code
=
doScaleOut
(
pCxt
,
(
SLogicSubplan
*
)
pChild
,
pLevel
,
pCurrentGroup
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
break
;
}
}
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
nodesDestroyList
(
pCurrentGroup
);
}
return
code
;
}
static
SQueryLogicPlan
*
makeQueryLogicPlan
()
{
SQueryLogicPlan
*
pLogicPlan
=
(
SQueryLogicPlan
*
)
nodesMakeNode
(
QUERY_NODE_LOGIC_PLAN
);
if
(
NULL
==
pLogicPlan
)
{
return
NULL
;
}
pLogicPlan
->
pTopSubplans
=
nodesMakeList
();
if
(
NULL
==
pLogicPlan
->
pTopSubplans
)
{
nodesDestroyNode
(
pLogicPlan
);
return
NULL
;
}
return
pLogicPlan
;
}
int32_t
scaleOutLogicPlan
(
SPlanContext
*
pCxt
,
SLogicSubplan
*
pLogicSubplan
,
SQueryLogicPlan
**
pLogicPlan
)
{
SQueryLogicPlan
*
pPlan
=
makeQueryLogicPlan
();
if
(
NULL
==
pPlan
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
SScaleOutContext
cxt
=
{
.
pPlanCxt
=
pCxt
,
.
subplanId
=
1
};
int32_t
code
=
doScaleOut
(
&
cxt
,
pLogicSubplan
,
&
(
pPlan
->
totalLevel
),
pPlan
->
pTopSubplans
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pLogicPlan
=
pPlan
;
}
else
{
nodesDestroyNode
(
pPlan
);
}
return
code
;
}
source/libs/planner/src/planSpliter.c
浏览文件 @
3e455e37
...
@@ -29,7 +29,7 @@ typedef struct SSplitContext {
...
@@ -29,7 +29,7 @@ typedef struct SSplitContext {
void
*
pInfo
;
void
*
pInfo
;
}
SSplitContext
;
}
SSplitContext
;
typedef
int32_t
(
*
FMatch
)(
SSplitContext
*
pCxt
,
S
SubLogicP
lan
*
pSubplan
);
typedef
int32_t
(
*
FMatch
)(
SSplitContext
*
pCxt
,
S
LogicSubp
lan
*
pSubplan
);
typedef
int32_t
(
*
FSplit
)(
SSplitContext
*
pCxt
);
typedef
int32_t
(
*
FSplit
)(
SSplitContext
*
pCxt
);
typedef
struct
SSplitRule
{
typedef
struct
SSplitRule
{
...
@@ -40,7 +40,7 @@ typedef struct SSplitRule {
...
@@ -40,7 +40,7 @@ typedef struct SSplitRule {
typedef
struct
SStsInfo
{
typedef
struct
SStsInfo
{
SScanLogicNode
*
pScan
;
SScanLogicNode
*
pScan
;
S
SubLogicP
lan
*
pSubplan
;
S
LogicSubp
lan
*
pSubplan
;
}
SStsInfo
;
}
SStsInfo
;
static
SLogicNode
*
stsMatchByNode
(
SLogicNode
*
pNode
)
{
static
SLogicNode
*
stsMatchByNode
(
SLogicNode
*
pNode
)
{
...
@@ -58,7 +58,7 @@ static SLogicNode* stsMatchByNode(SLogicNode* pNode) {
...
@@ -58,7 +58,7 @@ static SLogicNode* stsMatchByNode(SLogicNode* pNode) {
return
NULL
;
return
NULL
;
}
}
static
int32_t
stsMatch
(
SSplitContext
*
pCxt
,
S
SubLogicP
lan
*
pSubplan
)
{
static
int32_t
stsMatch
(
SSplitContext
*
pCxt
,
S
LogicSubp
lan
*
pSubplan
)
{
if
(
SPLIT_FLAG_TEST_MASK
(
pSubplan
->
splitFlag
,
SPLIT_FLAG_STS
))
{
if
(
SPLIT_FLAG_TEST_MASK
(
pSubplan
->
splitFlag
,
SPLIT_FLAG_STS
))
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -74,7 +74,7 @@ static int32_t stsMatch(SSplitContext* pCxt, SSubLogicPlan* pSubplan) {
...
@@ -74,7 +74,7 @@ static int32_t stsMatch(SSplitContext* pCxt, SSubLogicPlan* pSubplan) {
}
}
SNode
*
pChild
;
SNode
*
pChild
;
FOREACH
(
pChild
,
pSubplan
->
pChildren
)
{
FOREACH
(
pChild
,
pSubplan
->
pChildren
)
{
int32_t
code
=
stsMatch
(
pCxt
,
(
S
SubLogicP
lan
*
)
pChild
);
int32_t
code
=
stsMatch
(
pCxt
,
(
S
LogicSubp
lan
*
)
pChild
);
if
(
TSDB_CODE_SUCCESS
!=
code
||
pCxt
->
match
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
||
pCxt
->
match
)
{
return
code
;
return
code
;
}
}
...
@@ -82,8 +82,8 @@ static int32_t stsMatch(SSplitContext* pCxt, SSubLogicPlan* pSubplan) {
...
@@ -82,8 +82,8 @@ static int32_t stsMatch(SSplitContext* pCxt, SSubLogicPlan* pSubplan) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
S
SubLogicP
lan
*
stsCreateScanSubplan
(
SSplitContext
*
pCxt
,
SScanLogicNode
*
pScan
)
{
static
S
LogicSubp
lan
*
stsCreateScanSubplan
(
SSplitContext
*
pCxt
,
SScanLogicNode
*
pScan
)
{
S
SubLogicP
lan
*
pSubplan
=
nodesMakeNode
(
QUERY_NODE_LOGIC_SUBPLAN
);
S
LogicSubp
lan
*
pSubplan
=
nodesMakeNode
(
QUERY_NODE_LOGIC_SUBPLAN
);
if
(
NULL
==
pSubplan
)
{
if
(
NULL
==
pSubplan
)
{
return
NULL
;
return
NULL
;
}
}
...
@@ -95,7 +95,7 @@ static SSubLogicPlan* stsCreateScanSubplan(SSplitContext* pCxt, SScanLogicNode*
...
@@ -95,7 +95,7 @@ static SSubLogicPlan* stsCreateScanSubplan(SSplitContext* pCxt, SScanLogicNode*
return
pSubplan
;
return
pSubplan
;
}
}
static
int32_t
stsCreateExchangeNode
(
SSplitContext
*
pCxt
,
S
SubLogicP
lan
*
pSubplan
,
SScanLogicNode
*
pScan
)
{
static
int32_t
stsCreateExchangeNode
(
SSplitContext
*
pCxt
,
S
LogicSubp
lan
*
pSubplan
,
SScanLogicNode
*
pScan
)
{
SExchangeLogicNode
*
pExchange
=
nodesMakeNode
(
QUERY_NODE_LOGIC_PLAN_EXCHANGE
);
SExchangeLogicNode
*
pExchange
=
nodesMakeNode
(
QUERY_NODE_LOGIC_PLAN_EXCHANGE
);
if
(
NULL
==
pExchange
)
{
if
(
NULL
==
pExchange
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
...
@@ -145,7 +145,7 @@ static const SSplitRule splitRuleSet[] = {
...
@@ -145,7 +145,7 @@ static const SSplitRule splitRuleSet[] = {
static
const
int32_t
splitRuleNum
=
(
sizeof
(
splitRuleSet
)
/
sizeof
(
SSplitRule
));
static
const
int32_t
splitRuleNum
=
(
sizeof
(
splitRuleSet
)
/
sizeof
(
SSplitRule
));
int32_t
applySplitRule
(
SSubLogicP
lan
*
pSubplan
)
{
static
int32_t
applySplitRule
(
SLogicSubp
lan
*
pSubplan
)
{
SSplitContext
cxt
=
{
.
errCode
=
TSDB_CODE_SUCCESS
,
.
groupId
=
pSubplan
->
id
.
groupId
+
1
,
.
match
=
false
,
.
pInfo
=
NULL
};
SSplitContext
cxt
=
{
.
errCode
=
TSDB_CODE_SUCCESS
,
.
groupId
=
pSubplan
->
id
.
groupId
+
1
,
.
match
=
false
,
.
pInfo
=
NULL
};
bool
split
=
false
;
bool
split
=
false
;
do
{
do
{
...
@@ -164,3 +164,45 @@ int32_t applySplitRule(SSubLogicPlan* pSubplan) {
...
@@ -164,3 +164,45 @@ int32_t applySplitRule(SSubLogicPlan* pSubplan) {
}
while
(
split
);
}
while
(
split
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
void
doSetLogicNodeParent
(
SLogicNode
*
pNode
,
SLogicNode
*
pParent
)
{
pNode
->
pParent
=
pParent
;
SNode
*
pChild
;
FOREACH
(
pChild
,
pNode
->
pChildren
)
{
doSetLogicNodeParent
((
SLogicNode
*
)
pChild
,
pNode
);
}
}
static
void
setLogicNodeParent
(
SLogicNode
*
pNode
)
{
doSetLogicNodeParent
(
pNode
,
NULL
);
}
int32_t
splitLogicPlan
(
SPlanContext
*
pCxt
,
SLogicNode
*
pLogicNode
,
SLogicSubplan
**
pLogicSubplan
)
{
SLogicSubplan
*
pSubplan
=
(
SLogicSubplan
*
)
nodesMakeNode
(
QUERY_NODE_LOGIC_SUBPLAN
);
if
(
NULL
==
pSubplan
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pSubplan
->
pNode
=
nodesCloneNode
(
pLogicNode
);
if
(
NULL
==
pSubplan
->
pNode
)
{
nodesDestroyNode
(
pSubplan
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
if
(
QUERY_NODE_LOGIC_PLAN_VNODE_MODIF
==
nodeType
(
pLogicNode
))
{
pSubplan
->
subplanType
=
SUBPLAN_TYPE_MODIFY
;
TSWAP
(((
SVnodeModifLogicNode
*
)
pLogicNode
)
->
pDataBlocks
,
((
SVnodeModifLogicNode
*
)
pSubplan
->
pNode
)
->
pDataBlocks
,
SArray
*
);
}
else
{
pSubplan
->
subplanType
=
SUBPLAN_TYPE_SCAN
;
}
pSubplan
->
id
.
queryId
=
pCxt
->
queryId
;
setLogicNodeParent
(
pSubplan
->
pNode
);
int32_t
code
=
applySplitRule
(
pSubplan
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pLogicSubplan
=
pSubplan
;
}
else
{
nodesDestroyNode
(
pSubplan
);
}
return
code
;
}
\ No newline at end of file
source/libs/planner/src/planner.c
浏览文件 @
3e455e37
...
@@ -17,20 +17,29 @@
...
@@ -17,20 +17,29 @@
#include "planInt.h"
#include "planInt.h"
int32_t
optimize
(
SPlanContext
*
pCxt
,
SLogicNode
*
pLogicNode
)
{
return
TSDB_CODE_SUCCESS
;
}
int32_t
qCreateQueryPlan
(
SPlanContext
*
pCxt
,
SQueryPlan
**
pPlan
,
SArray
*
pExecNodeList
)
{
int32_t
qCreateQueryPlan
(
SPlanContext
*
pCxt
,
SQueryPlan
**
pPlan
,
SArray
*
pExecNodeList
)
{
SLogicNode
*
pLogicNode
=
NULL
;
SLogicNode
*
pLogicNode
=
NULL
;
SLogicSubplan
*
pLogicSubplan
=
NULL
;
SQueryLogicPlan
*
pLogicPlan
=
NULL
;
int32_t
code
=
createLogicPlan
(
pCxt
,
&
pLogicNode
);
int32_t
code
=
createLogicPlan
(
pCxt
,
&
pLogicNode
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
optimize
(
pCxt
,
pLogicNode
);
code
=
optimize
LogicPlan
(
pCxt
,
pLogicNode
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createPhysiPlan
(
pCxt
,
pLogicNode
,
pPlan
,
pExecNodeList
);
code
=
splitLogicPlan
(
pCxt
,
pLogicNode
,
&
pLogicSubplan
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
scaleOutLogicPlan
(
pCxt
,
pLogicSubplan
,
&
pLogicPlan
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createPhysiPlan
(
pCxt
,
pLogicPlan
,
pPlan
,
pExecNodeList
);
}
nodesDestroyNode
(
pLogicNode
);
nodesDestroyNode
(
pLogicNode
);
nodesDestroyNode
(
pLogicSubplan
);
nodesDestroyNode
(
pLogicPlan
);
terrno
=
code
;
return
code
;
return
code
;
}
}
...
...
source/libs/planner/test/plannerTest.cpp
浏览文件 @
3e455e37
...
@@ -26,11 +26,6 @@ using namespace testing;
...
@@ -26,11 +26,6 @@ using namespace testing;
class
PlannerTest
:
public
Test
{
class
PlannerTest
:
public
Test
{
protected:
protected:
enum
TestTarget
{
TEST_LOGIC_PLAN
,
TEST_PHYSICAL_PLAN
};
void
setDatabase
(
const
string
&
acctId
,
const
string
&
db
)
{
void
setDatabase
(
const
string
&
acctId
,
const
string
&
db
)
{
acctId_
=
acctId
;
acctId_
=
acctId
;
db_
=
db
;
db_
=
db
;
...
@@ -46,7 +41,7 @@ protected:
...
@@ -46,7 +41,7 @@ protected:
cxt_
.
pSql
=
sqlBuf_
.
c_str
();
cxt_
.
pSql
=
sqlBuf_
.
c_str
();
}
}
bool
run
(
TestTarget
target
=
TEST_PHYSICAL_PLAN
)
{
bool
run
()
{
int32_t
code
=
qParseQuerySql
(
&
cxt_
,
&
query_
);
int32_t
code
=
qParseQuerySql
(
&
cxt_
,
&
query_
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
@@ -56,12 +51,12 @@ protected:
...
@@ -56,12 +51,12 @@ protected:
const
string
syntaxTreeStr
=
toString
(
query_
->
pRoot
,
false
);
const
string
syntaxTreeStr
=
toString
(
query_
->
pRoot
,
false
);
SLogicNode
*
pLogic
Plan
=
nullptr
;
SLogicNode
*
pLogic
Node
=
nullptr
;
SPlanContext
cxt
=
{
.
queryId
=
1
,
.
acctId
=
0
};
SPlanContext
cxt
=
{
.
queryId
=
1
,
.
acctId
=
0
};
setPlanContext
(
query_
,
&
cxt
);
setPlanContext
(
query_
,
&
cxt
);
code
=
createLogicPlan
(
&
cxt
,
&
pLogic
Plan
);
code
=
createLogicPlan
(
&
cxt
,
&
pLogic
Node
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
cout
<<
"sql:["
<<
cxt_
.
pSql
<<
"]
logic p
lan code:"
<<
code
<<
", strerror:"
<<
tstrerror
(
code
)
<<
endl
;
cout
<<
"sql:["
<<
cxt_
.
pSql
<<
"]
createLogicP
lan code:"
<<
code
<<
", strerror:"
<<
tstrerror
(
code
)
<<
endl
;
return
false
;
return
false
;
}
}
...
@@ -69,15 +64,29 @@ protected:
...
@@ -69,15 +64,29 @@ protected:
cout
<<
"syntax test : "
<<
endl
;
cout
<<
"syntax test : "
<<
endl
;
cout
<<
syntaxTreeStr
<<
endl
;
cout
<<
syntaxTreeStr
<<
endl
;
cout
<<
"unformatted logic plan : "
<<
endl
;
cout
<<
"unformatted logic plan : "
<<
endl
;
cout
<<
toString
((
const
SNode
*
)
pLogicPlan
,
false
)
<<
endl
;
cout
<<
toString
((
const
SNode
*
)
pLogicNode
,
false
)
<<
endl
;
SLogicSubplan
*
pLogicSubplan
=
nullptr
;
code
=
splitLogicPlan
(
&
cxt
,
pLogicNode
,
&
pLogicSubplan
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
cout
<<
"sql:["
<<
cxt_
.
pSql
<<
"] splitLogicPlan code:"
<<
code
<<
", strerror:"
<<
tstrerror
(
code
)
<<
endl
;
return
false
;
}
SQueryLogicPlan
*
pLogicPlan
=
NULL
;
code
=
scaleOutLogicPlan
(
&
cxt
,
pLogicSubplan
,
&
pLogicPlan
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
cout
<<
"sql:["
<<
cxt_
.
pSql
<<
"] createPhysiPlan code:"
<<
code
<<
", strerror:"
<<
tstrerror
(
code
)
<<
endl
;
return
false
;
}
if
(
TEST_PHYSICAL_PLAN
==
target
)
{
SQueryPlan
*
pPlan
=
nullptr
;
SQueryPlan
*
pPlan
=
nullptr
;
code
=
createPhysiPlan
(
&
cxt
,
pLogicPlan
,
&
pPlan
,
NULL
);
code
=
createPhysiPlan
(
&
cxt
,
pLogicPlan
,
&
pPlan
,
NULL
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
cout
<<
"sql:["
<<
cxt_
.
pSql
<<
"] physical p
lan code:"
<<
code
<<
", strerror:"
<<
tstrerror
(
code
)
<<
endl
;
cout
<<
"sql:["
<<
cxt_
.
pSql
<<
"] createPhysiP
lan code:"
<<
code
<<
", strerror:"
<<
tstrerror
(
code
)
<<
endl
;
return
false
;
return
false
;
}
}
cout
<<
"unformatted physical plan : "
<<
endl
;
cout
<<
"unformatted physical plan : "
<<
endl
;
cout
<<
toString
((
const
SNode
*
)
pPlan
,
false
)
<<
endl
;
cout
<<
toString
((
const
SNode
*
)
pPlan
,
false
)
<<
endl
;
SNode
*
pNode
;
SNode
*
pNode
;
...
@@ -88,7 +97,6 @@ protected:
...
@@ -88,7 +97,6 @@ protected:
cout
<<
toString
(
pSubplan
,
false
)
<<
endl
;
cout
<<
toString
(
pSubplan
,
false
)
<<
endl
;
}
}
}
}
}
return
true
;
return
true
;
}
}
...
@@ -120,14 +128,6 @@ private:
...
@@ -120,14 +128,6 @@ private:
cout
<<
"sql:["
<<
cxt_
.
pSql
<<
"] toString code:"
<<
code
<<
", strerror:"
<<
tstrerror
(
code
)
<<
endl
;
cout
<<
"sql:["
<<
cxt_
.
pSql
<<
"] toString code:"
<<
code
<<
", strerror:"
<<
tstrerror
(
code
)
<<
endl
;
return
string
();
return
string
();
}
}
SNode
*
pNode
;
code
=
nodesStringToNode
(
pStr
,
&
pNode
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tfree
(
pStr
);
cout
<<
"sql:["
<<
cxt_
.
pSql
<<
"] toObject code:"
<<
code
<<
", strerror:"
<<
tstrerror
(
code
)
<<
endl
;
return
string
();
}
nodesDestroyNode
(
pNode
);
string
str
(
pStr
);
string
str
(
pStr
);
tfree
(
pStr
);
tfree
(
pStr
);
return
str
;
return
str
;
...
@@ -185,6 +185,13 @@ TEST_F(PlannerTest, interval) {
...
@@ -185,6 +185,13 @@ TEST_F(PlannerTest, interval) {
ASSERT_TRUE
(
run
());
ASSERT_TRUE
(
run
());
}
}
TEST_F
(
PlannerTest
,
sessionWindow
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"SELECT count(*) FROM t1 session(ts, 10s)"
);
ASSERT_TRUE
(
run
());
}
TEST_F
(
PlannerTest
,
showTables
)
{
TEST_F
(
PlannerTest
,
showTables
)
{
setDatabase
(
"root"
,
"test"
);
setDatabase
(
"root"
,
"test"
);
...
...
tests/script/jenkins/basic.txt
浏览文件 @
3e455e37
...
@@ -15,10 +15,13 @@
...
@@ -15,10 +15,13 @@
# ---- insert
# ---- insert
./test.sh -f tsim/insert/basic0.sim
./test.sh -f tsim/insert/basic0.sim
./test.sh -f tsim/insert/basic1.sim
./test.sh -f tsim/insert/backquote.sim
./test.sh -f tsim/insert/null.sim
./test.sh -f tsim/insert/null.sim
# ---- query
# ---- query
./test.sh -f tsim/query/interval.sim
./test.sh -f tsim/query/interval.sim
#./test.sh -f tsim/query/interval-offset.sim
# ---- table
# ---- table
./test.sh -f tsim/table/basic1.sim
./test.sh -f tsim/table/basic1.sim
...
...
tests/script/tsim/db/basic7.sim
浏览文件 @
3e455e37
...
@@ -14,6 +14,7 @@ sql insert into tb1 values (now, 1);
...
@@ -14,6 +14,7 @@ sql insert into tb1 values (now, 1);
sql show stables
sql show stables
if $rows != 1 then
if $rows != 1 then
print $rows
return -1
return -1
endi
endi
...
...
tests/script/tsim/insert/backquote.sim
浏览文件 @
3e455e37
...
@@ -36,8 +36,9 @@ while $dbCnt < 2
...
@@ -36,8 +36,9 @@ while $dbCnt < 2
$dbCnt = $dbCnt + 1
$dbCnt = $dbCnt + 1
print =============== create super table, include all type
print =============== create super table, include all type
sql create table `stable` (`timestamp` timestamp, `int` int, `binary` binary(16), `nchar` nchar(16)) tags (`float` float, `Binary` binary(16), `Nchar` nchar(16))
print notes: after nchar show ok, modify binary to nchar
sql create table `Stable` (`timestamp` timestamp, `int` int, `Binary` binary(32), `Nchar` nchar(32)) tags (`float` float, `binary` binary(16), `nchar` nchar(16))
sql create table `stable` (`timestamp` timestamp, `int` int, `binary` binary(16), `nchar` binary(16)) tags (`float` float, `Binary` binary(16), `Nchar` nchar(16))
sql create table `Stable` (`timestamp` timestamp, `int` int, `Binary` binary(32), `Nchar` binary(32)) tags (`float` float, `binary` binary(16), `nchar` nchar(16))
sql show stables
sql show stables
print rows: $rows
print rows: $rows
...
@@ -47,11 +48,15 @@ while $dbCnt < 2
...
@@ -47,11 +48,15 @@ while $dbCnt < 2
return -1
return -1
endi
endi
if $data00 != Stable then
if $data00 != Stable then
if $data00 != stable then
return -1
return -1
endi
endi
endi
if $data10 != Stable then
if $data10 != stable then
if $data10 != stable then
return -1
return -1
endi
endi
endi
print =============== create child table
print =============== create child table
sql create table `table` using `stable` tags(100.0, 'stable+table', 'stable+table')
sql create table `table` using `stable` tags(100.0, 'stable+table', 'stable+table')
...
@@ -145,26 +150,26 @@ while $dbCnt < 2
...
@@ -145,26 +150,26 @@ while $dbCnt < 2
return -1
return -1
endi
endi
print =============== query data from st, but not support select * from super table, waiting fix
#
print =============== query data from st, but not support select * from super table, waiting fix
sql select count(*) from `stable`
#
sql select count(*) from `stable`
print rows: $rows
#
print rows: $rows
print $data00 $data01 $data02 $data03
#
print $data00 $data01 $data02 $data03
if $rows != 1 then
#
if $rows != 1 then
return -1
#
return -1
endi
#
endi
if $data00 != 4 then
#
if $data00 != 4 then
return -1
#
return -1
endi
#
endi
sql select count(*) from `Stable`
#
sql select count(*) from `Stable`
print rows: $rows
#
print rows: $rows
print $data00 $data01 $data02 $data03
#
print $data00 $data01 $data02 $data03
if $rows != 1 then
#
if $rows != 1 then
return -1
#
return -1
endi
#
endi
if $data00 != 4 then
#
if $data00 != 4 then
return -1
#
return -1
endi
#
endi
#sql select * from
st
#sql select * from
`stable`
#if $rows != 4 then
#if $rows != 4 then
# return -1
# return -1
#endi
#endi
...
@@ -178,7 +183,7 @@ system sh/exec.sh -n dnode1 -s start
...
@@ -178,7 +183,7 @@ system sh/exec.sh -n dnode1 -s start
$loop_cnt = 0
$loop_cnt = 0
check_dnode_ready:
check_dnode_ready:
$loop_cnt = $loop_cnt + 1
$loop_cnt = $loop_cnt + 1
sleep
1
00
sleep
2
00
if $loop_cnt == 10 then
if $loop_cnt == 10 then
print ====> dnode not ready!
print ====> dnode not ready!
return -1
return -1
...
@@ -228,11 +233,15 @@ while $dbCnt < 2
...
@@ -228,11 +233,15 @@ while $dbCnt < 2
return -1
return -1
endi
endi
if $data00 != Stable then
if $data00 != Stable then
if $data00 != stable then
return -1
return -1
endi
endi
endi
if $data10 != Stable then
if $data10 != stable then
if $data10 != stable then
return -1
return -1
endi
endi
endi
sql show tables
sql show tables
print rows: $rows
print rows: $rows
...
@@ -313,26 +322,26 @@ while $dbCnt < 2
...
@@ -313,26 +322,26 @@ while $dbCnt < 2
return -1
return -1
endi
endi
print =============== query data from st, but not support select * from super table, waiting fix
#
print =============== query data from st, but not support select * from super table, waiting fix
sql select count(*) from `stable`
#
sql select count(*) from `stable`
print rows: $rows
#
print rows: $rows
print $data00 $data01 $data02 $data03
#
print $data00 $data01 $data02 $data03
if $rows != 1 then
#
if $rows != 1 then
return -1
#
return -1
endi
#
endi
if $data00 != 4 then
#
if $data00 != 4 then
return -1
#
return -1
endi
#
endi
sql select count(*) from `Stable`
#
sql select count(*) from `Stable`
print rows: $rows
#
print rows: $rows
print $data00 $data01 $data02 $data03
#
print $data00 $data01 $data02 $data03
if $rows != 1 then
#
if $rows != 1 then
return -1
#
return -1
endi
#
endi
if $data00 != 4 then
#
if $data00 != 4 then
return -1
#
return -1
endi
#
endi
#sql select * from
st
#sql select * from
`stable`
#if $rows != 4 then
#if $rows != 4 then
# return -1
# return -1
#endi
#endi
...
...
tests/script/tsim/insert/basic1.sim
浏览文件 @
3e455e37
...
@@ -55,7 +55,8 @@ if $rows != 4 then
...
@@ -55,7 +55,8 @@ if $rows != 4 then
return -1
return -1
endi
endi
if $data01 != true then
if $data01 != 1 then
print expect 1, actual: $data01
return -1
return -1
endi
endi
...
@@ -80,7 +81,7 @@ system sh/exec.sh -n dnode1 -s start
...
@@ -80,7 +81,7 @@ system sh/exec.sh -n dnode1 -s start
$loop_cnt = 0
$loop_cnt = 0
check_dnode_ready:
check_dnode_ready:
$loop_cnt = $loop_cnt + 1
$loop_cnt = $loop_cnt + 1
sleep
1
00
sleep
2
00
if $loop_cnt == 10 then
if $loop_cnt == 10 then
print ====> dnode not ready!
print ====> dnode not ready!
return -1
return -1
...
@@ -105,7 +106,7 @@ if $rows != 4 then
...
@@ -105,7 +106,7 @@ if $rows != 4 then
return -1
return -1
endi
endi
if $data01 !=
true then
if $data01 !=
1 then
return -1
return -1
endi
endi
...
...
tests/script/tsim/testCaseSuite.sim
浏览文件 @
3e455e37
...
@@ -9,9 +9,9 @@ run tsim/db/error1.sim
...
@@ -9,9 +9,9 @@ run tsim/db/error1.sim
run tsim/dnode/basic1.sim
run tsim/dnode/basic1.sim
run tsim/insert/basic0.sim
run tsim/insert/basic0.sim
#run tsim/insert/basic1.sim # TD-14246
run tsim/insert/basic1.sim
#run tsim/insert/backquote.sim # TD-14261
run tsim/insert/backquote.sim
#
run tsim/insert/null.sim
run tsim/insert/null.sim
run tsim/query/interval.sim
run tsim/query/interval.sim
#run tsim/query/interval-offset.sim # TD-14266
#run tsim/query/interval-offset.sim # TD-14266
...
...
tools/shell/src/shellMain.c
浏览文件 @
3e455e37
...
@@ -58,7 +58,7 @@ static struct argp_option options[] = {
...
@@ -58,7 +58,7 @@ static struct argp_option options[] = {
{
"check"
,
'k'
,
"CHECK"
,
0
,
"Check tables."
},
{
"check"
,
'k'
,
"CHECK"
,
0
,
"Check tables."
},
{
"database"
,
'd'
,
"DATABASE"
,
0
,
"Database to use when connecting to the server."
},
{
"database"
,
'd'
,
"DATABASE"
,
0
,
"Database to use when connecting to the server."
},
{
"timezone"
,
'z'
,
"TIMEZONE"
,
0
,
"Time zone of the shell, default is local."
},
{
"timezone"
,
'z'
,
"TIMEZONE"
,
0
,
"Time zone of the shell, default is local."
},
{
"netrole"
,
'n'
,
"NETROLE"
,
0
,
"Net role when network connectivity test, default is startup, options: client|server|rpc|startup|sync|spee
n
|fqdn."
},
{
"netrole"
,
'n'
,
"NETROLE"
,
0
,
"Net role when network connectivity test, default is startup, options: client|server|rpc|startup|sync|spee
d
|fqdn."
},
{
"pktlen"
,
'l'
,
"PKTLEN"
,
0
,
"Packet length used for net test, default is 1000 bytes."
},
{
"pktlen"
,
'l'
,
"PKTLEN"
,
0
,
"Packet length used for net test, default is 1000 bytes."
},
{
"pktnum"
,
'N'
,
"PKTNUM"
,
0
,
"Packet numbers used for net test, default is 100."
},
{
"pktnum"
,
'N'
,
"PKTNUM"
,
0
,
"Packet numbers used for net test, default is 100."
},
// Shuduo: 3.0 does not support UDP any more
// Shuduo: 3.0 does not support UDP any more
...
...
tools/shell/src/tnettest.c
浏览文件 @
3e455e37
...
@@ -406,7 +406,7 @@ static int32_t taosNetCheckRpc(const char* serverFqdn, uint16_t port, uint16_t p
...
@@ -406,7 +406,7 @@ static int32_t taosNetCheckRpc(const char* serverFqdn, uint16_t port, uint16_t p
reqMsg
.
code
=
0
;
reqMsg
.
code
=
0
;
reqMsg
.
handle
=
NULL
;
// rpc handle returned to app
reqMsg
.
handle
=
NULL
;
// rpc handle returned to app
reqMsg
.
ahandle
=
NULL
;
// app handle set by client
reqMsg
.
ahandle
=
NULL
;
// app handle set by client
strcpy
(
reqMsg
.
pCont
,
"nettest"
);
strcpy
(
reqMsg
.
pCont
,
"
dnode-
nettest"
);
rpcSendRecv
(
pRpcConn
,
&
epSet
,
&
reqMsg
,
&
rspMsg
);
rpcSendRecv
(
pRpcConn
,
&
epSet
,
&
reqMsg
,
&
rspMsg
);
...
@@ -442,7 +442,7 @@ static void taosNetTestStartup(char *host, int32_t port) {
...
@@ -442,7 +442,7 @@ static void taosNetTestStartup(char *host, int32_t port) {
SStartupReq
*
pStep
=
malloc
(
sizeof
(
SStartupReq
));
SStartupReq
*
pStep
=
malloc
(
sizeof
(
SStartupReq
));
while
(
1
)
{
while
(
1
)
{
int32_t
code
=
taosNetCheckRpc
(
host
,
port
+
TSDB_PORT_DNODEDNODE
,
20
,
0
,
pStep
);
int32_t
code
=
taosNetCheckRpc
(
host
,
port
,
20
,
0
,
pStep
);
if
(
code
>
0
)
{
if
(
code
>
0
)
{
code
=
taosNetParseStartup
(
pStep
);
code
=
taosNetParseStartup
(
pStep
);
}
}
...
@@ -499,12 +499,11 @@ static void taosNetCheckSync(char *host, int32_t port) {
...
@@ -499,12 +499,11 @@ static void taosNetCheckSync(char *host, int32_t port) {
}
}
static
void
taosNetTestRpc
(
char
*
host
,
int32_t
startPort
,
int32_t
pkgLen
)
{
static
void
taosNetTestRpc
(
char
*
host
,
int32_t
startPort
,
int32_t
pkgLen
)
{
int32_t
endPort
=
startPort
+
TSDB_PORT_SYNC
;
char
spi
=
0
;
char
spi
=
0
;
uInfo
(
"check rpc, host:%s
startPort:%d endPort:%d pkgLen:%d
\n
"
,
host
,
startPort
,
end
Port
,
pkgLen
);
uInfo
(
"check rpc, host:%s
Port:%d pkgLen:%d
\n
"
,
host
,
start
Port
,
pkgLen
);
for
(
uint16_t
port
=
startPort
;
port
<
endPort
;
port
++
)
{
uint16_t
port
=
startPort
;
int32_t
sendpkgLen
;
int32_t
sendpkgLen
;
if
(
pkgLen
<=
tsRpcMaxUdpSize
)
{
if
(
pkgLen
<=
tsRpcMaxUdpSize
)
{
sendpkgLen
=
tsRpcMaxUdpSize
+
1000
;
sendpkgLen
=
tsRpcMaxUdpSize
+
1000
;
...
@@ -525,7 +524,7 @@ static void taosNetTestRpc(char *host, int32_t startPort, int32_t pkgLen) {
...
@@ -525,7 +524,7 @@ static void taosNetTestRpc(char *host, int32_t startPort, int32_t pkgLen) {
}
else
{
}
else
{
sendpkgLen
=
pkgLen
;
sendpkgLen
=
pkgLen
;
}
}
/*
tsRpcForceTcp = 0;
tsRpcForceTcp = 0;
ret = taosNetCheckRpc(host, port, pkgLen, spi, NULL);
ret = taosNetCheckRpc(host, port, pkgLen, spi, NULL);
if (ret < 0) {
if (ret < 0) {
...
@@ -533,14 +532,13 @@ static void taosNetTestRpc(char *host, int32_t startPort, int32_t pkgLen) {
...
@@ -533,14 +532,13 @@ static void taosNetTestRpc(char *host, int32_t startPort, int32_t pkgLen) {
} else {
} else {
printf("successed to test UDP port:%d\n", port);
printf("successed to test UDP port:%d\n", port);
}
}
}
*/
taosNetCheckSync
(
host
,
startPort
+
TSDB_PORT_SYNC
);
taosNetCheckSync
(
host
,
startPort
);
}
}
static
void
taosNetTestClient
(
char
*
host
,
int32_t
startPort
,
int32_t
pkgLen
)
{
static
void
taosNetTestClient
(
char
*
host
,
int32_t
startPort
,
int32_t
pkgLen
)
{
int32_t
endPort
=
startPort
+
11
;
uInfo
(
"work as client, host:%s Port:%d pkgLen:%d
\n
"
,
host
,
startPort
,
pkgLen
);
uInfo
(
"work as client, host:%s startPort:%d endPort:%d pkgLen:%d
\n
"
,
host
,
startPort
,
endPort
,
pkgLen
);
uint32_t
serverIp
=
taosGetIpv4FromFqdn
(
host
);
uint32_t
serverIp
=
taosGetIpv4FromFqdn
(
host
);
if
(
serverIp
==
0xFFFFFFFF
)
{
if
(
serverIp
==
0xFFFFFFFF
)
{
...
@@ -549,15 +547,14 @@ static void taosNetTestClient(char *host, int32_t startPort, int32_t pkgLen) {
...
@@ -549,15 +547,14 @@ static void taosNetTestClient(char *host, int32_t startPort, int32_t pkgLen) {
}
}
uInfo
(
"server ip:%s is resolved from host:%s"
,
taosIpStr
(
serverIp
),
host
);
uInfo
(
"server ip:%s is resolved from host:%s"
,
taosIpStr
(
serverIp
),
host
);
taosNetCheckPort
(
serverIp
,
startPort
,
end
Port
,
pkgLen
);
taosNetCheckPort
(
serverIp
,
startPort
,
start
Port
,
pkgLen
);
}
}
static
void
taosNetTestServer
(
char
*
host
,
int32_t
startPort
,
int32_t
pkgLen
)
{
static
void
taosNetTestServer
(
char
*
host
,
int32_t
startPort
,
int32_t
pkgLen
)
{
int32_t
endPort
=
startPort
+
11
;
uInfo
(
"work as server, host:%s Port:%d pkgLen:%d
\n
"
,
host
,
startPort
,
pkgLen
);
uInfo
(
"work as server, host:%s startPort:%d endPort:%d pkgLen:%d
\n
"
,
host
,
startPort
,
endPort
,
pkgLen
);
int32_t
port
=
startPort
;
int32_t
port
=
startPort
;
int32_t
num
=
endPort
-
startPort
+
1
;
int32_t
num
=
1
;
if
(
num
<
0
)
num
=
1
;
if
(
num
<
0
)
num
=
1
;
TdThread
*
pids
=
malloc
(
2
*
num
*
sizeof
(
TdThread
));
TdThread
*
pids
=
malloc
(
2
*
num
*
sizeof
(
TdThread
));
...
...
taos-tools
@
8145dd17
比较
f36b07f7
...
8145dd17
Subproject commit
f36b07f710d661dca88fdd70e73b5e3e16a960e0
Subproject commit
8145dd1713ab9e7652ea621ca7e6895fd0b21d65
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录