Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
bdbf365e
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看板
提交
bdbf365e
编写于
3月 25, 2022
作者:
L
Liu Jicong
浏览文件
操作
浏览文件
下载
差异文件
merge from 3.0
上级
59a4eec1
0439d0b8
变更
92
显示空白变更内容
内联
并排
Showing
92 changed file
with
3573 addition
and
1326 deletion
+3573
-1326
include/common/tmsg.h
include/common/tmsg.h
+10
-5
include/common/ttypes.h
include/common/ttypes.h
+1
-0
include/libs/nodes/cmdnodes.h
include/libs/nodes/cmdnodes.h
+2
-0
include/libs/parser/parser.h
include/libs/parser/parser.h
+2
-0
include/util/tdef.h
include/util/tdef.h
+4
-0
include/util/types.h
include/util/types.h
+2
-0
source/client/inc/clientInt.h
source/client/inc/clientInt.h
+1
-0
source/client/src/clientEnv.c
source/client/src/clientEnv.c
+7
-0
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+26
-7
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+3
-2
source/common/src/tglobal.c
source/common/src/tglobal.c
+4
-0
source/common/src/tmsg.c
source/common/src/tmsg.c
+1
-1
source/common/src/ttime.c
source/common/src/ttime.c
+21
-6
source/dnode/mgmt/bnode/src/bmWorker.c
source/dnode/mgmt/bnode/src/bmWorker.c
+5
-1
source/dnode/mgmt/container/inc/dnd.h
source/dnode/mgmt/container/inc/dnd.h
+12
-16
source/dnode/mgmt/container/inc/dndInt.h
source/dnode/mgmt/container/inc/dndInt.h
+1
-5
source/dnode/mgmt/container/src/dndExec.c
source/dnode/mgmt/container/src/dndExec.c
+8
-1
source/dnode/mgmt/container/src/dndInt.c
source/dnode/mgmt/container/src/dndInt.c
+7
-8
source/dnode/mgmt/container/src/dndMonitor.c
source/dnode/mgmt/container/src/dndMonitor.c
+26
-7
source/dnode/mgmt/container/src/dndMsg.c
source/dnode/mgmt/container/src/dndMsg.c
+1
-1
source/dnode/mgmt/container/src/dndObj.c
source/dnode/mgmt/container/src/dndObj.c
+2
-1
source/dnode/mgmt/container/src/dndTransport.c
source/dnode/mgmt/container/src/dndTransport.c
+56
-28
source/dnode/mgmt/dnode/src/dmFile.c
source/dnode/mgmt/dnode/src/dmFile.c
+1
-1
source/dnode/mgmt/dnode/src/dmInt.c
source/dnode/mgmt/dnode/src/dmInt.c
+2
-2
source/dnode/mgmt/dnode/src/dmMsg.c
source/dnode/mgmt/dnode/src/dmMsg.c
+19
-15
source/dnode/mgmt/dnode/src/dmWorker.c
source/dnode/mgmt/dnode/src/dmWorker.c
+3
-1
source/dnode/mgmt/mnode/src/mmInt.c
source/dnode/mgmt/mnode/src/mmInt.c
+2
-1
source/dnode/mgmt/mnode/src/mmMsg.c
source/dnode/mgmt/mnode/src/mmMsg.c
+82
-76
source/dnode/mgmt/mnode/src/mmWorker.c
source/dnode/mgmt/mnode/src/mmWorker.c
+2
-0
source/dnode/mgmt/qnode/src/qmMsg.c
source/dnode/mgmt/qnode/src/qmMsg.c
+9
-9
source/dnode/mgmt/qnode/src/qmWorker.c
source/dnode/mgmt/qnode/src/qmWorker.c
+2
-0
source/dnode/mgmt/snode/src/smMsg.c
source/dnode/mgmt/snode/src/smMsg.c
+2
-2
source/dnode/mgmt/snode/src/smWorker.c
source/dnode/mgmt/snode/src/smWorker.c
+2
-0
source/dnode/mgmt/vnode/src/vmInt.c
source/dnode/mgmt/vnode/src/vmInt.c
+4
-4
source/dnode/mgmt/vnode/src/vmMsg.c
source/dnode/mgmt/vnode/src/vmMsg.c
+45
-45
source/dnode/mgmt/vnode/src/vmWorker.c
source/dnode/mgmt/vnode/src/vmWorker.c
+2
-2
source/dnode/mnode/impl/CMakeLists.txt
source/dnode/mnode/impl/CMakeLists.txt
+1
-1
source/dnode/mnode/impl/src/mndSma.c
source/dnode/mnode/impl/src/mndSma.c
+1
-1
source/dnode/mnode/impl/src/mndStream.c
source/dnode/mnode/impl/src/mndStream.c
+10
-26
source/dnode/vnode/inc/tsdb.h
source/dnode/vnode/inc/tsdb.h
+32
-2
source/dnode/vnode/src/inc/tsdbDef.h
source/dnode/vnode/src/inc/tsdbDef.h
+1
-0
source/dnode/vnode/src/inc/tsdbSma.h
source/dnode/vnode/src/inc/tsdbSma.h
+2
-0
source/dnode/vnode/src/tq/tqRead.c
source/dnode/vnode/src/tq/tqRead.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbMemTable.c
source/dnode/vnode/src/tsdb/tsdbMemTable.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbSma.c
source/dnode/vnode/src/tsdb/tsdbSma.c
+165
-114
source/dnode/vnode/src/tsdb/tsdbWrite.c
source/dnode/vnode/src/tsdb/tsdbWrite.c
+1
-45
source/dnode/vnode/test/tsdbSmaTest.cpp
source/dnode/vnode/test/tsdbSmaTest.cpp
+11
-11
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+8
-3
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+129
-34
source/libs/function/CMakeLists.txt
source/libs/function/CMakeLists.txt
+45
-2
source/libs/function/inc/tudf.h
source/libs/function/inc/tudf.h
+98
-50
source/libs/function/inc/tudfInt.h
source/libs/function/inc/tudfInt.h
+100
-0
source/libs/function/inc/udfc.h
source/libs/function/inc/udfc.h
+110
-0
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+1
-2
source/libs/function/src/tudf.c
source/libs/function/src/tudf.c
+859
-129
source/libs/function/src/udfd.c
source/libs/function/src/udfd.c
+356
-0
source/libs/function/test/runUdf.c
source/libs/function/test/runUdf.c
+45
-0
source/libs/function/test/udf1.c
source/libs/function/test/udf1.c
+20
-0
source/libs/nodes/src/nodesCloneFuncs.c
source/libs/nodes/src/nodesCloneFuncs.c
+2
-2
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+44
-3
source/libs/parser/inc/parAst.h
source/libs/parser/inc/parAst.h
+2
-2
source/libs/parser/inc/parInsertData.h
source/libs/parser/inc/parInsertData.h
+1
-1
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+5
-4
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+4
-2
source/libs/parser/src/parInsert.c
source/libs/parser/src/parInsert.c
+2
-20
source/libs/parser/src/parInsertData.c
source/libs/parser/src/parInsertData.c
+0
-1
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+115
-37
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+275
-274
source/libs/parser/test/parserAstTest.cpp
source/libs/parser/test/parserAstTest.cpp
+0
-3
source/libs/parser/test/parserInsertTest.cpp
source/libs/parser/test/parserInsertTest.cpp
+1
-1
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+28
-0
source/libs/planner/test/plannerTest.cpp
source/libs/planner/test/plannerTest.cpp
+17
-1
source/libs/sync/inc/syncRaftEntry.h
source/libs/sync/inc/syncRaftEntry.h
+9
-0
source/libs/sync/src/syncAppendEntries.c
source/libs/sync/src/syncAppendEntries.c
+6
-3
source/libs/sync/src/syncCommit.c
source/libs/sync/src/syncCommit.c
+1
-1
source/libs/sync/src/syncIO.c
source/libs/sync/src/syncIO.c
+19
-16
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+53
-6
source/libs/sync/src/syncRaftEntry.c
source/libs/sync/src/syncRaftEntry.c
+19
-0
source/libs/sync/src/syncRaftLog.c
source/libs/sync/src/syncRaftLog.c
+13
-9
source/libs/sync/test/CMakeLists.txt
source/libs/sync/test/CMakeLists.txt
+14
-0
source/libs/sync/test/syncEntryTest.cpp
source/libs/sync/test/syncEntryTest.cpp
+17
-1
source/libs/sync/test/syncReplicateLoadTest.cpp
source/libs/sync/test/syncReplicateLoadTest.cpp
+3
-2
source/libs/sync/test/syncReplicateTest.cpp
source/libs/sync/test/syncReplicateTest.cpp
+7
-5
source/libs/sync/test/syncReplicateTest2.cpp
source/libs/sync/test/syncReplicateTest2.cpp
+6
-4
source/libs/sync/test/syncReplicateTest3.cpp
source/libs/sync/test/syncReplicateTest3.cpp
+217
-0
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+1
-1
tests/script/tsim/insert/backquote.sim
tests/script/tsim/insert/backquote.sim
+32
-31
tests/script/tsim/insert/basic0.sim
tests/script/tsim/insert/basic0.sim
+100
-4
tests/script/tsim/query/interval-offset.sim
tests/script/tsim/query/interval-offset.sim
+173
-214
tests/script/tsim/table/basic1.sim
tests/script/tsim/table/basic1.sim
+4
-0
tools/shell/src/shellMain.c
tools/shell/src/shellMain.c
+6
-8
tools/taos-tools
tools/taos-tools
+1
-1
未找到文件。
include/common/tmsg.h
浏览文件 @
bdbf365e
...
@@ -207,7 +207,7 @@ typedef struct {
...
@@ -207,7 +207,7 @@ typedef struct {
// Submit message for one table
// Submit message for one table
typedef
struct
SSubmitBlk
{
typedef
struct
SSubmitBlk
{
int64_t
uid
;
// table unique id
int64_t
uid
;
// table unique id
int
32_t
tid
;
//
table id
int
64_t
suid
;
// s
table id
int32_t
padding
;
// TODO just for padding here
int32_t
padding
;
// TODO just for padding here
int32_t
sversion
;
// data schema version
int32_t
sversion
;
// data schema version
int32_t
dataLen
;
// data part length, not including the SSubmitBlk head
int32_t
dataLen
;
// data part length, not including the SSubmitBlk head
...
@@ -234,10 +234,10 @@ typedef struct {
...
@@ -234,10 +234,10 @@ typedef struct {
typedef
struct
{
typedef
struct
{
int32_t
totalLen
;
int32_t
totalLen
;
int32_t
len
;
int32_t
len
;
void
*
pMsg
;
const
void
*
pMsg
;
}
SSubmitMsgIter
;
}
SSubmitMsgIter
;
int32_t
tInitSubmitMsgIter
(
SSubmitReq
*
pMsg
,
SSubmitMsgIter
*
pIter
);
int32_t
tInitSubmitMsgIter
(
const
SSubmitReq
*
pMsg
,
SSubmitMsgIter
*
pIter
);
int32_t
tGetSubmitMsgNext
(
SSubmitMsgIter
*
pIter
,
SSubmitBlk
**
pPBlock
);
int32_t
tGetSubmitMsgNext
(
SSubmitMsgIter
*
pIter
,
SSubmitBlk
**
pPBlock
);
int32_t
tInitSubmitBlkIter
(
SSubmitBlk
*
pBlock
,
SSubmitBlkIter
*
pIter
);
int32_t
tInitSubmitBlkIter
(
SSubmitBlk
*
pBlock
,
SSubmitBlkIter
*
pIter
);
STSRow
*
tGetSubmitBlkNext
(
SSubmitBlkIter
*
pIter
);
STSRow
*
tGetSubmitBlkNext
(
SSubmitBlkIter
*
pIter
);
...
@@ -2093,6 +2093,11 @@ static FORCE_INLINE void tdDestroyTSmaWrapper(STSmaWrapper* pSW) {
...
@@ -2093,6 +2093,11 @@ static FORCE_INLINE void tdDestroyTSmaWrapper(STSmaWrapper* pSW) {
}
}
}
}
static
FORCE_INLINE
void
tdFreeTSmaWrapper
(
STSmaWrapper
*
pSW
)
{
tdDestroyTSmaWrapper
(
pSW
);
tfree
(
pSW
);
}
static
FORCE_INLINE
int32_t
tEncodeTSma
(
void
**
buf
,
const
STSma
*
pSma
)
{
static
FORCE_INLINE
int32_t
tEncodeTSma
(
void
**
buf
,
const
STSma
*
pSma
)
{
int32_t
tlen
=
0
;
int32_t
tlen
=
0
;
...
...
include/common/ttypes.h
浏览文件 @
bdbf365e
...
@@ -159,6 +159,7 @@ typedef struct {
...
@@ -159,6 +159,7 @@ typedef struct {
(IS_SIGNED_NUMERIC_TYPE(_t) || (_t) == (TSDB_DATA_TYPE_BOOL) || (_t) == (TSDB_DATA_TYPE_TIMESTAMP))
(IS_SIGNED_NUMERIC_TYPE(_t) || (_t) == (TSDB_DATA_TYPE_BOOL) || (_t) == (TSDB_DATA_TYPE_TIMESTAMP))
#define IS_CONVERT_AS_UNSIGNED(_t) (IS_UNSIGNED_NUMERIC_TYPE(_t) || (_t) == (TSDB_DATA_TYPE_BOOL))
#define IS_CONVERT_AS_UNSIGNED(_t) (IS_UNSIGNED_NUMERIC_TYPE(_t) || (_t) == (TSDB_DATA_TYPE_BOOL))
// TODO remove this function
static
FORCE_INLINE
bool
isNull
(
const
void
*
val
,
int32_t
type
)
{
static
FORCE_INLINE
bool
isNull
(
const
void
*
val
,
int32_t
type
)
{
switch
(
type
)
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_BOOL
:
...
...
include/libs/nodes/cmdnodes.h
浏览文件 @
bdbf365e
...
@@ -199,6 +199,7 @@ typedef struct SIndexOptions {
...
@@ -199,6 +199,7 @@ typedef struct SIndexOptions {
typedef
struct
SCreateIndexStmt
{
typedef
struct
SCreateIndexStmt
{
ENodeType
type
;
ENodeType
type
;
EIndexType
indexType
;
EIndexType
indexType
;
bool
ignoreExists
;
char
indexName
[
TSDB_INDEX_NAME_LEN
];
char
indexName
[
TSDB_INDEX_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
SNodeList
*
pCols
;
SNodeList
*
pCols
;
...
@@ -207,6 +208,7 @@ typedef struct SCreateIndexStmt {
...
@@ -207,6 +208,7 @@ typedef struct SCreateIndexStmt {
typedef
struct
SDropIndexStmt
{
typedef
struct
SDropIndexStmt
{
ENodeType
type
;
ENodeType
type
;
bool
ignoreNotExists
;
char
indexName
[
TSDB_INDEX_NAME_LEN
];
char
indexName
[
TSDB_INDEX_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
}
SDropIndexStmt
;
}
SDropIndexStmt
;
...
...
include/libs/parser/parser.h
浏览文件 @
bdbf365e
...
@@ -60,6 +60,8 @@ int32_t qParseQuerySql(SParseContext* pCxt, SQuery** pQuery);
...
@@ -60,6 +60,8 @@ int32_t qParseQuerySql(SParseContext* pCxt, SQuery** pQuery);
void
qDestroyQuery
(
SQuery
*
pQueryNode
);
void
qDestroyQuery
(
SQuery
*
pQueryNode
);
int32_t
qExtractResultSchema
(
const
SNode
*
pRoot
,
int32_t
*
numOfCols
,
SSchema
**
pSchema
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
include/util/tdef.h
浏览文件 @
bdbf365e
...
@@ -453,6 +453,10 @@ enum {
...
@@ -453,6 +453,10 @@ enum {
SND_WORKER_TYPE__UNIQUE
,
SND_WORKER_TYPE__UNIQUE
,
};
};
#define MND_VGID -1
#define QND_VGID 1
#define VND_VGID 0
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
include/util/types.h
浏览文件 @
bdbf365e
...
@@ -84,6 +84,8 @@ typedef uint16_t VarDataLenT; // maxVarDataLen: 32767
...
@@ -84,6 +84,8 @@ typedef uint16_t VarDataLenT; // maxVarDataLen: 32767
#define varDataLen(v) ((VarDataLenT *)(v))[0]
#define varDataLen(v) ((VarDataLenT *)(v))[0]
#define varDataVal(v) ((char *)(v) + VARSTR_HEADER_SIZE)
#define varDataVal(v) ((char *)(v) + VARSTR_HEADER_SIZE)
#define NCHAR_WIDTH_TO_BYTES(n) ((n) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE)
typedef
int32_t
VarDataOffsetT
;
typedef
int32_t
VarDataOffsetT
;
typedef
struct
tstr
{
typedef
struct
tstr
{
...
...
source/client/inc/clientInt.h
浏览文件 @
bdbf365e
...
@@ -155,6 +155,7 @@ typedef struct SReqResultInfo {
...
@@ -155,6 +155,7 @@ typedef struct SReqResultInfo {
TAOS_FIELD
*
fields
;
TAOS_FIELD
*
fields
;
uint32_t
numOfCols
;
uint32_t
numOfCols
;
int32_t
*
length
;
int32_t
*
length
;
char
**
convertBuf
;
TAOS_ROW
row
;
TAOS_ROW
row
;
SResultColumn
*
pCol
;
SResultColumn
*
pCol
;
uint32_t
numOfRows
;
uint32_t
numOfRows
;
...
...
source/client/src/clientEnv.c
浏览文件 @
bdbf365e
...
@@ -169,6 +169,13 @@ static void doFreeReqResultInfo(SReqResultInfo *pResInfo) {
...
@@ -169,6 +169,13 @@ static void doFreeReqResultInfo(SReqResultInfo *pResInfo) {
tfree
(
pResInfo
->
row
);
tfree
(
pResInfo
->
row
);
tfree
(
pResInfo
->
pCol
);
tfree
(
pResInfo
->
pCol
);
tfree
(
pResInfo
->
fields
);
tfree
(
pResInfo
->
fields
);
if
(
pResInfo
->
convertBuf
!=
NULL
)
{
for
(
int32_t
i
=
0
;
i
<
pResInfo
->
numOfCols
;
++
i
)
{
tfree
(
pResInfo
->
convertBuf
[
i
]);
}
tfree
(
pResInfo
->
convertBuf
);
}
}
}
static
void
doDestroyRequest
(
void
*
p
)
{
static
void
doDestroyRequest
(
void
*
p
)
{
...
...
source/client/src/clientImpl.c
浏览文件 @
bdbf365e
...
@@ -634,18 +634,30 @@ _return:
...
@@ -634,18 +634,30 @@ _return:
for
(
int32_t
i
=
0
;
i
<
pResultInfo
->
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pResultInfo
->
numOfCols
;
++
i
)
{
SResultColumn
*
pCol
=
&
pResultInfo
->
pCol
[
i
];
SResultColumn
*
pCol
=
&
pResultInfo
->
pCol
[
i
];
if
(
IS_VAR_DATA_TYPE
(
pResultInfo
->
fields
[
i
].
type
))
{
int32_t
type
=
pResultInfo
->
fields
[
i
].
type
;
int32_t
bytes
=
pResultInfo
->
fields
[
i
].
bytes
;
if
(
IS_VAR_DATA_TYPE
(
type
))
{
if
(
pCol
->
offset
[
pResultInfo
->
current
]
!=
-
1
)
{
if
(
pCol
->
offset
[
pResultInfo
->
current
]
!=
-
1
)
{
char
*
pStart
=
pResultInfo
->
pCol
[
i
].
offset
[
pResultInfo
->
current
]
+
pResultInfo
->
pCol
[
i
].
pData
;
char
*
pStart
=
pResultInfo
->
pCol
[
i
].
offset
[
pResultInfo
->
current
]
+
pResultInfo
->
pCol
[
i
].
pData
;
pResultInfo
->
length
[
i
]
=
varDataLen
(
pStart
);
pResultInfo
->
length
[
i
]
=
varDataLen
(
pStart
);
pResultInfo
->
row
[
i
]
=
varDataVal
(
pStart
);
pResultInfo
->
row
[
i
]
=
varDataVal
(
pStart
);
if
(
type
==
TSDB_DATA_TYPE_NCHAR
)
{
int32_t
len
=
taosUcs4ToMbs
((
TdUcs4
*
)
varDataVal
(
pStart
),
varDataLen
(
pStart
),
varDataVal
(
pResultInfo
->
convertBuf
[
i
]));
ASSERT
(
len
<=
bytes
);
pResultInfo
->
row
[
i
]
=
varDataVal
(
pResultInfo
->
convertBuf
[
i
]);
varDataSetLen
(
pResultInfo
->
convertBuf
[
i
],
len
);
pResultInfo
->
length
[
i
]
=
len
;
}
}
else
{
}
else
{
pResultInfo
->
row
[
i
]
=
NULL
;
pResultInfo
->
row
[
i
]
=
NULL
;
}
}
}
else
{
}
else
{
if
(
!
colDataIsNull_f
(
pCol
->
nullbitmap
,
pResultInfo
->
current
))
{
if
(
!
colDataIsNull_f
(
pCol
->
nullbitmap
,
pResultInfo
->
current
))
{
pResultInfo
->
row
[
i
]
=
pResultInfo
->
pCol
[
i
].
pData
+
pResultInfo
->
fields
[
i
].
bytes
*
pResultInfo
->
current
;
pResultInfo
->
row
[
i
]
=
pResultInfo
->
pCol
[
i
].
pData
+
bytes
*
pResultInfo
->
current
;
}
else
{
}
else
{
pResultInfo
->
row
[
i
]
=
NULL
;
pResultInfo
->
row
[
i
]
=
NULL
;
}
}
...
@@ -661,13 +673,20 @@ static int32_t doPrepareResPtr(SReqResultInfo* pResInfo) {
...
@@ -661,13 +673,20 @@ static int32_t doPrepareResPtr(SReqResultInfo* pResInfo) {
pResInfo
->
row
=
calloc
(
pResInfo
->
numOfCols
,
POINTER_BYTES
);
pResInfo
->
row
=
calloc
(
pResInfo
->
numOfCols
,
POINTER_BYTES
);
pResInfo
->
pCol
=
calloc
(
pResInfo
->
numOfCols
,
sizeof
(
SResultColumn
));
pResInfo
->
pCol
=
calloc
(
pResInfo
->
numOfCols
,
sizeof
(
SResultColumn
));
pResInfo
->
length
=
calloc
(
pResInfo
->
numOfCols
,
sizeof
(
int32_t
));
pResInfo
->
length
=
calloc
(
pResInfo
->
numOfCols
,
sizeof
(
int32_t
));
}
pResInfo
->
convertBuf
=
calloc
(
pResInfo
->
numOfCols
,
POINTER_BYTES
);
if
(
pResInfo
->
row
==
NULL
||
pResInfo
->
pCol
==
NULL
||
pResInfo
->
length
==
NULL
)
{
if
(
pResInfo
->
row
==
NULL
||
pResInfo
->
pCol
==
NULL
||
pResInfo
->
length
==
NULL
||
pResInfo
->
convertBuf
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
else
{
return
TSDB_CODE_SUCCESS
;
}
}
for
(
int32_t
i
=
0
;
i
<
pResInfo
->
numOfCols
;
++
i
)
{
if
(
pResInfo
->
fields
[
i
].
type
==
TSDB_DATA_TYPE_NCHAR
)
{
pResInfo
->
convertBuf
[
i
]
=
calloc
(
1
,
NCHAR_WIDTH_TO_BYTES
(
pResInfo
->
fields
[
i
].
bytes
));
}
}
}
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
setResultDataPtr
(
SReqResultInfo
*
pResultInfo
,
TAOS_FIELD
*
pFields
,
int32_t
numOfCols
,
int32_t
numOfRows
)
{
int32_t
setResultDataPtr
(
SReqResultInfo
*
pResultInfo
,
TAOS_FIELD
*
pFields
,
int32_t
numOfCols
,
int32_t
numOfRows
)
{
...
...
source/client/test/clientTests.cpp
浏览文件 @
bdbf365e
...
@@ -52,7 +52,7 @@ TEST(testCase, driverInit_Test) {
...
@@ -52,7 +52,7 @@ TEST(testCase, driverInit_Test) {
// taosInitGlobalCfg();
// taosInitGlobalCfg();
// taos_init();
// taos_init();
}
}
#if 0
TEST(testCase, connect_Test) {
TEST(testCase, connect_Test) {
// taos_options(TSDB_OPTION_CONFIGDIR, "/home/ubuntu/first/cfg");
// taos_options(TSDB_OPTION_CONFIGDIR, "/home/ubuntu/first/cfg");
...
@@ -652,6 +652,7 @@ TEST(testCase, projection_query_stables) {
...
@@ -652,6 +652,7 @@ TEST(testCase, projection_query_stables) {
taos_free_result(pRes);
taos_free_result(pRes);
taos_close(pConn);
taos_close(pConn);
}
}
#endif
TEST
(
testCase
,
agg_query_tables
)
{
TEST
(
testCase
,
agg_query_tables
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
...
@@ -660,7 +661,7 @@ TEST(testCase, agg_query_tables) {
...
@@ -660,7 +661,7 @@ TEST(testCase, agg_query_tables) {
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"use abc1"
);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"use abc1"
);
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"select count(*)
, sum(k),min(k),max(k)
from tu"
);
pRes
=
taos_query
(
pConn
,
"select count(*) from tu"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to select from table, reason:%s
\n
"
,
taos_errstr
(
pRes
));
printf
(
"failed to select from table, reason:%s
\n
"
,
taos_errstr
(
pRes
));
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
...
...
source/common/src/tglobal.c
浏览文件 @
bdbf365e
...
@@ -180,6 +180,10 @@ static int32_t taosSetTfsCfg(SConfig *pCfg) {
...
@@ -180,6 +180,10 @@ static int32_t taosSetTfsCfg(SConfig *pCfg) {
memcpy
(
&
tsDiskCfg
[
index
],
pCfg
,
sizeof
(
SDiskCfg
));
memcpy
(
&
tsDiskCfg
[
index
],
pCfg
,
sizeof
(
SDiskCfg
));
if
(
pCfg
->
level
==
0
&&
pCfg
->
primary
==
1
)
{
if
(
pCfg
->
level
==
0
&&
pCfg
->
primary
==
1
)
{
tstrncpy
(
tsDataDir
,
pCfg
->
dir
,
PATH_MAX
);
tstrncpy
(
tsDataDir
,
pCfg
->
dir
,
PATH_MAX
);
if
(
taosMkDir
(
tsDataDir
)
!=
0
)
{
uError
(
"failed to create dataDir:%s since %s"
,
tsDataDir
,
terrstr
());
return
-
1
;
}
}
}
if
(
taosMkDir
(
pCfg
->
dir
)
!=
0
)
{
if
(
taosMkDir
(
pCfg
->
dir
)
!=
0
)
{
uError
(
"failed to create tfsDir:%s since %s"
,
tsDataDir
,
terrstr
());
uError
(
"failed to create tfsDir:%s since %s"
,
tsDataDir
,
terrstr
());
...
...
source/common/src/tmsg.c
浏览文件 @
bdbf365e
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
#undef TD_MSG_SEG_CODE_
#undef TD_MSG_SEG_CODE_
#include "tmsgdef.h"
#include "tmsgdef.h"
int32_t
tInitSubmitMsgIter
(
SSubmitReq
*
pMsg
,
SSubmitMsgIter
*
pIter
)
{
int32_t
tInitSubmitMsgIter
(
const
SSubmitReq
*
pMsg
,
SSubmitMsgIter
*
pIter
)
{
if
(
pMsg
==
NULL
)
{
if
(
pMsg
==
NULL
)
{
terrno
=
TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP
;
terrno
=
TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP
;
return
-
1
;
return
-
1
;
...
...
source/common/src/ttime.c
浏览文件 @
bdbf365e
...
@@ -458,16 +458,21 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision) {
...
@@ -458,16 +458,21 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision) {
if
(
duration
==
0
)
{
if
(
duration
==
0
)
{
return
t
;
return
t
;
}
}
if
(
unit
==
'y'
)
{
duration
*=
12
;
if
(
unit
!=
'n'
&&
unit
!=
'y'
)
{
}
else
if
(
unit
!=
'n'
)
{
return
t
+
duration
;
return
t
+
duration
;
}
}
// The following code handles the y/n time duration
int64_t
numOfMonth
=
duration
;
if
(
unit
==
'y'
)
{
numOfMonth
*=
12
;
}
struct
tm
tm
;
struct
tm
tm
;
time_t
tt
=
(
time_t
)(
t
/
TSDB_TICK_PER_SECOND
(
precision
));
time_t
tt
=
(
time_t
)(
t
/
TSDB_TICK_PER_SECOND
(
precision
));
taosLocalTime
(
&
tt
,
&
tm
);
taosLocalTime
(
&
tt
,
&
tm
);
int32_t
mon
=
tm
.
tm_year
*
12
+
tm
.
tm_mon
+
(
int32_t
)
duration
;
int32_t
mon
=
tm
.
tm_year
*
12
+
tm
.
tm_mon
+
(
int32_t
)
numOfMonth
;
tm
.
tm_year
=
mon
/
12
;
tm
.
tm_year
=
mon
/
12
;
tm
.
tm_mon
=
mon
%
12
;
tm
.
tm_mon
=
mon
%
12
;
...
@@ -557,8 +562,7 @@ int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precisio
...
@@ -557,8 +562,7 @@ int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precisio
// not enough time range
// not enough time range
if
(
start
<
0
||
INT64_MAX
-
start
>
pInterval
->
interval
-
1
)
{
if
(
start
<
0
||
INT64_MAX
-
start
>
pInterval
->
interval
-
1
)
{
end
=
start
+
pInterval
->
interval
-
1
;
end
=
taosTimeAdd
(
start
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
precision
)
-
1
;
while
(
end
<
t
&&
((
start
+
pInterval
->
sliding
)
<=
INT64_MAX
))
{
// move forward to the correct time window
while
(
end
<
t
&&
((
start
+
pInterval
->
sliding
)
<=
INT64_MAX
))
{
// move forward to the correct time window
start
+=
pInterval
->
sliding
;
start
+=
pInterval
->
sliding
;
...
@@ -574,12 +578,23 @@ int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precisio
...
@@ -574,12 +578,23 @@ int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precisio
}
}
}
}
ASSERT
(
pInterval
->
offset
>=
0
);
if
(
pInterval
->
offset
>
0
)
{
if
(
pInterval
->
offset
>
0
)
{
start
=
taosTimeAdd
(
start
,
pInterval
->
offset
,
pInterval
->
offsetUnit
,
precision
);
start
=
taosTimeAdd
(
start
,
pInterval
->
offset
,
pInterval
->
offsetUnit
,
precision
);
if
(
start
>
t
)
{
if
(
start
>
t
)
{
start
=
taosTimeAdd
(
start
,
-
pInterval
->
interval
,
pInterval
->
intervalUnit
,
precision
);
start
=
taosTimeAdd
(
start
,
-
pInterval
->
interval
,
pInterval
->
intervalUnit
,
precision
);
}
else
{
// try to move current window to the left-hande-side, due to the offset effect.
int64_t
end
=
taosTimeAdd
(
start
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
precision
)
-
1
;
ASSERT
(
end
>=
t
);
end
=
taosTimeAdd
(
end
,
-
pInterval
->
sliding
,
pInterval
->
slidingUnit
,
precision
);
if
(
end
>=
t
)
{
start
=
taosTimeAdd
(
start
,
-
pInterval
->
sliding
,
pInterval
->
slidingUnit
,
precision
);
}
}
}
}
}
return
start
;
return
start
;
}
}
...
...
source/dnode/mgmt/bnode/src/bmWorker.c
浏览文件 @
bdbf365e
...
@@ -77,7 +77,11 @@ int32_t bmStartWorker(SBnodeMgmt *pMgmt) {
...
@@ -77,7 +77,11 @@ int32_t bmStartWorker(SBnodeMgmt *pMgmt) {
return
-
1
;
return
-
1
;
}
}
dDebug
(
"bnode workers are initialized"
);
return
0
;
return
0
;
}
}
void
bmStopWorker
(
SBnodeMgmt
*
pMgmt
)
{
tMultiWorkerCleanup
(
&
pMgmt
->
writeWorker
);
}
void
bmStopWorker
(
SBnodeMgmt
*
pMgmt
)
{
tMultiWorkerCleanup
(
&
pMgmt
->
writeWorker
);
dDebug
(
"bnode workers are closed"
);
}
source/dnode/mgmt/container/inc/dnd.h
浏览文件 @
bdbf365e
...
@@ -19,7 +19,6 @@
...
@@ -19,7 +19,6 @@
#include "os.h"
#include "os.h"
#include "cJSON.h"
#include "cJSON.h"
#include "monitor.h"
#include "tcache.h"
#include "tcache.h"
#include "tcrc32c.h"
#include "tcrc32c.h"
#include "tdatablock.h"
#include "tdatablock.h"
...
@@ -36,8 +35,7 @@
...
@@ -36,8 +35,7 @@
#include "tworker.h"
#include "tworker.h"
#include "dnode.h"
#include "dnode.h"
#include "tfs.h"
#include "monitor.h"
#include "wal.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
...
@@ -53,7 +51,6 @@ extern "C" {
...
@@ -53,7 +51,6 @@ extern "C" {
typedef
enum
{
DNODE
,
VNODES
,
QNODE
,
SNODE
,
MNODE
,
BNODE
,
NODE_MAX
}
ENodeType
;
typedef
enum
{
DNODE
,
VNODES
,
QNODE
,
SNODE
,
MNODE
,
BNODE
,
NODE_MAX
}
ENodeType
;
typedef
enum
{
DND_STAT_INIT
,
DND_STAT_RUNNING
,
DND_STAT_STOPPED
}
EDndStatus
;
typedef
enum
{
DND_STAT_INIT
,
DND_STAT_RUNNING
,
DND_STAT_STOPPED
}
EDndStatus
;
typedef
enum
{
DND_ENV_INIT
,
DND_ENV_READY
,
DND_ENV_CLEANUP
}
EEnvStatus
;
typedef
enum
{
DND_ENV_INIT
,
DND_ENV_READY
,
DND_ENV_CLEANUP
}
EEnvStatus
;
typedef
enum
{
DND_WORKER_SINGLE
,
DND_WORKER_MULTI
}
EWorkerType
;
typedef
enum
{
PROC_SINGLE
,
PROC_CHILD
,
PROC_PARENT
}
EProcType
;
typedef
enum
{
PROC_SINGLE
,
PROC_CHILD
,
PROC_PARENT
}
EProcType
;
typedef
struct
SMgmtFp
SMgmtFp
;
typedef
struct
SMgmtFp
SMgmtFp
;
...
@@ -75,10 +72,8 @@ typedef int32_t (*DropNodeFp)(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
...
@@ -75,10 +72,8 @@ typedef int32_t (*DropNodeFp)(SMgmtWrapper *pWrapper, SNodeMsg *pMsg);
typedef
int32_t
(
*
RequireNodeFp
)(
SMgmtWrapper
*
pWrapper
,
bool
*
required
);
typedef
int32_t
(
*
RequireNodeFp
)(
SMgmtWrapper
*
pWrapper
,
bool
*
required
);
typedef
struct
SMsgHandle
{
typedef
struct
SMsgHandle
{
int32_t
vgId
;
SMgmtWrapper
*
pQndWrapper
;
NodeMsgFp
vgIdMsgFp
;
SMgmtWrapper
*
pMndWrapper
;
SMgmtWrapper
*
pVgIdWrapper
;
// Handle the case where the same message type is distributed to qnode or vnode
NodeMsgFp
msgFp
;
SMgmtWrapper
*
pWrapper
;
SMgmtWrapper
*
pWrapper
;
}
SMsgHandle
;
}
SMsgHandle
;
...
@@ -129,7 +124,6 @@ typedef struct SDnode {
...
@@ -129,7 +124,6 @@ typedef struct SDnode {
bool
dropped
;
bool
dropped
;
EDndStatus
status
;
EDndStatus
status
;
EDndEvent
event
;
EDndEvent
event
;
EProcType
procType
;
SStartupReq
startup
;
SStartupReq
startup
;
TdFilePtr
pLockFile
;
TdFilePtr
pLockFile
;
STransMgmt
trans
;
STransMgmt
trans
;
...
@@ -138,9 +132,8 @@ typedef struct SDnode {
...
@@ -138,9 +132,8 @@ typedef struct SDnode {
EDndStatus
dndGetStatus
(
SDnode
*
pDnode
);
EDndStatus
dndGetStatus
(
SDnode
*
pDnode
);
void
dndSetStatus
(
SDnode
*
pDnode
,
EDndStatus
stat
);
void
dndSetStatus
(
SDnode
*
pDnode
,
EDndStatus
stat
);
SMgmtWrapper
*
dndAcquireWrapper
(
SDnode
*
pDnode
,
ENodeType
nodeType
);
void
dndSetMsgHandle
(
SMgmtWrapper
*
pWrapper
,
int32_t
msgType
,
NodeMsgFp
nodeMsgFp
,
int32_t
vgId
);
void
dndSetMsgHandle
(
SMgmtWrapper
*
pWrapper
,
int32_t
msgType
,
NodeMsgFp
nodeMsgFp
,
int32_t
vgId
);
void
dndReportStartup
(
SDnode
*
pDnode
,
char
*
pName
,
char
*
pDesc
);
void
dndReportStartup
(
SDnode
*
pDnode
,
const
char
*
pName
,
const
char
*
pDesc
);
void
dndSendMonitorReport
(
SDnode
*
pDnode
);
void
dndSendMonitorReport
(
SDnode
*
pDnode
);
int32_t
dndSendReqToMnode
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pMsg
);
int32_t
dndSendReqToMnode
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pMsg
);
...
@@ -148,10 +141,13 @@ int32_t dndSendReqToDnode(SMgmtWrapper *pWrapper, SEpSet *pEpSet, SRpcMsg *pMsg)
...
@@ -148,10 +141,13 @@ int32_t dndSendReqToDnode(SMgmtWrapper *pWrapper, SEpSet *pEpSet, SRpcMsg *pMsg)
void
dndSendRsp
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pRsp
);
void
dndSendRsp
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pRsp
);
int32_t
dndProcessNodeMsg
(
SDnode
*
pDnode
,
SNodeMsg
*
pMsg
);
int32_t
dndProcessNodeMsg
(
SDnode
*
pDnode
,
SNodeMsg
*
pMsg
);
int32_t
dndReadFile
(
SMgmtWrapper
*
pWrapper
,
bool
*
pDeployed
);
int32_t
dndReadFile
(
SMgmtWrapper
*
pWrapper
,
bool
*
pDeployed
);
int32_t
dndWriteFile
(
SMgmtWrapper
*
pWrapper
,
bool
deployed
);
int32_t
dndWriteFile
(
SMgmtWrapper
*
pWrapper
,
bool
deployed
);
SMgmtWrapper
*
dndAcquireWrapper
(
SDnode
*
pDnode
,
ENodeType
nodeType
);
int32_t
dndMarkWrapper
(
SMgmtWrapper
*
pWrapper
);
void
dndReleaseWrapper
(
SMgmtWrapper
*
pWrapper
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/dnode/mgmt/container/inc/dndInt.h
浏览文件 @
bdbf365e
...
@@ -34,7 +34,7 @@ int32_t dndInit();
...
@@ -34,7 +34,7 @@ int32_t dndInit();
void
dndCleanup
();
void
dndCleanup
();
const
char
*
dndStatStr
(
EDndStatus
stat
);
const
char
*
dndStatStr
(
EDndStatus
stat
);
void
dndGetStartup
(
SDnode
*
pDnode
,
SStartupReq
*
pStartup
);
void
dndGetStartup
(
SDnode
*
pDnode
,
SStartupReq
*
pStartup
);
TdFilePtr
dndCheckRunning
(
char
*
dataDir
);
TdFilePtr
dndCheckRunning
(
c
onst
c
har
*
dataDir
);
void
dndProcessStartupReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
);
void
dndProcessStartupReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
);
// dndMsg.c
// dndMsg.c
...
@@ -50,10 +50,6 @@ SDnode *dndCreate(const SDnodeOpt *pOption);
...
@@ -50,10 +50,6 @@ SDnode *dndCreate(const SDnodeOpt *pOption);
void
dndClose
(
SDnode
*
pDnode
);
void
dndClose
(
SDnode
*
pDnode
);
void
dndHandleEvent
(
SDnode
*
pDnode
,
EDndEvent
event
);
void
dndHandleEvent
(
SDnode
*
pDnode
,
EDndEvent
event
);
SMgmtWrapper
*
dndAcquireWrapper
(
SDnode
*
pDnode
,
ENodeType
nodeType
);
int32_t
dndMarkWrapper
(
SMgmtWrapper
*
pWrapper
);
void
dndReleaseWrapper
(
SMgmtWrapper
*
pWrapper
);
// dndTransport.c
// dndTransport.c
int32_t
dndInitServer
(
SDnode
*
pDnode
);
int32_t
dndInitServer
(
SDnode
*
pDnode
);
void
dndCleanupServer
(
SDnode
*
pDnode
);
void
dndCleanupServer
(
SDnode
*
pDnode
);
...
...
source/dnode/mgmt/container/src/dndExec.c
浏览文件 @
bdbf365e
...
@@ -50,16 +50,23 @@ int32_t dndOpenNode(SMgmtWrapper *pWrapper) {
...
@@ -50,16 +50,23 @@ int32_t dndOpenNode(SMgmtWrapper *pWrapper) {
}
}
void
dndCloseNode
(
SMgmtWrapper
*
pWrapper
)
{
void
dndCloseNode
(
SMgmtWrapper
*
pWrapper
)
{
dDebug
(
"node:%s, start to close"
,
pWrapper
->
name
);
taosWLockLatch
(
&
pWrapper
->
latch
);
taosWLockLatch
(
&
pWrapper
->
latch
);
if
(
pWrapper
->
deployed
)
{
if
(
pWrapper
->
deployed
)
{
(
*
pWrapper
->
fp
.
closeFp
)(
pWrapper
);
(
*
pWrapper
->
fp
.
closeFp
)(
pWrapper
);
pWrapper
->
deployed
=
false
;
pWrapper
->
deployed
=
false
;
}
}
taosWUnLockLatch
(
&
pWrapper
->
latch
);
while
(
pWrapper
->
refCount
>
0
)
{
taosMsleep
(
10
);
}
if
(
pWrapper
->
pProc
)
{
if
(
pWrapper
->
pProc
)
{
taosProcCleanup
(
pWrapper
->
pProc
);
taosProcCleanup
(
pWrapper
->
pProc
);
pWrapper
->
pProc
=
NULL
;
pWrapper
->
pProc
=
NULL
;
}
}
taosWUnLockLatch
(
&
pWrapper
->
latch
);
dDebug
(
"node:%s, has been closed"
,
pWrapper
->
name
);
}
}
static
int32_t
dndRunInSingleProcess
(
SDnode
*
pDnode
)
{
static
int32_t
dndRunInSingleProcess
(
SDnode
*
pDnode
)
{
...
...
source/dnode/mgmt/container/src/dndInt.c
浏览文件 @
bdbf365e
...
@@ -15,11 +15,12 @@
...
@@ -15,11 +15,12 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "dndInt.h"
#include "dndInt.h"
#include "wal.h"
static
int8_t
once
=
DND_ENV_INIT
;
static
int8_t
once
=
DND_ENV_INIT
;
int32_t
dndInit
()
{
int32_t
dndInit
()
{
d
Debug
(
"start to init dnode env"
);
d
Info
(
"start to init dnode env"
);
if
(
atomic_val_compare_exchange_8
(
&
once
,
DND_ENV_INIT
,
DND_ENV_READY
)
!=
DND_ENV_INIT
)
{
if
(
atomic_val_compare_exchange_8
(
&
once
,
DND_ENV_INIT
,
DND_ENV_READY
)
!=
DND_ENV_INIT
)
{
terrno
=
TSDB_CODE_REPEAT_INIT
;
terrno
=
TSDB_CODE_REPEAT_INIT
;
dError
(
"failed to init dnode env since %s"
,
terrstr
());
dError
(
"failed to init dnode env since %s"
,
terrstr
());
...
@@ -52,7 +53,7 @@ int32_t dndInit() {
...
@@ -52,7 +53,7 @@ int32_t dndInit() {
}
}
void
dndCleanup
()
{
void
dndCleanup
()
{
d
Debug
(
"start to cleanup dnode env"
);
d
Info
(
"start to cleanup dnode env"
);
if
(
atomic_val_compare_exchange_8
(
&
once
,
DND_ENV_READY
,
DND_ENV_CLEANUP
)
!=
DND_ENV_READY
)
{
if
(
atomic_val_compare_exchange_8
(
&
once
,
DND_ENV_READY
,
DND_ENV_CLEANUP
)
!=
DND_ENV_READY
)
{
dError
(
"dnode env is already cleaned up"
);
dError
(
"dnode env is already cleaned up"
);
return
;
return
;
...
@@ -92,7 +93,7 @@ const char *dndStatStr(EDndStatus status) {
...
@@ -92,7 +93,7 @@ const char *dndStatStr(EDndStatus status) {
}
}
}
}
void
dndReportStartup
(
SDnode
*
pDnode
,
c
har
*
pName
,
char
*
pDesc
)
{
void
dndReportStartup
(
SDnode
*
pDnode
,
c
onst
char
*
pName
,
const
char
*
pDesc
)
{
SStartupReq
*
pStartup
=
&
pDnode
->
startup
;
SStartupReq
*
pStartup
=
&
pDnode
->
startup
;
tstrncpy
(
pStartup
->
name
,
pName
,
TSDB_STEP_NAME_LEN
);
tstrncpy
(
pStartup
->
name
,
pName
,
TSDB_STEP_NAME_LEN
);
tstrncpy
(
pStartup
->
desc
,
pDesc
,
TSDB_STEP_DESC_LEN
);
tstrncpy
(
pStartup
->
desc
,
pDesc
,
TSDB_STEP_DESC_LEN
);
...
@@ -104,21 +105,21 @@ void dndGetStartup(SDnode *pDnode, SStartupReq *pStartup) {
...
@@ -104,21 +105,21 @@ void dndGetStartup(SDnode *pDnode, SStartupReq *pStartup) {
pStartup
->
finished
=
(
dndGetStatus
(
pDnode
)
==
DND_STAT_RUNNING
);
pStartup
->
finished
=
(
dndGetStatus
(
pDnode
)
==
DND_STAT_RUNNING
);
}
}
TdFilePtr
dndCheckRunning
(
char
*
dataDir
)
{
TdFilePtr
dndCheckRunning
(
c
onst
c
har
*
dataDir
)
{
char
filepath
[
PATH_MAX
]
=
{
0
};
char
filepath
[
PATH_MAX
]
=
{
0
};
snprintf
(
filepath
,
sizeof
(
filepath
),
"%s/.running"
,
dataDir
);
snprintf
(
filepath
,
sizeof
(
filepath
),
"%s/.running"
,
dataDir
);
TdFilePtr
pFile
=
taosOpenFile
(
filepath
,
TD_FILE_CTEATE
|
TD_FILE_WRITE
|
TD_FILE_TRUNC
);
TdFilePtr
pFile
=
taosOpenFile
(
filepath
,
TD_FILE_CTEATE
|
TD_FILE_WRITE
|
TD_FILE_TRUNC
);
if
(
pFile
==
NULL
)
{
if
(
pFile
==
NULL
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
dError
(
"failed to lock file:%s since %s
, quit
"
,
filepath
,
terrstr
());
dError
(
"failed to lock file:%s since %s"
,
filepath
,
terrstr
());
return
NULL
;
return
NULL
;
}
}
int32_t
ret
=
taosLockFile
(
pFile
);
int32_t
ret
=
taosLockFile
(
pFile
);
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
dError
(
"failed to lock file:%s since %s
, quit
"
,
filepath
,
terrstr
());
dError
(
"failed to lock file:%s since %s"
,
filepath
,
terrstr
());
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
return
NULL
;
return
NULL
;
}
}
...
@@ -129,12 +130,10 @@ TdFilePtr dndCheckRunning(char *dataDir) {
...
@@ -129,12 +130,10 @@ TdFilePtr dndCheckRunning(char *dataDir) {
void
dndProcessStartupReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pReq
)
{
void
dndProcessStartupReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pReq
)
{
dDebug
(
"startup req is received"
);
dDebug
(
"startup req is received"
);
SStartupReq
*
pStartup
=
rpcMallocCont
(
sizeof
(
SStartupReq
));
SStartupReq
*
pStartup
=
rpcMallocCont
(
sizeof
(
SStartupReq
));
dndGetStartup
(
pDnode
,
pStartup
);
dndGetStartup
(
pDnode
,
pStartup
);
dDebug
(
"startup req is sent, step:%s desc:%s finished:%d"
,
pStartup
->
name
,
pStartup
->
desc
,
pStartup
->
finished
);
dDebug
(
"startup req is sent, step:%s desc:%s finished:%d"
,
pStartup
->
name
,
pStartup
->
desc
,
pStartup
->
finished
);
SRpcMsg
rpcRsp
=
{.
handle
=
pReq
->
handle
,
.
pCont
=
pStartup
,
.
contLen
=
sizeof
(
SStartupReq
)};
SRpcMsg
rpcRsp
=
{.
handle
=
pReq
->
handle
,
.
pCont
=
pStartup
,
.
contLen
=
sizeof
(
SStartupReq
)};
rpcSendResponse
(
&
rpcRsp
);
rpcSendResponse
(
&
rpcRsp
);
}
}
source/dnode/mgmt/container/src/dndMonitor.c
浏览文件 @
bdbf365e
...
@@ -22,7 +22,12 @@ static int32_t dndGetMonitorDiskInfo(SDnode *pDnode, SMonDiskInfo *pInfo) {
...
@@ -22,7 +22,12 @@ static int32_t dndGetMonitorDiskInfo(SDnode *pDnode, SMonDiskInfo *pInfo) {
tstrncpy
(
pInfo
->
tempdir
.
name
,
tsTempDir
,
sizeof
(
pInfo
->
tempdir
.
name
));
tstrncpy
(
pInfo
->
tempdir
.
name
,
tsTempDir
,
sizeof
(
pInfo
->
tempdir
.
name
));
pInfo
->
tempdir
.
size
=
tsTempSpace
.
size
;
pInfo
->
tempdir
.
size
=
tsTempSpace
.
size
;
return
vmMonitorTfsInfo
(
dndAcquireWrapper
(
pDnode
,
VNODES
),
pInfo
);
SMgmtWrapper
*
pWrapper
=
dndAcquireWrapper
(
pDnode
,
VNODES
);
if
(
pWrapper
!=
NULL
)
{
vmMonitorTfsInfo
(
pWrapper
,
pInfo
);
dndReleaseWrapper
(
pWrapper
);
}
return
0
;
}
}
static
void
dndGetMonitorBasicInfo
(
SDnode
*
pDnode
,
SMonBasicInfo
*
pInfo
)
{
static
void
dndGetMonitorBasicInfo
(
SDnode
*
pDnode
,
SMonBasicInfo
*
pInfo
)
{
...
@@ -45,8 +50,17 @@ static void dndGetMonitorDnodeInfo(SDnode *pDnode, SMonDnodeInfo *pInfo) {
...
@@ -45,8 +50,17 @@ static void dndGetMonitorDnodeInfo(SDnode *pDnode, SMonDnodeInfo *pInfo) {
taosGetCardInfo
(
&
pInfo
->
net_in
,
&
pInfo
->
net_out
);
taosGetCardInfo
(
&
pInfo
->
net_in
,
&
pInfo
->
net_out
);
taosGetProcIO
(
&
pInfo
->
io_read
,
&
pInfo
->
io_write
,
&
pInfo
->
io_read_disk
,
&
pInfo
->
io_write_disk
);
taosGetProcIO
(
&
pInfo
->
io_read
,
&
pInfo
->
io_write
,
&
pInfo
->
io_read_disk
,
&
pInfo
->
io_write_disk
);
vmMonitorVnodeReqs
(
dndAcquireWrapper
(
pDnode
,
VNODES
),
pInfo
);
SMgmtWrapper
*
pWrapper
=
dndAcquireWrapper
(
pDnode
,
VNODES
);
pInfo
->
has_mnode
=
(
dndAcquireWrapper
(
pDnode
,
MNODE
)
->
required
);
if
(
pWrapper
!=
NULL
)
{
vmMonitorVnodeReqs
(
pWrapper
,
pInfo
);
dndReleaseWrapper
(
pWrapper
);
}
pWrapper
=
dndAcquireWrapper
(
pDnode
,
MNODE
);
if
(
pWrapper
!=
NULL
)
{
pInfo
->
has_mnode
=
pWrapper
->
required
;
dndReleaseWrapper
(
pWrapper
);
}
}
}
void
dndSendMonitorReport
(
SDnode
*
pDnode
)
{
void
dndSendMonitorReport
(
SDnode
*
pDnode
)
{
...
@@ -63,11 +77,16 @@ void dndSendMonitorReport(SDnode *pDnode) {
...
@@ -63,11 +77,16 @@ void dndSendMonitorReport(SDnode *pDnode) {
SMonClusterInfo
clusterInfo
=
{
0
};
SMonClusterInfo
clusterInfo
=
{
0
};
SMonVgroupInfo
vgroupInfo
=
{
0
};
SMonVgroupInfo
vgroupInfo
=
{
0
};
SMonGrantInfo
grantInfo
=
{
0
};
SMonGrantInfo
grantInfo
=
{
0
};
if
(
mmMonitorMnodeInfo
(
dndAcquireWrapper
(
pDnode
,
MNODE
),
&
clusterInfo
,
&
vgroupInfo
,
&
grantInfo
)
==
0
)
{
SMgmtWrapper
*
pWrapper
=
dndAcquireWrapper
(
pDnode
,
MNODE
);
if
(
pWrapper
!=
NULL
)
{
if
(
mmMonitorMnodeInfo
(
pWrapper
,
&
clusterInfo
,
&
vgroupInfo
,
&
grantInfo
)
==
0
)
{
monSetClusterInfo
(
pMonitor
,
&
clusterInfo
);
monSetClusterInfo
(
pMonitor
,
&
clusterInfo
);
monSetVgroupInfo
(
pMonitor
,
&
vgroupInfo
);
monSetVgroupInfo
(
pMonitor
,
&
vgroupInfo
);
monSetGrantInfo
(
pMonitor
,
&
grantInfo
);
monSetGrantInfo
(
pMonitor
,
&
grantInfo
);
}
}
dndReleaseWrapper
(
pWrapper
);
}
SMonDnodeInfo
dnodeInfo
=
{
0
};
SMonDnodeInfo
dnodeInfo
=
{
0
};
dndGetMonitorDnodeInfo
(
pDnode
,
&
dnodeInfo
);
dndGetMonitorDnodeInfo
(
pDnode
,
&
dnodeInfo
);
...
...
source/dnode/mgmt/container/src/dndMsg.c
浏览文件 @
bdbf365e
...
@@ -20,8 +20,8 @@ static void dndUpdateMnodeEpSet(SDnode *pDnode, SEpSet *pEpSet) {
...
@@ -20,8 +20,8 @@ static void dndUpdateMnodeEpSet(SDnode *pDnode, SEpSet *pEpSet) {
SMgmtWrapper
*
pWrapper
=
dndAcquireWrapper
(
pDnode
,
DNODE
);
SMgmtWrapper
*
pWrapper
=
dndAcquireWrapper
(
pDnode
,
DNODE
);
if
(
pWrapper
!=
NULL
)
{
if
(
pWrapper
!=
NULL
)
{
dmUpdateMnodeEpSet
(
pWrapper
->
pMgmt
,
pEpSet
);
dmUpdateMnodeEpSet
(
pWrapper
->
pMgmt
,
pEpSet
);
}
dndReleaseWrapper
(
pWrapper
);
dndReleaseWrapper
(
pWrapper
);
}
}
}
static
inline
NodeMsgFp
dndGetMsgFp
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pRpc
)
{
static
inline
NodeMsgFp
dndGetMsgFp
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pRpc
)
{
...
...
source/dnode/mgmt/container/src/dndObj.c
浏览文件 @
bdbf365e
...
@@ -58,7 +58,7 @@ static void dndClearMemory(SDnode *pDnode) {
...
@@ -58,7 +58,7 @@ static void dndClearMemory(SDnode *pDnode) {
SDnode
*
dndCreate
(
const
SDnodeOpt
*
pOption
)
{
SDnode
*
dndCreate
(
const
SDnodeOpt
*
pOption
)
{
dInfo
(
"start to create dnode object"
);
dInfo
(
"start to create dnode object"
);
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
char
path
[
PATH_MAX
];
char
path
[
PATH_MAX
]
=
{
0
}
;
SDnode
*
pDnode
=
NULL
;
SDnode
*
pDnode
=
NULL
;
pDnode
=
calloc
(
1
,
sizeof
(
SDnode
));
pDnode
=
calloc
(
1
,
sizeof
(
SDnode
));
...
@@ -117,6 +117,7 @@ SDnode *dndCreate(const SDnodeOpt *pOption) {
...
@@ -117,6 +117,7 @@ SDnode *dndCreate(const SDnodeOpt *pOption) {
_OVER:
_OVER:
if
(
code
!=
0
&&
pDnode
)
{
if
(
code
!=
0
&&
pDnode
)
{
dndClearMemory
(
pDnode
);
dndClearMemory
(
pDnode
);
pDnode
=
NULL
;
dError
(
"failed to create dnode object since %s"
,
terrstr
());
dError
(
"failed to create dnode object since %s"
,
terrstr
());
}
else
{
}
else
{
dInfo
(
"dnode object is created, data:%p"
,
pDnode
);
dInfo
(
"dnode object is created, data:%p"
,
pDnode
);
...
...
source/dnode/mgmt/container/src/dndTransport.c
浏览文件 @
bdbf365e
...
@@ -20,13 +20,15 @@
...
@@ -20,13 +20,15 @@
#define INTERNAL_CKEY "_key"
#define INTERNAL_CKEY "_key"
#define INTERNAL_SECRET "_pwd"
#define INTERNAL_SECRET "_pwd"
static
inline
void
dndProcessQVnodeRpcMsg
(
SMsgHandle
*
pHandle
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
static
inline
void
dndProcessQ
M
VnodeRpcMsg
(
SMsgHandle
*
pHandle
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
SMsgHead
*
pHead
=
pMsg
->
pCont
;
SMsgHead
*
pHead
=
pMsg
->
pCont
;
int32_t
vgId
=
htonl
(
pHead
->
vgId
);
int32_t
vgId
=
htonl
(
pHead
->
vgId
);
SMgmtWrapper
*
pWrapper
=
pHandle
->
pWrapper
;
SMgmtWrapper
*
pWrapper
=
pHandle
->
pWrapper
;
if
(
vgId
==
pHandle
->
vgId
&&
pHandle
->
pVgIdWrapper
!=
NULL
)
{
if
(
vgId
==
QND_VGID
)
{
pWrapper
=
pHandle
->
pVgIdWrapper
;
pWrapper
=
pHandle
->
pQndWrapper
;
}
else
if
(
vgId
==
MND_VGID
)
{
pWrapper
=
pHandle
->
pMndWrapper
;
}
}
dTrace
(
"msg:%s will be processed by %s, handle:%p app:%p vgId:%d"
,
TMSG_INFO
(
pMsg
->
msgType
),
pWrapper
->
name
,
dTrace
(
"msg:%s will be processed by %s, handle:%p app:%p vgId:%d"
,
TMSG_INFO
(
pMsg
->
msgType
),
pWrapper
->
name
,
...
@@ -46,13 +48,13 @@ static void dndProcessResponse(void *parent, SRpcMsg *pRsp, SEpSet *pEpSet) {
...
@@ -46,13 +48,13 @@ static void dndProcessResponse(void *parent, SRpcMsg *pRsp, SEpSet *pEpSet) {
}
}
SMsgHandle
*
pHandle
=
&
pMgmt
->
msgHandles
[
TMSG_INDEX
(
msgType
)];
SMsgHandle
*
pHandle
=
&
pMgmt
->
msgHandles
[
TMSG_INDEX
(
msgType
)];
if
(
pHandle
->
msgFp
!=
NULL
)
{
if
(
pHandle
->
pWrapper
!=
NULL
)
{
if
(
pHandle
->
vgId
==
0
)
{
if
(
pHandle
->
pMndWrapper
==
NULL
&&
pHandle
->
pQndWrapper
==
NULL
)
{
dTrace
(
"rsp:%s will be processed by %s, handle:%p app:%p code:0x%04x:%s"
,
TMSG_INFO
(
msgType
),
dTrace
(
"rsp:%s will be processed by %s, handle:%p app:%p code:0x%04x:%s"
,
TMSG_INFO
(
msgType
),
pHandle
->
pWrapper
->
name
,
pRsp
->
handle
,
pRsp
->
ahandle
,
pRsp
->
code
&
0XFFFF
,
tstrerror
(
pRsp
->
code
));
pHandle
->
pWrapper
->
name
,
pRsp
->
handle
,
pRsp
->
ahandle
,
pRsp
->
code
&
0XFFFF
,
tstrerror
(
pRsp
->
code
));
dndProcessRpcMsg
(
pHandle
->
pWrapper
,
pRsp
,
pEpSet
);
dndProcessRpcMsg
(
pHandle
->
pWrapper
,
pRsp
,
pEpSet
);
}
else
{
}
else
{
dndProcessQVnodeRpcMsg
(
pHandle
,
pRsp
,
pEpSet
);
dndProcessQ
M
VnodeRpcMsg
(
pHandle
,
pRsp
,
pEpSet
);
}
}
}
else
{
}
else
{
dError
(
"rsp:%s not processed since no handle, handle:%p app:%p"
,
TMSG_INFO
(
msgType
),
pRsp
->
handle
,
pRsp
->
ahandle
);
dError
(
"rsp:%s not processed since no handle, handle:%p app:%p"
,
TMSG_INFO
(
msgType
),
pRsp
->
handle
,
pRsp
->
ahandle
);
...
@@ -126,13 +128,13 @@ static void dndProcessRequest(void *param, SRpcMsg *pReq, SEpSet *pEpSet) {
...
@@ -126,13 +128,13 @@ static void dndProcessRequest(void *param, SRpcMsg *pReq, SEpSet *pEpSet) {
}
}
SMsgHandle
*
pHandle
=
&
pMgmt
->
msgHandles
[
TMSG_INDEX
(
msgType
)];
SMsgHandle
*
pHandle
=
&
pMgmt
->
msgHandles
[
TMSG_INDEX
(
msgType
)];
if
(
pHandle
->
msgFp
!=
NULL
)
{
if
(
pHandle
->
pWrapper
!=
NULL
)
{
if
(
pHandle
->
vgId
==
0
)
{
if
(
pHandle
->
pMndWrapper
==
NULL
&&
pHandle
->
pQndWrapper
==
NULL
)
{
dTrace
(
"req:%s will be processed by %s, handle:%p app:%p"
,
TMSG_INFO
(
msgType
),
pHandle
->
pWrapper
->
name
,
dTrace
(
"req:%s will be processed by %s, handle:%p app:%p"
,
TMSG_INFO
(
msgType
),
pHandle
->
pWrapper
->
name
,
pReq
->
handle
,
pReq
->
ahandle
);
pReq
->
handle
,
pReq
->
ahandle
);
dndProcessRpcMsg
(
pHandle
->
pWrapper
,
pReq
,
pEpSet
);
dndProcessRpcMsg
(
pHandle
->
pWrapper
,
pReq
,
pEpSet
);
}
else
{
}
else
{
dndProcessQVnodeRpcMsg
(
pHandle
,
pReq
,
pEpSet
);
dndProcessQ
M
VnodeRpcMsg
(
pHandle
,
pReq
,
pEpSet
);
}
}
}
else
{
}
else
{
dError
(
"req:%s not processed since no handle, handle:%p app:%p"
,
TMSG_INFO
(
msgType
),
pReq
->
handle
,
pReq
->
ahandle
);
dError
(
"req:%s not processed since no handle, handle:%p app:%p"
,
TMSG_INFO
(
msgType
),
pReq
->
handle
,
pReq
->
ahandle
);
...
@@ -144,9 +146,14 @@ static void dndProcessRequest(void *param, SRpcMsg *pReq, SEpSet *pEpSet) {
...
@@ -144,9 +146,14 @@ static void dndProcessRequest(void *param, SRpcMsg *pReq, SEpSet *pEpSet) {
static
void
dndSendMsgToMnodeRecv
(
SDnode
*
pDnode
,
SRpcMsg
*
pRpcMsg
,
SRpcMsg
*
pRpcRsp
)
{
static
void
dndSendMsgToMnodeRecv
(
SDnode
*
pDnode
,
SRpcMsg
*
pRpcMsg
,
SRpcMsg
*
pRpcRsp
)
{
STransMgmt
*
pMgmt
=
&
pDnode
->
trans
;
STransMgmt
*
pMgmt
=
&
pDnode
->
trans
;
SEpSet
epSet
=
{
0
};
SEpSet
epSet
=
{
0
};
dmGetMnodeEpSet
(
dndAcquireWrapper
(
pDnode
,
DNODE
)
->
pMgmt
,
&
epSet
);
SMgmtWrapper
*
pWrapper
=
dndAcquireWrapper
(
pDnode
,
DNODE
);
if
(
pWrapper
!=
NULL
)
{
dmGetMnodeEpSet
(
pWrapper
->
pMgmt
,
&
epSet
);
dndReleaseWrapper
(
pWrapper
);
}
rpcSendRecv
(
pMgmt
->
clientRpc
,
&
epSet
,
pRpcMsg
,
pRpcRsp
);
rpcSendRecv
(
pMgmt
->
clientRpc
,
&
epSet
,
pRpcMsg
,
pRpcRsp
);
}
}
...
@@ -180,10 +187,15 @@ static int32_t dndRetrieveUserAuthInfo(void *parent, char *user, char *spi, char
...
@@ -180,10 +187,15 @@ static int32_t dndRetrieveUserAuthInfo(void *parent, char *user, char *spi, char
return
0
;
return
0
;
}
}
if
(
mmGetUserAuth
(
dndAcquireWrapper
(
pDnode
,
MNODE
),
user
,
spi
,
encrypt
,
secret
,
ckey
)
==
0
)
{
SMgmtWrapper
*
pWrapper
=
dndAcquireWrapper
(
pDnode
,
MNODE
);
if
(
pWrapper
!=
NULL
)
{
if
(
mmGetUserAuth
(
pWrapper
,
user
,
spi
,
encrypt
,
secret
,
ckey
)
==
0
)
{
dndReleaseWrapper
(
pWrapper
);
dTrace
(
"user:%s, get auth from mnode, spi:%d encrypt:%d"
,
user
,
*
spi
,
*
encrypt
);
dTrace
(
"user:%s, get auth from mnode, spi:%d encrypt:%d"
,
user
,
*
spi
,
*
encrypt
);
return
0
;
return
0
;
}
}
dndReleaseWrapper
(
pWrapper
);
}
if
(
terrno
!=
TSDB_CODE_APP_NOT_READY
)
{
if
(
terrno
!=
TSDB_CODE_APP_NOT_READY
)
{
dTrace
(
"failed to get user auth from mnode since %s"
,
terrstr
());
dTrace
(
"failed to get user auth from mnode since %s"
,
terrstr
());
...
@@ -269,21 +281,27 @@ int32_t dndInitMsgHandle(SDnode *pDnode) {
...
@@ -269,21 +281,27 @@ int32_t dndInitMsgHandle(SDnode *pDnode) {
int32_t
vgId
=
pWrapper
->
msgVgIds
[
msgIndex
];
int32_t
vgId
=
pWrapper
->
msgVgIds
[
msgIndex
];
if
(
msgFp
==
NULL
)
continue
;
if
(
msgFp
==
NULL
)
continue
;
// dTrace("msg:%s will be processed by %s, vgId:%d", tMsgInfo[msgIndex], pWrapper->name, vgId);
SMsgHandle
*
pHandle
=
&
pMgmt
->
msgHandles
[
msgIndex
];
SMsgHandle
*
pHandle
=
&
pMgmt
->
msgHandles
[
msgIndex
];
if
(
pHandle
->
msgFp
!=
NULL
&&
pHandle
->
vgId
==
vgId
)
{
if
(
vgId
==
QND_VGID
)
{
dError
(
"msg:%s has multiple process nodes, prev node:%s:%d, curr node:%s:%d"
,
tMsgInfo
[
msgIndex
],
if
(
pHandle
->
pQndWrapper
!=
NULL
)
{
pHandle
->
pWrapper
->
name
,
pHandle
->
pWrapper
->
msgVgIds
[
msgIndex
],
pWrapper
->
name
,
vgId
);
dError
(
"msg:%s has multiple process nodes"
,
tMsgInfo
[
msgIndex
]
);
return
-
1
;
return
-
1
;
}
pHandle
->
pQndWrapper
=
pWrapper
;
}
else
if
(
vgId
==
MND_VGID
)
{
if
(
pHandle
->
pMndWrapper
!=
NULL
)
{
dError
(
"msg:%s has multiple process nodes"
,
tMsgInfo
[
msgIndex
]);
return
-
1
;
}
pHandle
->
pMndWrapper
=
pWrapper
;
}
else
{
}
else
{
dTrace
(
"msg:%s will be processed by %s, vgId:%d"
,
tMsgInfo
[
msgIndex
],
pWrapper
->
name
,
vgId
);
if
(
pHandle
->
pWrapper
!=
NULL
)
{
if
(
vgId
==
0
)
{
dError
(
"msg:%s has multiple process nodes"
,
tMsgInfo
[
msgIndex
]);
pHandle
->
msgFp
=
msgFp
;
return
-
1
;
pHandle
->
pWrapper
=
pWrapper
;
}
else
{
pHandle
->
vgId
=
vgId
;
pHandle
->
vgIdMsgFp
=
msgFp
;
pHandle
->
pVgIdWrapper
=
pWrapper
;
}
}
pHandle
->
pWrapper
=
pWrapper
;
}
}
}
}
}
}
...
@@ -320,7 +338,12 @@ int32_t dndSendReqToMnode(SMgmtWrapper *pWrapper, SRpcMsg *pReq) {
...
@@ -320,7 +338,12 @@ int32_t dndSendReqToMnode(SMgmtWrapper *pWrapper, SRpcMsg *pReq) {
SDnode
*
pDnode
=
pWrapper
->
pDnode
;
SDnode
*
pDnode
=
pWrapper
->
pDnode
;
STransMgmt
*
pTrans
=
&
pDnode
->
trans
;
STransMgmt
*
pTrans
=
&
pDnode
->
trans
;
SEpSet
epSet
=
{
0
};
SEpSet
epSet
=
{
0
};
dmGetMnodeEpSet
(
dndAcquireWrapper
(
pDnode
,
DNODE
)
->
pMgmt
,
&
epSet
);
SMgmtWrapper
*
pWrapper
=
dndAcquireWrapper
(
pDnode
,
DNODE
);
if
(
pWrapper
!=
NULL
)
{
dmGetMnodeEpSet
(
pWrapper
->
pMgmt
,
&
epSet
);
dndReleaseWrapper
(
pWrapper
);
}
return
dndSendRpcReq
(
pTrans
,
&
epSet
,
pReq
);
return
dndSendRpcReq
(
pTrans
,
&
epSet
,
pReq
);
}
}
}
}
...
@@ -328,7 +351,12 @@ int32_t dndSendReqToMnode(SMgmtWrapper *pWrapper, SRpcMsg *pReq) {
...
@@ -328,7 +351,12 @@ int32_t dndSendReqToMnode(SMgmtWrapper *pWrapper, SRpcMsg *pReq) {
void
dndSendRpcRsp
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pRsp
)
{
void
dndSendRpcRsp
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pRsp
)
{
if
(
pRsp
->
code
==
TSDB_CODE_APP_NOT_READY
)
{
if
(
pRsp
->
code
==
TSDB_CODE_APP_NOT_READY
)
{
SMgmtWrapper
*
pDnodeWrapper
=
dndAcquireWrapper
(
pWrapper
->
pDnode
,
DNODE
);
SMgmtWrapper
*
pDnodeWrapper
=
dndAcquireWrapper
(
pWrapper
->
pDnode
,
DNODE
);
if
(
pDnodeWrapper
!=
NULL
)
{
dmSendRedirectRsp
(
pDnodeWrapper
->
pMgmt
,
pRsp
);
dmSendRedirectRsp
(
pDnodeWrapper
->
pMgmt
,
pRsp
);
dndReleaseWrapper
(
pDnodeWrapper
);
}
else
{
rpcSendResponse
(
pRsp
);
}
}
else
{
}
else
{
rpcSendResponse
(
pRsp
);
rpcSendResponse
(
pRsp
);
}
}
...
...
source/dnode/mgmt/dnode/src/dmFile.c
浏览文件 @
bdbf365e
...
@@ -209,7 +209,7 @@ int32_t dmWriteFile(SDnodeMgmt *pMgmt) {
...
@@ -209,7 +209,7 @@ int32_t dmWriteFile(SDnodeMgmt *pMgmt) {
}
}
pMgmt
->
updateTime
=
taosGetTimestampMs
();
pMgmt
->
updateTime
=
taosGetTimestampMs
();
dDebug
(
"successed to write %s"
,
file
);
dDebug
(
"successed to write %s"
,
real
file
);
return
0
;
return
0
;
}
}
...
...
source/dnode/mgmt/dnode/src/dmInt.c
浏览文件 @
bdbf365e
...
@@ -74,14 +74,14 @@ void dmSendRedirectRsp(SDnodeMgmt *pMgmt, SRpcMsg *pReq) {
...
@@ -74,14 +74,14 @@ void dmSendRedirectRsp(SDnodeMgmt *pMgmt, SRpcMsg *pReq) {
}
}
static
int32_t
dmStart
(
SMgmtWrapper
*
pWrapper
)
{
static
int32_t
dmStart
(
SMgmtWrapper
*
pWrapper
)
{
dDebug
(
"dnode
mgmt start to run"
);
dDebug
(
"dnode
-
mgmt start to run"
);
return
dmStartThread
(
pWrapper
->
pMgmt
);
return
dmStartThread
(
pWrapper
->
pMgmt
);
}
}
int32_t
dmInit
(
SMgmtWrapper
*
pWrapper
)
{
int32_t
dmInit
(
SMgmtWrapper
*
pWrapper
)
{
SDnode
*
pDnode
=
pWrapper
->
pDnode
;
SDnode
*
pDnode
=
pWrapper
->
pDnode
;
SDnodeMgmt
*
pMgmt
=
calloc
(
1
,
sizeof
(
SDnodeMgmt
));
SDnodeMgmt
*
pMgmt
=
calloc
(
1
,
sizeof
(
SDnodeMgmt
));
dInfo
(
"dnode-mgmt
is initialized
"
);
dInfo
(
"dnode-mgmt
start to init
"
);
pDnode
->
dnodeId
=
0
;
pDnode
->
dnodeId
=
0
;
pDnode
->
dropped
=
0
;
pDnode
->
dropped
=
0
;
...
...
source/dnode/mgmt/dnode/src/dmMsg.c
浏览文件 @
bdbf365e
...
@@ -41,8 +41,12 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
...
@@ -41,8 +41,12 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
memcpy
(
req
.
clusterCfg
.
charset
,
tsCharset
,
TD_LOCALE_LEN
);
memcpy
(
req
.
clusterCfg
.
charset
,
tsCharset
,
TD_LOCALE_LEN
);
taosRUnLockLatch
(
&
pMgmt
->
latch
);
taosRUnLockLatch
(
&
pMgmt
->
latch
);
SMgmtWrapper
*
pWrapper
=
dndAcquireWrapper
(
pDnode
,
VNODES
);
if
(
pWrapper
!=
NULL
)
{
req
.
pVloads
=
taosArrayInit
(
TSDB_MAX_VNODES
,
sizeof
(
SVnodeLoad
));
req
.
pVloads
=
taosArrayInit
(
TSDB_MAX_VNODES
,
sizeof
(
SVnodeLoad
));
vmMonitorVnodeLoads
(
dndAcquireWrapper
(
pDnode
,
VNODES
),
req
.
pVloads
);
vmMonitorVnodeLoads
(
pWrapper
,
req
.
pVloads
);
dndReleaseWrapper
(
pWrapper
);
}
int32_t
contLen
=
tSerializeSStatusReq
(
NULL
,
0
,
&
req
);
int32_t
contLen
=
tSerializeSStatusReq
(
NULL
,
0
,
&
req
);
void
*
pHead
=
rpcMallocCont
(
contLen
);
void
*
pHead
=
rpcMallocCont
(
contLen
);
...
@@ -114,19 +118,19 @@ int32_t dmProcessConfigReq(SDnodeMgmt *pMgmt, SNodeMsg *pMsg) {
...
@@ -114,19 +118,19 @@ int32_t dmProcessConfigReq(SDnodeMgmt *pMgmt, SNodeMsg *pMsg) {
void
dmInitMsgHandles
(
SMgmtWrapper
*
pWrapper
)
{
void
dmInitMsgHandles
(
SMgmtWrapper
*
pWrapper
)
{
// Requests handled by DNODE
// Requests handled by DNODE
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_MNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_MNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_MNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_MNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_QNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_QNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_QNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_QNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_SNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_SNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_SNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_SNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_BNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_BNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_BNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_BNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CONFIG_DNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CONFIG_DNODE
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_NETWORK_TEST
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_NETWORK_TEST
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
VND_VGID
);
// Requests handled by MNODE
// Requests handled by MNODE
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_STATUS_RSP
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_STATUS_RSP
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_GRANT_RSP
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_GRANT_RSP
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_AUTH_RSP
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_AUTH_RSP
,
(
NodeMsgFp
)
dmProcessMgmtMsg
,
VND_VGID
);
}
}
source/dnode/mgmt/dnode/src/dmWorker.c
浏览文件 @
bdbf365e
...
@@ -114,6 +114,7 @@ int32_t dmStartWorker(SDnodeMgmt *pMgmt) {
...
@@ -114,6 +114,7 @@ int32_t dmStartWorker(SDnodeMgmt *pMgmt) {
return
-
1
;
return
-
1
;
}
}
dDebug
(
"dnode workers are initialized"
);
return
0
;
return
0
;
}
}
...
@@ -136,6 +137,7 @@ void dmStopWorker(SDnodeMgmt *pMgmt) {
...
@@ -136,6 +137,7 @@ void dmStopWorker(SDnodeMgmt *pMgmt) {
taosDestoryThread
(
pMgmt
->
threadId
);
taosDestoryThread
(
pMgmt
->
threadId
);
pMgmt
->
threadId
=
NULL
;
pMgmt
->
threadId
=
NULL
;
}
}
dDebug
(
"dnode workers are closed"
);
}
}
int32_t
dmProcessMgmtMsg
(
SDnodeMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
)
{
int32_t
dmProcessMgmtMsg
(
SDnodeMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
)
{
...
@@ -144,6 +146,6 @@ int32_t dmProcessMgmtMsg(SDnodeMgmt *pMgmt, SNodeMsg *pMsg) {
...
@@ -144,6 +146,6 @@ int32_t dmProcessMgmtMsg(SDnodeMgmt *pMgmt, SNodeMsg *pMsg) {
pWorker
=
&
pMgmt
->
statusWorker
;
pWorker
=
&
pMgmt
->
statusWorker
;
}
}
dTrace
(
"msg:%p,
will be written
to worker %s"
,
pMsg
,
pWorker
->
name
);
dTrace
(
"msg:%p,
put in
to worker %s"
,
pMsg
,
pWorker
->
name
);
return
taosWriteQitem
(
pWorker
->
queue
,
pMsg
);
return
taosWriteQitem
(
pWorker
->
queue
,
pMsg
);
}
}
source/dnode/mgmt/mnode/src/mmInt.c
浏览文件 @
bdbf365e
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "mmInt.h"
#include "mmInt.h"
#include "wal.h"
static
bool
mmDeployRequired
(
SDnode
*
pDnode
)
{
static
bool
mmDeployRequired
(
SDnode
*
pDnode
)
{
if
(
pDnode
->
dnodeId
>
0
)
return
false
;
if
(
pDnode
->
dnodeId
>
0
)
return
false
;
...
@@ -226,7 +227,7 @@ static int32_t mmOpen(SMgmtWrapper *pWrapper) {
...
@@ -226,7 +227,7 @@ static int32_t mmOpen(SMgmtWrapper *pWrapper) {
}
}
static
int32_t
mmStart
(
SMgmtWrapper
*
pWrapper
)
{
static
int32_t
mmStart
(
SMgmtWrapper
*
pWrapper
)
{
dDebug
(
"mnode
mgmt start to run"
);
dDebug
(
"mnode
-
mgmt start to run"
);
SMnodeMgmt
*
pMgmt
=
pWrapper
->
pMgmt
;
SMnodeMgmt
*
pMgmt
=
pWrapper
->
pMgmt
;
return
mndStart
(
pMgmt
->
pMnode
);
return
mndStart
(
pMgmt
->
pMnode
);
}
}
...
...
source/dnode/mgmt/mnode/src/mmMsg.c
浏览文件 @
bdbf365e
...
@@ -75,84 +75,90 @@ int32_t mmProcessAlterReq(SMnodeMgmt *pMgmt, SNodeMsg *pMsg) {
...
@@ -75,84 +75,90 @@ int32_t mmProcessAlterReq(SMnodeMgmt *pMgmt, SNodeMsg *pMsg) {
void
mmInitMsgHandles
(
SMgmtWrapper
*
pWrapper
)
{
void
mmInitMsgHandles
(
SMgmtWrapper
*
pWrapper
)
{
// Requests handled by DNODE
// Requests handled by DNODE
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_MNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_MNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_ALTER_MNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_ALTER_MNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_MNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_MNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_QNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_QNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_QNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_QNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_SNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_SNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_SNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_SNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_BNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_BNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_BNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_BNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_VNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_VNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_ALTER_VNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_ALTER_VNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_VNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_VNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_SYNC_VNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_SYNC_VNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_COMPACT_VNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_COMPACT_VNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CONFIG_DNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CONFIG_DNODE_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
// Requests handled by MNODE
// Requests handled by MNODE
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CONNECT
,
(
NodeMsgFp
)
mmProcessReadMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CONNECT
,
(
NodeMsgFp
)
mmProcessReadMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_ACCT
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_ACCT
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_ALTER_ACCT
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_ALTER_ACCT
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_ACCT
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_ACCT
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_USER
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_USER
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_ALTER_USER
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_ALTER_USER
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_USER
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_USER
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_GET_USER_AUTH
,
(
NodeMsgFp
)
mmProcessReadMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_GET_USER_AUTH
,
(
NodeMsgFp
)
mmProcessReadMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_DNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_DNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CONFIG_DNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CONFIG_DNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_DNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_DNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_MNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_MNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_MNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_MNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_QNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_QNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_QNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_QNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_SNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_SNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_SNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_SNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_BNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_BNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_BNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_BNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_DB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_DB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_DB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_DB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_USE_DB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_USE_DB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_ALTER_DB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_ALTER_DB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_SYNC_DB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_SYNC_DB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_COMPACT_DB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_COMPACT_DB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_FUNC
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_FUNC
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_RETRIEVE_FUNC
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_RETRIEVE_FUNC
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_FUNC
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_FUNC
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_STB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_STB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_ALTER_STB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_ALTER_STB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_STB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_STB
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_SMA
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_SMA
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_SMA
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_SMA
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_TABLE_META
,
(
NodeMsgFp
)
mmProcessReadMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_TABLE_META
,
(
NodeMsgFp
)
mmProcessReadMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_VGROUP_LIST
,
(
NodeMsgFp
)
mmProcessReadMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_VGROUP_LIST
,
(
NodeMsgFp
)
mmProcessReadMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_KILL_QUERY
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_KILL_QUERY
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_KILL_CONN
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_KILL_CONN
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_HEARTBEAT
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_HEARTBEAT
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_SHOW
,
(
NodeMsgFp
)
mmProcessReadMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_SHOW
,
(
NodeMsgFp
)
mmProcessReadMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_SHOW_RETRIEVE
,
(
NodeMsgFp
)
mmProcessReadMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_SHOW_RETRIEVE
,
(
NodeMsgFp
)
mmProcessReadMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_SYSTABLE_RETRIEVE
,
(
NodeMsgFp
)
mmProcessReadMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_SYSTABLE_RETRIEVE
,
(
NodeMsgFp
)
mmProcessReadMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_STATUS
,
(
NodeMsgFp
)
mmProcessReadMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_STATUS
,
(
NodeMsgFp
)
mmProcessReadMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_KILL_TRANS
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_KILL_TRANS
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_GRANT
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_GRANT
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_AUTH
,
(
NodeMsgFp
)
mmProcessReadMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_AUTH
,
(
NodeMsgFp
)
mmProcessReadMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_ALTER_MNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_ALTER_MNODE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_TOPIC
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_TOPIC
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_ALTER_TOPIC
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_ALTER_TOPIC
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_TOPIC
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_DROP_TOPIC
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_SUBSCRIBE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_SUBSCRIBE
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_MQ_COMMIT_OFFSET
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_MQ_COMMIT_OFFSET
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_GET_SUB_EP
,
(
NodeMsgFp
)
mmProcessReadMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_GET_SUB_EP
,
(
NodeMsgFp
)
mmProcessReadMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_STREAM
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_MND_CREATE_STREAM
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TASK_DEPLOY_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TASK_DEPLOY_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
// Requests handled by VNODE
// Requests handled by VNODE
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_SET_CONN_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_SET_CONN_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_REB_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_REB_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CREATE_STB_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CREATE_STB_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_ALTER_STB_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_ALTER_STB_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_STB_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_STB_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CREATE_SMA_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CREATE_SMA_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_SMA_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_SMA_RSP
,
(
NodeMsgFp
)
mmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY
,
(
NodeMsgFp
)
mmProcessReadMsg
,
MND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY_CONTINUE
,
(
NodeMsgFp
)
mmProcessReadMsg
,
MND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_FETCH
,
(
NodeMsgFp
)
mmProcessReadMsg
,
MND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_FETCH_RSP
,
(
NodeMsgFp
)
mmProcessReadMsg
,
MND_VGID
);
}
}
source/dnode/mgmt/mnode/src/mmWorker.c
浏览文件 @
bdbf365e
...
@@ -108,6 +108,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
...
@@ -108,6 +108,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
return
-
1
;
return
-
1
;
}
}
dDebug
(
"mnode workers are initialized"
);
return
0
;
return
0
;
}
}
...
@@ -115,4 +116,5 @@ void mmStopWorker(SMnodeMgmt *pMgmt) {
...
@@ -115,4 +116,5 @@ void mmStopWorker(SMnodeMgmt *pMgmt) {
tSingleWorkerCleanup
(
&
pMgmt
->
readWorker
);
tSingleWorkerCleanup
(
&
pMgmt
->
readWorker
);
tSingleWorkerCleanup
(
&
pMgmt
->
writeWorker
);
tSingleWorkerCleanup
(
&
pMgmt
->
writeWorker
);
tSingleWorkerCleanup
(
&
pMgmt
->
syncWorker
);
tSingleWorkerCleanup
(
&
pMgmt
->
syncWorker
);
dDebug
(
"mnode workers are closed"
);
}
}
source/dnode/mgmt/qnode/src/qmMsg.c
浏览文件 @
bdbf365e
...
@@ -56,14 +56,14 @@ int32_t qmProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
...
@@ -56,14 +56,14 @@ int32_t qmProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
void
qmInitMsgHandles
(
SMgmtWrapper
*
pWrapper
)
{
void
qmInitMsgHandles
(
SMgmtWrapper
*
pWrapper
)
{
// Requests handled by VNODE
// Requests handled by VNODE
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY
,
(
NodeMsgFp
)
qmProcessQueryMsg
,
1
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY
,
(
NodeMsgFp
)
qmProcessQueryMsg
,
QND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY_CONTINUE
,
(
NodeMsgFp
)
qmProcessQueryMsg
,
1
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY_CONTINUE
,
(
NodeMsgFp
)
qmProcessQueryMsg
,
QND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_FETCH
,
(
NodeMsgFp
)
qmProcessFetchMsg
,
1
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_FETCH
,
(
NodeMsgFp
)
qmProcessFetchMsg
,
QND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_FETCH_RSP
,
(
NodeMsgFp
)
qmProcessFetchMsg
,
1
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_FETCH_RSP
,
(
NodeMsgFp
)
qmProcessFetchMsg
,
QND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_RES_READY
,
(
NodeMsgFp
)
qmProcessFetchMsg
,
1
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_RES_READY
,
(
NodeMsgFp
)
qmProcessFetchMsg
,
QND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TASKS_STATUS
,
(
NodeMsgFp
)
qmProcessFetchMsg
,
1
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TASKS_STATUS
,
(
NodeMsgFp
)
qmProcessFetchMsg
,
QND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CANCEL_TASK
,
(
NodeMsgFp
)
qmProcessFetchMsg
,
1
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CANCEL_TASK
,
(
NodeMsgFp
)
qmProcessFetchMsg
,
QND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_TASK
,
(
NodeMsgFp
)
qmProcessFetchMsg
,
1
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_TASK
,
(
NodeMsgFp
)
qmProcessFetchMsg
,
QND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_SHOW_TABLES
,
(
NodeMsgFp
)
qmProcessFetchMsg
,
1
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_SHOW_TABLES
,
(
NodeMsgFp
)
qmProcessFetchMsg
,
QND_VGID
);
}
}
source/dnode/mgmt/qnode/src/qmWorker.c
浏览文件 @
bdbf365e
...
@@ -132,10 +132,12 @@ int32_t qmStartWorker(SQnodeMgmt *pMgmt) {
...
@@ -132,10 +132,12 @@ int32_t qmStartWorker(SQnodeMgmt *pMgmt) {
return
-
1
;
return
-
1
;
}
}
dDebug
(
"qnode workers are initialized"
);
return
0
;
return
0
;
}
}
void
qmStopWorker
(
SQnodeMgmt
*
pMgmt
)
{
void
qmStopWorker
(
SQnodeMgmt
*
pMgmt
)
{
tSingleWorkerCleanup
(
&
pMgmt
->
queryWorker
);
tSingleWorkerCleanup
(
&
pMgmt
->
queryWorker
);
tSingleWorkerCleanup
(
&
pMgmt
->
fetchWorker
);
tSingleWorkerCleanup
(
&
pMgmt
->
fetchWorker
);
dDebug
(
"qnode workers are closed"
);
}
}
source/dnode/mgmt/snode/src/smMsg.c
浏览文件 @
bdbf365e
...
@@ -56,6 +56,6 @@ int32_t smProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
...
@@ -56,6 +56,6 @@ int32_t smProcessDropReq(SMgmtWrapper *pWrapper, SNodeMsg *pMsg) {
void
smInitMsgHandles
(
SMgmtWrapper
*
pWrapper
)
{
void
smInitMsgHandles
(
SMgmtWrapper
*
pWrapper
)
{
// Requests handled by SNODE
// Requests handled by SNODE
dndSetMsgHandle
(
pWrapper
,
TDMT_SND_TASK_DEPLOY
,
(
NodeMsgFp
)
smProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_SND_TASK_DEPLOY
,
(
NodeMsgFp
)
smProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_SND_TASK_EXEC
,
(
NodeMsgFp
)
smProcessExecMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_SND_TASK_EXEC
,
(
NodeMsgFp
)
smProcessExecMsg
,
VND_VGID
);
}
}
source/dnode/mgmt/snode/src/smWorker.c
浏览文件 @
bdbf365e
...
@@ -80,6 +80,7 @@ int32_t smStartWorker(SSnodeMgmt *pMgmt) {
...
@@ -80,6 +80,7 @@ int32_t smStartWorker(SSnodeMgmt *pMgmt) {
return
-
1
;
return
-
1
;
}
}
dDebug
(
"snode workers are initialized"
);
return
0
;
return
0
;
}
}
...
@@ -90,6 +91,7 @@ void smStopWorker(SSnodeMgmt *pMgmt) {
...
@@ -90,6 +91,7 @@ void smStopWorker(SSnodeMgmt *pMgmt) {
}
}
taosArrayDestroy
(
pMgmt
->
uniqueWorkers
);
taosArrayDestroy
(
pMgmt
->
uniqueWorkers
);
tSingleWorkerCleanup
(
&
pMgmt
->
sharedWorker
);
tSingleWorkerCleanup
(
&
pMgmt
->
sharedWorker
);
dDebug
(
"snode workers are closed"
);
}
}
static
FORCE_INLINE
int32_t
smGetSWIdFromMsg
(
SRpcMsg
*
pMsg
)
{
static
FORCE_INLINE
int32_t
smGetSWIdFromMsg
(
SRpcMsg
*
pMsg
)
{
...
...
source/dnode/mgmt/vnode/src/vmInt.c
浏览文件 @
bdbf365e
...
@@ -257,14 +257,14 @@ static void vmCleanup(SMgmtWrapper *pWrapper) {
...
@@ -257,14 +257,14 @@ static void vmCleanup(SMgmtWrapper *pWrapper) {
SVnodesMgmt
*
pMgmt
=
pWrapper
->
pMgmt
;
SVnodesMgmt
*
pMgmt
=
pWrapper
->
pMgmt
;
if
(
pMgmt
==
NULL
)
return
;
if
(
pMgmt
==
NULL
)
return
;
dInfo
(
"vnode
s
-mgmt start to cleanup"
);
dInfo
(
"vnode-mgmt start to cleanup"
);
vmCloseVnodes
(
pMgmt
);
vmCloseVnodes
(
pMgmt
);
vmStopWorker
(
pMgmt
);
vmStopWorker
(
pMgmt
);
vnodeCleanup
();
vnodeCleanup
();
// walCleanUp();
// walCleanUp();
free
(
pMgmt
);
free
(
pMgmt
);
pWrapper
->
pMgmt
=
NULL
;
pWrapper
->
pMgmt
=
NULL
;
dInfo
(
"vnode
s
-mgmt is cleaned up"
);
dInfo
(
"vnode-mgmt is cleaned up"
);
}
}
static
int32_t
vmInit
(
SMgmtWrapper
*
pWrapper
)
{
static
int32_t
vmInit
(
SMgmtWrapper
*
pWrapper
)
{
...
@@ -272,7 +272,7 @@ static int32_t vmInit(SMgmtWrapper *pWrapper) {
...
@@ -272,7 +272,7 @@ static int32_t vmInit(SMgmtWrapper *pWrapper) {
SVnodesMgmt
*
pMgmt
=
calloc
(
1
,
sizeof
(
SVnodesMgmt
));
SVnodesMgmt
*
pMgmt
=
calloc
(
1
,
sizeof
(
SVnodesMgmt
));
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
dInfo
(
"vnode
s
-mgmt start to init"
);
dInfo
(
"vnode-mgmt start to init"
);
if
(
pMgmt
==
NULL
)
goto
_OVER
;
if
(
pMgmt
==
NULL
)
goto
_OVER
;
pMgmt
->
path
=
pWrapper
->
path
;
pMgmt
->
path
=
pWrapper
->
path
;
...
@@ -312,7 +312,7 @@ static int32_t vmInit(SMgmtWrapper *pWrapper) {
...
@@ -312,7 +312,7 @@ static int32_t vmInit(SMgmtWrapper *pWrapper) {
}
}
if
(
vmOpenVnodes
(
pMgmt
)
!=
0
)
{
if
(
vmOpenVnodes
(
pMgmt
)
!=
0
)
{
dError
(
"failed to open vnode
s
since %s"
,
terrstr
());
dError
(
"failed to open vnode since %s"
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
...
...
source/dnode/mgmt/vnode/src/vmMsg.c
浏览文件 @
bdbf365e
...
@@ -244,49 +244,49 @@ int32_t vmProcessCompactVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) {
...
@@ -244,49 +244,49 @@ int32_t vmProcessCompactVnodeReq(SVnodesMgmt *pMgmt, SNodeMsg *pMsg) {
void
vmInitMsgHandles
(
SMgmtWrapper
*
pWrapper
)
{
void
vmInitMsgHandles
(
SMgmtWrapper
*
pWrapper
)
{
// Requests handled by VNODE
// Requests handled by VNODE
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_SUBMIT
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_SUBMIT
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY
,
(
NodeMsgFp
)
vmProcessQueryMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY
,
(
NodeMsgFp
)
vmProcessQueryMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY_CONTINUE
,
(
NodeMsgFp
)
vmProcessQueryMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY_CONTINUE
,
(
NodeMsgFp
)
vmProcessQueryMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_FETCH
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_FETCH
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_FETCH_RSP
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_FETCH_RSP
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_ALTER_TABLE
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_ALTER_TABLE
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_UPDATE_TAG_VAL
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_UPDATE_TAG_VAL
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TABLE_META
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TABLE_META
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TABLES_META
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TABLES_META
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_CONSUME
,
(
NodeMsgFp
)
vmProcessQueryMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_CONSUME
,
(
NodeMsgFp
)
vmProcessQueryMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_QUERY
,
(
NodeMsgFp
)
vmProcessQueryMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_QUERY
,
(
NodeMsgFp
)
vmProcessQueryMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_CONNECT
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_CONNECT
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_DISCONNECT
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_DISCONNECT
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_SET_CUR
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_SET_CUR
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_RES_READY
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_RES_READY
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TASKS_STATUS
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TASKS_STATUS
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CANCEL_TASK
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CANCEL_TASK
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_TASK
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_TASK
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CREATE_STB
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CREATE_STB
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_ALTER_STB
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_ALTER_STB
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_STB
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_STB
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CREATE_TABLE
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CREATE_TABLE
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_ALTER_TABLE
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_ALTER_TABLE
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_TABLE
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_TABLE
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CREATE_SMA
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CREATE_SMA
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CANCEL_SMA
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CANCEL_SMA
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_SMA
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_DROP_SMA
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_SHOW_TABLES
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_SHOW_TABLES
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_SHOW_TABLES_FETCH
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_SHOW_TABLES_FETCH
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_SET_CONN
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_SET_CONN
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_REB
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_REB
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_SET_CUR
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_MQ_SET_CUR
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CONSUME
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_CONSUME
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TASK_DEPLOY
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TASK_DEPLOY
,
(
NodeMsgFp
)
vmProcessWriteMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY_HEARTBEAT
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_QUERY_HEARTBEAT
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TASK_EXEC
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TASK_EXEC
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TASK_PIPE_EXEC
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TASK_PIPE_EXEC
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TASK_MERGE_EXEC
,
(
NodeMsgFp
)
vmProcessMergeMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_TASK_MERGE_EXEC
,
(
NodeMsgFp
)
vmProcessMergeMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_STREAM_TRIGGER
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_VND_STREAM_TRIGGER
,
(
NodeMsgFp
)
vmProcessFetchMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_VNODE
,
(
NodeMsgFp
)
vmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_CREATE_VNODE
,
(
NodeMsgFp
)
vmProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_ALTER_VNODE
,
(
NodeMsgFp
)
vmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_ALTER_VNODE
,
(
NodeMsgFp
)
vmProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_VNODE
,
(
NodeMsgFp
)
vmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_DROP_VNODE
,
(
NodeMsgFp
)
vmProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_SYNC_VNODE
,
(
NodeMsgFp
)
vmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_SYNC_VNODE
,
(
NodeMsgFp
)
vmProcessMgmtMsg
,
VND_VGID
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_COMPACT_VNODE
,
(
NodeMsgFp
)
vmProcessMgmtMsg
,
0
);
dndSetMsgHandle
(
pWrapper
,
TDMT_DND_COMPACT_VNODE
,
(
NodeMsgFp
)
vmProcessMgmtMsg
,
VND_VGID
);
}
}
source/dnode/mgmt/vnode/src/vmWorker.c
浏览文件 @
bdbf365e
...
@@ -372,7 +372,7 @@ int32_t vmStartWorker(SVnodesMgmt *pMgmt) {
...
@@ -372,7 +372,7 @@ int32_t vmStartWorker(SVnodesMgmt *pMgmt) {
return
-
1
;
return
-
1
;
}
}
dDebug
(
"vnode workers
is
initialized"
);
dDebug
(
"vnode workers
are
initialized"
);
return
0
;
return
0
;
}
}
...
@@ -382,5 +382,5 @@ void vmStopWorker(SVnodesMgmt *pMgmt) {
...
@@ -382,5 +382,5 @@ void vmStopWorker(SVnodesMgmt *pMgmt) {
tQWorkerCleanup
(
&
pMgmt
->
queryPool
);
tQWorkerCleanup
(
&
pMgmt
->
queryPool
);
tWWorkerCleanup
(
&
pMgmt
->
writePool
);
tWWorkerCleanup
(
&
pMgmt
->
writePool
);
tWWorkerCleanup
(
&
pMgmt
->
syncPool
);
tWWorkerCleanup
(
&
pMgmt
->
syncPool
);
dDebug
(
"vnode workers
is
closed"
);
dDebug
(
"vnode workers
are
closed"
);
}
}
source/dnode/mnode/impl/CMakeLists.txt
浏览文件 @
bdbf365e
...
@@ -6,7 +6,7 @@ target_include_directories(
...
@@ -6,7 +6,7 @@ target_include_directories(
PRIVATE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
PRIVATE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
)
)
target_link_libraries
(
target_link_libraries
(
mnode scheduler sdb wal transport cjson sync monitor
mnode scheduler sdb wal transport cjson sync monitor
parser
)
)
if
(
${
BUILD_TEST
}
)
if
(
${
BUILD_TEST
}
)
...
...
source/dnode/mnode/impl/src/mndSma.c
浏览文件 @
bdbf365e
...
@@ -69,7 +69,7 @@ void mndCleanupSma(SMnode *pMnode) {}
...
@@ -69,7 +69,7 @@ void mndCleanupSma(SMnode *pMnode) {}
static
SSdbRaw
*
mndSmaActionEncode
(
SSmaObj
*
pSma
)
{
static
SSdbRaw
*
mndSmaActionEncode
(
SSmaObj
*
pSma
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
int32_t
size
=
sizeof
(
SSmaObj
)
+
pSma
->
exprLen
+
pSma
->
tagsFilterLen
+
TSDB_SMA_RESERVE_SIZE
;
int32_t
size
=
sizeof
(
SSmaObj
)
+
pSma
->
exprLen
+
pSma
->
tagsFilterLen
+
pSma
->
sqlLen
+
pSma
->
astLen
+
TSDB_SMA_RESERVE_SIZE
;
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_SMA
,
TSDB_SMA_VER_NUMBER
,
size
);
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_SMA
,
TSDB_SMA_VER_NUMBER
,
size
);
if
(
pRaw
==
NULL
)
goto
_OVER
;
if
(
pRaw
==
NULL
)
goto
_OVER
;
...
...
source/dnode/mnode/impl/src/mndStream.c
浏览文件 @
bdbf365e
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
*/
*/
#include "mndStream.h"
#include "mndStream.h"
#include "parser.h"
#include "mndAuth.h"
#include "mndAuth.h"
#include "mndDb.h"
#include "mndDb.h"
#include "mndDnode.h"
#include "mndDnode.h"
...
@@ -218,28 +219,6 @@ static int32_t mndCheckCreateStreamReq(SCMCreateStreamReq *pCreate) {
...
@@ -218,28 +219,6 @@ static int32_t mndCheckCreateStreamReq(SCMCreateStreamReq *pCreate) {
return
0
;
return
0
;
}
}
static
SArray
*
mndExtractNamesFromAst
(
const
SNode
*
pAst
)
{
if
(
pAst
->
type
!=
QUERY_NODE_SELECT_STMT
)
return
NULL
;
SArray
*
names
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
if
(
names
==
NULL
)
{
return
NULL
;
}
SSelectStmt
*
pSelect
=
(
SSelectStmt
*
)
pAst
;
SNodeList
*
pNodes
=
pSelect
->
pProjectionList
;
SListCell
*
pCell
=
pNodes
->
pHead
;
while
(
pCell
!=
NULL
)
{
if
(
pCell
->
pNode
->
type
!=
QUERY_NODE_FUNCTION
)
{
continue
;
}
SFunctionNode
*
pFunction
=
(
SFunctionNode
*
)
pCell
->
pNode
;
char
*
name
=
strdup
(
pFunction
->
node
.
aliasName
);
taosArrayPush
(
names
,
&
name
);
pCell
=
pCell
->
pNext
;
}
return
names
;
}
static
int32_t
mndStreamGetPlanString
(
const
char
*
ast
,
char
**
pStr
)
{
static
int32_t
mndStreamGetPlanString
(
const
char
*
ast
,
char
**
pStr
)
{
if
(
NULL
==
ast
)
{
if
(
NULL
==
ast
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -269,18 +248,23 @@ static int32_t mndStreamGetPlanString(const char *ast, char **pStr) {
...
@@ -269,18 +248,23 @@ static int32_t mndStreamGetPlanString(const char *ast, char **pStr) {
int32_t
mndAddStreamToTrans
(
SMnode
*
pMnode
,
SStreamObj
*
pStream
,
const
char
*
ast
,
STrans
*
pTrans
)
{
int32_t
mndAddStreamToTrans
(
SMnode
*
pMnode
,
SStreamObj
*
pStream
,
const
char
*
ast
,
STrans
*
pTrans
)
{
SNode
*
pAst
=
NULL
;
SNode
*
pAst
=
NULL
;
#if 1 // TODO: remove debug info later
printf
(
"ast = %s
\n
"
,
ast
);
#endif
if
(
nodesStringToNode
(
ast
,
&
pAst
)
<
0
)
{
if
(
nodesStringToNode
(
ast
,
&
pAst
)
<
0
)
{
return
-
1
;
return
-
1
;
}
}
#if 1
#if 1
SArray
*
names
=
mndExtractNamesFromAst
(
pAst
);
SSchemaWrapper
sw
=
{
0
};
qExtractResultSchema
(
pAst
,
(
int32_t
*
)
&
sw
.
nCols
,
&
sw
.
pSchema
);
printf
(
"|"
);
printf
(
"|"
);
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
names
)
;
i
++
)
{
for
(
int
i
=
0
;
i
<
sw
.
nCols
;
i
++
)
{
printf
(
" %15s |"
,
(
char
*
)
taosArrayGetP
(
names
,
i
)
);
printf
(
" %15s |"
,
(
char
*
)
sw
.
pSchema
[
i
].
name
);
}
}
printf
(
"
\n
=======================================================
\n
"
);
printf
(
"
\n
=======================================================
\n
"
);
pStream
->
ColAlias
=
names
;
pStream
->
ColAlias
=
NULL
;
#endif
#endif
if
(
TSDB_CODE_SUCCESS
!=
mndStreamGetPlanString
(
ast
,
&
pStream
->
physicalPlan
))
{
if
(
TSDB_CODE_SUCCESS
!=
mndStreamGetPlanString
(
ast
,
&
pStream
->
physicalPlan
))
{
...
...
source/dnode/vnode/inc/tsdb.h
浏览文件 @
bdbf365e
...
@@ -87,6 +87,15 @@ int tsdbInsertData(STsdb *pTsdb, SSubmitReq *pMsg, SSubmitRsp *pRsp);
...
@@ -87,6 +87,15 @@ int tsdbInsertData(STsdb *pTsdb, SSubmitReq *pMsg, SSubmitRsp *pRsp);
int
tsdbPrepareCommit
(
STsdb
*
pTsdb
);
int
tsdbPrepareCommit
(
STsdb
*
pTsdb
);
int
tsdbCommit
(
STsdb
*
pTsdb
);
int
tsdbCommit
(
STsdb
*
pTsdb
);
/**
* @brief When submit msg received, update the relative expired window synchronously.
*
* @param pTsdb
* @param msg
* @return int32_t
*/
int32_t
tsdbUpdateSmaWindow
(
STsdb
*
pTsdb
,
const
char
*
msg
);
/**
/**
* @brief Insert tSma(Time-range-wise SMA) data from stream computing engine
* @brief Insert tSma(Time-range-wise SMA) data from stream computing engine
*
*
...
@@ -95,11 +104,18 @@ int tsdbCommit(STsdb *pTsdb);
...
@@ -95,11 +104,18 @@ int tsdbCommit(STsdb *pTsdb);
* @return int32_t
* @return int32_t
*/
*/
int32_t
tsdbInsertTSmaData
(
STsdb
*
pTsdb
,
char
*
msg
);
int32_t
tsdbInsertTSmaData
(
STsdb
*
pTsdb
,
char
*
msg
);
int32_t
tsdbUpdateSmaWindow
(
STsdb
*
pTsdb
,
int8_t
smaType
,
char
*
msg
);
/**
* @brief Drop tSma data and local cache.
*
* @param pTsdb
* @param indexUid
* @return int32_t
*/
int32_t
tsdbDropTSmaData
(
STsdb
*
pTsdb
,
int64_t
indexUid
);
int32_t
tsdbDropTSmaData
(
STsdb
*
pTsdb
,
int64_t
indexUid
);
/**
/**
* @brief Insert RSma(
Time-range-wise
Rollup SMA) data.
* @brief Insert RSma(Rollup SMA) data.
*
*
* @param pTsdb
* @param pTsdb
* @param msg
* @param msg
...
@@ -108,6 +124,20 @@ int32_t tsdbDropTSmaData(STsdb *pTsdb, int64_t indexUid);
...
@@ -108,6 +124,20 @@ int32_t tsdbDropTSmaData(STsdb *pTsdb, int64_t indexUid);
int32_t
tsdbInsertRSmaData
(
STsdb
*
pTsdb
,
char
*
msg
);
int32_t
tsdbInsertRSmaData
(
STsdb
*
pTsdb
,
char
*
msg
);
// TODO: This is the basic params, and should wrap the params to a queryHandle.
// TODO: This is the basic params, and should wrap the params to a queryHandle.
/**
* @brief Get tSma(Time-range-wise SMA) data.
*
* @param pTsdb
* @param pData
* @param indexUid
* @param interval
* @param intervalUnit
* @param tableUid
* @param colId
* @param querySKey
* @param nMaxResult
* @return int32_t
*/
int32_t
tsdbGetTSmaData
(
STsdb
*
pTsdb
,
STSmaDataWrapper
*
pData
,
int64_t
indexUid
,
int64_t
interval
,
int8_t
intervalUnit
,
int32_t
tsdbGetTSmaData
(
STsdb
*
pTsdb
,
STSmaDataWrapper
*
pData
,
int64_t
indexUid
,
int64_t
interval
,
int8_t
intervalUnit
,
tb_uid_t
tableUid
,
col_id_t
colId
,
TSKEY
querySKey
,
int32_t
nMaxResult
);
tb_uid_t
tableUid
,
col_id_t
colId
,
TSKEY
querySKey
,
int32_t
nMaxResult
);
...
...
source/dnode/vnode/src/inc/tsdbDef.h
浏览文件 @
bdbf365e
...
@@ -63,6 +63,7 @@ struct STsdb {
...
@@ -63,6 +63,7 @@ struct STsdb {
#define REPO_ID(r) ((r)->vgId)
#define REPO_ID(r) ((r)->vgId)
#define REPO_CFG(r) (&(r)->config)
#define REPO_CFG(r) (&(r)->config)
#define REPO_FS(r) (r)->fs
#define REPO_FS(r) (r)->fs
#define REPO_META(r) (r)->pMeta
#define REPO_TFS(r) (r)->pTfs
#define REPO_TFS(r) (r)->pTfs
#define IS_REPO_LOCKED(r) (r)->repoLocked
#define IS_REPO_LOCKED(r) (r)->repoLocked
#define REPO_SMA_ENV(r, t) ((TSDB_SMA_TYPE_ROLLUP == (t)) ? (r)->pRSmaEnv : (r)->pTSmaEnv)
#define REPO_SMA_ENV(r, t) ((TSDB_SMA_TYPE_ROLLUP == (t)) ? (r)->pRSmaEnv : (r)->pTSmaEnv)
...
...
source/dnode/vnode/src/inc/tsdbSma.h
浏览文件 @
bdbf365e
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
#ifndef _TD_TSDB_SMA_H_
#ifndef _TD_TSDB_SMA_H_
#define _TD_TSDB_SMA_H_
#define _TD_TSDB_SMA_H_
#define TSDB_SMA_TEST // remove after test finished
typedef
struct
SSmaStat
SSmaStat
;
typedef
struct
SSmaStat
SSmaStat
;
typedef
struct
SSmaEnv
SSmaEnv
;
typedef
struct
SSmaEnv
SSmaEnv
;
...
...
source/dnode/vnode/src/tq/tqRead.c
浏览文件 @
bdbf365e
...
@@ -44,7 +44,7 @@ int32_t tqReadHandleSetMsg(STqReadHandle* pReadHandle, SSubmitReq* pMsg, int64_t
...
@@ -44,7 +44,7 @@ int32_t tqReadHandleSetMsg(STqReadHandle* pReadHandle, SSubmitReq* pMsg, int64_t
if
(
pReadHandle
->
pBlock
==
NULL
)
break
;
if
(
pReadHandle
->
pBlock
==
NULL
)
break
;
pReadHandle
->
pBlock
->
uid
=
htobe64
(
pReadHandle
->
pBlock
->
uid
);
pReadHandle
->
pBlock
->
uid
=
htobe64
(
pReadHandle
->
pBlock
->
uid
);
pReadHandle
->
pBlock
->
tid
=
htonl
(
pReadHandle
->
pBlock
->
t
id
);
pReadHandle
->
pBlock
->
suid
=
htobe64
(
pReadHandle
->
pBlock
->
su
id
);
pReadHandle
->
pBlock
->
sversion
=
htonl
(
pReadHandle
->
pBlock
->
sversion
);
pReadHandle
->
pBlock
->
sversion
=
htonl
(
pReadHandle
->
pBlock
->
sversion
);
pReadHandle
->
pBlock
->
dataLen
=
htonl
(
pReadHandle
->
pBlock
->
dataLen
);
pReadHandle
->
pBlock
->
dataLen
=
htonl
(
pReadHandle
->
pBlock
->
dataLen
);
pReadHandle
->
pBlock
->
schemaLen
=
htonl
(
pReadHandle
->
pBlock
->
schemaLen
);
pReadHandle
->
pBlock
->
schemaLen
=
htonl
(
pReadHandle
->
pBlock
->
schemaLen
);
...
...
source/dnode/vnode/src/tsdb/tsdbMemTable.c
浏览文件 @
bdbf365e
...
@@ -248,7 +248,7 @@ static int tsdbScanAndConvertSubmitMsg(STsdb *pTsdb, SSubmitReq *pMsg) {
...
@@ -248,7 +248,7 @@ static int tsdbScanAndConvertSubmitMsg(STsdb *pTsdb, SSubmitReq *pMsg) {
if
(
pBlock
==
NULL
)
break
;
if
(
pBlock
==
NULL
)
break
;
pBlock
->
uid
=
htobe64
(
pBlock
->
uid
);
pBlock
->
uid
=
htobe64
(
pBlock
->
uid
);
pBlock
->
tid
=
htonl
(
pBlock
->
t
id
);
pBlock
->
suid
=
htobe64
(
pBlock
->
su
id
);
pBlock
->
sversion
=
htonl
(
pBlock
->
sversion
);
pBlock
->
sversion
=
htonl
(
pBlock
->
sversion
);
pBlock
->
dataLen
=
htonl
(
pBlock
->
dataLen
);
pBlock
->
dataLen
=
htonl
(
pBlock
->
dataLen
);
pBlock
->
schemaLen
=
htonl
(
pBlock
->
schemaLen
);
pBlock
->
schemaLen
=
htonl
(
pBlock
->
schemaLen
);
...
...
source/dnode/vnode/src/tsdb/tsdbSma.c
浏览文件 @
bdbf365e
...
@@ -38,7 +38,7 @@ typedef enum {
...
@@ -38,7 +38,7 @@ typedef enum {
}
ESmaStorageLevel
;
}
ESmaStorageLevel
;
typedef
struct
{
typedef
struct
{
STsdb
*
pTsdb
;
STsdb
*
pTsdb
;
SDBFile
dFile
;
SDBFile
dFile
;
int32_t
interval
;
// interval with the precision of DB
int32_t
interval
;
// interval with the precision of DB
}
STSmaWriteH
;
}
STSmaWriteH
;
...
@@ -49,7 +49,7 @@ typedef struct {
...
@@ -49,7 +49,7 @@ typedef struct {
}
SmaFsIter
;
}
SmaFsIter
;
typedef
struct
{
typedef
struct
{
STsdb
*
pTsdb
;
STsdb
*
pTsdb
;
SDBFile
dFile
;
SDBFile
dFile
;
int32_t
interval
;
// interval with the precision of DB
int32_t
interval
;
// interval with the precision of DB
int32_t
blockSize
;
// size of SMA block item
int32_t
blockSize
;
// size of SMA block item
...
@@ -69,7 +69,7 @@ typedef struct {
...
@@ -69,7 +69,7 @@ typedef struct {
*/
*/
int8_t
state
;
// ETsdbSmaStat
int8_t
state
;
// ETsdbSmaStat
SHashObj
*
expiredWindows
;
// key: skey of time window, value: N/A
SHashObj
*
expiredWindows
;
// key: skey of time window, value: N/A
STSma
*
pSma
;
// cache schema
STSma
*
pSma
;
// cache schema
}
SSmaStatItem
;
}
SSmaStatItem
;
struct
SSmaStat
{
struct
SSmaStat
{
...
@@ -80,9 +80,9 @@ struct SSmaStat {
...
@@ -80,9 +80,9 @@ struct SSmaStat {
// declaration of static functions
// declaration of static functions
// expired window
// expired window
static
int32_t
tsdbUpdateExpiredWindow
(
STsdb
*
pTsdb
,
ETsdbSmaType
smaType
,
char
*
msg
);
static
int32_t
tsdbUpdateExpiredWindow
Impl
(
STsdb
*
pTsdb
,
const
char
*
msg
);
static
int32_t
tsdbInitSmaStat
(
SSmaStat
**
pSmaStat
);
static
int32_t
tsdbInitSmaStat
(
SSmaStat
**
pSmaStat
);
static
void
*
tsdbFreeSmaStatItem
(
SSmaStatItem
*
pSmaStatItem
);
static
void
*
tsdbFreeSmaStatItem
(
SSmaStatItem
*
pSmaStatItem
);
static
int32_t
tsdbDestroySmaState
(
SSmaStat
*
pSmaStat
);
static
int32_t
tsdbDestroySmaState
(
SSmaStat
*
pSmaStat
);
static
SSmaEnv
*
tsdbNewSmaEnv
(
const
STsdb
*
pTsdb
,
const
char
*
path
,
SDiskID
did
);
static
SSmaEnv
*
tsdbNewSmaEnv
(
const
STsdb
*
pTsdb
,
const
char
*
path
,
SDiskID
did
);
static
int32_t
tsdbInitSmaEnv
(
STsdb
*
pTsdb
,
const
char
*
path
,
SDiskID
did
,
SSmaEnv
**
pEnv
);
static
int32_t
tsdbInitSmaEnv
(
STsdb
*
pTsdb
,
const
char
*
path
,
SDiskID
did
,
SSmaEnv
**
pEnv
);
...
@@ -124,7 +124,7 @@ static FORCE_INLINE int8_t tsdbSmaStat(SSmaStatItem *pStatItem) {
...
@@ -124,7 +124,7 @@ static FORCE_INLINE int8_t tsdbSmaStat(SSmaStatItem *pStatItem) {
}
}
static
FORCE_INLINE
bool
tsdbSmaStatIsOK
(
SSmaStatItem
*
pStatItem
,
int8_t
*
state
)
{
static
FORCE_INLINE
bool
tsdbSmaStatIsOK
(
SSmaStatItem
*
pStatItem
,
int8_t
*
state
)
{
if
(
!
pStatItem
)
{
if
(
!
pStatItem
)
{
return
false
;
return
false
;
}
}
...
@@ -384,49 +384,20 @@ static int32_t tsdbCheckAndInitSmaEnv(STsdb *pTsdb, int8_t smaType) {
...
@@ -384,49 +384,20 @@ static int32_t tsdbCheckAndInitSmaEnv(STsdb *pTsdb, int8_t smaType) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
};
};
/**
static
STimeWindow
getActiveTimeWindowX
(
int64_t
ts
,
SInterval
*
pInterval
)
{
* @brief Update expired window according to msg from stream computing module.
STimeWindow
tw
=
{
0
};
*
tw
.
skey
=
100
;
* @param pTsdb
tw
.
ekey
=
1000
;
* @param smaType ETsdbSmaType
return
tw
;
* @param msg
}
* @return int32_t
*/
int32_t
tsdbUpdateExpiredWindow
(
STsdb
*
pTsdb
,
ETsdbSmaType
smaType
,
char
*
msg
)
{
if
(
!
msg
||
!
pTsdb
->
pMeta
)
{
terrno
=
TSDB_CODE_INVALID_PTR
;
return
TSDB_CODE_FAILED
;
}
// TODO: decode the msg from Stream Computing module => start
int64_t
indexUid
=
SMA_TEST_INDEX_UID
;
const
int32_t
SMA_TEST_EXPIRED_WINDOW_SIZE
=
10
;
TSKEY
expiredWindows
[
SMA_TEST_EXPIRED_WINDOW_SIZE
];
TSKEY
skey1
=
1646987196
*
1e3
;
for
(
int32_t
i
=
0
;
i
<
SMA_TEST_EXPIRED_WINDOW_SIZE
;
++
i
)
{
expiredWindows
[
i
]
=
skey1
+
i
;
}
// TODO: decode the msg <= end
if
(
tsdbCheckAndInitSmaEnv
(
pTsdb
,
smaType
)
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
TSDB_CODE_TDB_INIT_FAILED
;
return
TSDB_CODE_FAILED
;
}
SSmaEnv
*
pEnv
=
REPO_SMA_ENV
(
pTsdb
,
smaType
);
SSmaStat
*
pStat
=
SMA_ENV_STAT
(
pEnv
);
SHashObj
*
pItemsHash
=
SMA_ENV_STAT_ITEMS
(
pEnv
);
TASSERT
(
pEnv
!=
NULL
&&
pStat
!=
NULL
&&
pItemsHash
!=
NULL
);
tsdbRefSmaStat
(
pTsdb
,
pStat
);
static
int32_t
tsdbSetExpiredWindow
(
STsdb
*
pTsdb
,
SHashObj
*
pItemsHash
,
int64_t
indexUid
,
int64_t
winSKey
)
{
SSmaStatItem
*
pItem
=
taosHashGet
(
pItemsHash
,
&
indexUid
,
sizeof
(
indexUid
));
SSmaStatItem
*
pItem
=
taosHashGet
(
pItemsHash
,
&
indexUid
,
sizeof
(
indexUid
));
if
(
pItem
==
NULL
)
{
if
(
pItem
==
NULL
)
{
pItem
=
tsdbNewSmaStatItem
(
TSDB_SMA_STAT_EXPIRED
);
// TODO use the real state
pItem
=
tsdbNewSmaStatItem
(
TSDB_SMA_STAT_EXPIRED
);
// TODO use the real state
if
(
pItem
==
NULL
)
{
if
(
pItem
==
NULL
)
{
// Response to stream computing: OOM
// Response to stream computing: OOM
// For query, if the indexUid not found, the TSDB should tell query module to query raw TS data.
// For query, if the indexUid not found, the TSDB should tell query module to query raw TS data.
tsdbUnRefSmaStat
(
pTsdb
,
pStat
);
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
...
@@ -436,7 +407,6 @@ int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, ETsdbSmaType smaType, char *msg) {
...
@@ -436,7 +407,6 @@ int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, ETsdbSmaType smaType, char *msg) {
terrno
=
TSDB_CODE_TDB_NO_SMA_INDEX_IN_META
;
terrno
=
TSDB_CODE_TDB_NO_SMA_INDEX_IN_META
;
taosHashCleanup
(
pItem
->
expiredWindows
);
taosHashCleanup
(
pItem
->
expiredWindows
);
free
(
pItem
);
free
(
pItem
);
tsdbUnRefSmaStat
(
pTsdb
,
pStat
);
tsdbWarn
(
"vgId:%d update expired window failed for smaIndex %"
PRIi64
" since %s"
,
REPO_ID
(
pTsdb
),
indexUid
,
tsdbWarn
(
"vgId:%d update expired window failed for smaIndex %"
PRIi64
" since %s"
,
REPO_ID
(
pTsdb
),
indexUid
,
tstrerror
(
terrno
));
tstrerror
(
terrno
));
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
...
@@ -447,14 +417,12 @@ int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, ETsdbSmaType smaType, char *msg) {
...
@@ -447,14 +417,12 @@ int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, ETsdbSmaType smaType, char *msg) {
// If error occurs during put smaStatItem, free the resources of pItem
// If error occurs during put smaStatItem, free the resources of pItem
taosHashCleanup
(
pItem
->
expiredWindows
);
taosHashCleanup
(
pItem
->
expiredWindows
);
free
(
pItem
);
free
(
pItem
);
tsdbUnRefSmaStat
(
pTsdb
,
pStat
);
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
}
}
int8_t
state
=
TSDB_SMA_STAT_EXPIRED
;
int8_t
state
=
TSDB_SMA_STAT_EXPIRED
;
for
(
int32_t
i
=
0
;
i
<
SMA_TEST_EXPIRED_WINDOW_SIZE
;
++
i
)
{
if
(
taosHashPut
(
pItem
->
expiredWindows
,
&
winSKey
,
sizeof
(
TSKEY
),
&
state
,
sizeof
(
state
))
!=
0
)
{
if
(
taosHashPut
(
pItem
->
expiredWindows
,
expiredWindows
+
i
,
sizeof
(
TSKEY
),
&
state
,
sizeof
(
state
))
!=
0
)
{
// If error occurs during taosHashPut expired windows, remove the smaIndex from pTsdb->pSmaStat, thus TSDB would
// If error occurs during taosHashPut expired windows, remove the smaIndex from pTsdb->pSmaStat, thus TSDB would
// tell query module to query raw TS data.
// tell query module to query raw TS data.
// N.B.
// N.B.
...
@@ -464,17 +432,135 @@ int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, ETsdbSmaType smaType, char *msg) {
...
@@ -464,17 +432,135 @@ int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, ETsdbSmaType smaType, char *msg) {
taosHashCleanup
(
pItem
->
expiredWindows
);
taosHashCleanup
(
pItem
->
expiredWindows
);
tfree
(
pItem
->
pSma
);
tfree
(
pItem
->
pSma
);
taosHashRemove
(
pItemsHash
,
&
indexUid
,
sizeof
(
indexUid
));
taosHashRemove
(
pItemsHash
,
&
indexUid
,
sizeof
(
indexUid
));
tsdbUnRefSmaStat
(
pTsdb
,
pStat
);
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
tsdbDebug
(
"vgId:%d smaIndex %"
PRIi64
" tsKey %"
PRIi64
" is put to hash"
,
REPO_ID
(
pTsdb
),
indexUid
,
tsdbDebug
(
"vgId:%d smaIndex %"
PRIi64
" tsKey %"
PRIi64
" is put to hash"
,
REPO_ID
(
pTsdb
),
indexUid
,
winSKey
);
expiredWindows
[
i
]);
}
/**
* @brief Update expired window according to msg from stream computing module.
*
* @param pTsdb
* @param msg SSubmitReq
* @return int32_t
*/
int32_t
tsdbUpdateExpiredWindowImpl
(
STsdb
*
pTsdb
,
const
char
*
msg
)
{
const
SSubmitReq
*
pMsg
=
(
const
SSubmitReq
*
)
msg
;
if
(
pMsg
->
length
<=
sizeof
(
SSubmitReq
))
{
terrno
=
TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP
;
return
TSDB_CODE_FAILED
;
}
if
(
!
pTsdb
->
pMeta
)
{
terrno
=
TSDB_CODE_INVALID_PTR
;
return
TSDB_CODE_FAILED
;
}
// TODO: decode the msg from Stream Computing module => start
#ifdef TSDB_SMA_TESTx
int64_t
indexUid
=
SMA_TEST_INDEX_UID
;
const
int32_t
SMA_TEST_EXPIRED_WINDOW_SIZE
=
10
;
TSKEY
expiredWindows
[
SMA_TEST_EXPIRED_WINDOW_SIZE
];
TSKEY
skey1
=
1646987196
*
1e3
;
for
(
int32_t
i
=
0
;
i
<
SMA_TEST_EXPIRED_WINDOW_SIZE
;
++
i
)
{
expiredWindows
[
i
]
=
skey1
+
i
;
}
#else
#endif
// TODO: decode the msg <= end
if
(
tsdbCheckAndInitSmaEnv
(
pTsdb
,
TSDB_SMA_TYPE_TIME_RANGE
)
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
TSDB_CODE_TDB_INIT_FAILED
;
return
TSDB_CODE_FAILED
;
}
#ifndef TSDB_SMA_TEST
TSKEY
expiredWindows
[
SMA_TEST_EXPIRED_WINDOW_SIZE
];
#endif
// Firstly, assume that tSma can only be created on super table/normal table.
// getActiveTimeWindow
SSmaEnv
*
pEnv
=
REPO_SMA_ENV
(
pTsdb
,
TSDB_SMA_TYPE_TIME_RANGE
);
SSmaStat
*
pStat
=
SMA_ENV_STAT
(
pEnv
);
SHashObj
*
pItemsHash
=
SMA_ENV_STAT_ITEMS
(
pEnv
);
TASSERT
(
pEnv
!=
NULL
&&
pStat
!=
NULL
&&
pItemsHash
!=
NULL
);
SSubmitMsgIter
msgIter
=
{
0
};
SSubmitBlk
*
pBlock
=
NULL
;
SInterval
interval
=
{
0
};
if
(
tInitSubmitMsgIter
(
pMsg
,
&
msgIter
)
!=
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_FAILED
;
}
// basic procedure
// TODO: optimization
tsdbRefSmaStat
(
pTsdb
,
pStat
);
while
(
true
)
{
tGetSubmitMsgNext
(
&
msgIter
,
&
pBlock
);
if
(
pBlock
==
NULL
)
break
;
int64_t
suid
=
htobe64
(
pBlock
->
uid
);
STSmaWrapper
*
pSW
=
NULL
;
STSma
*
pTSma
=
NULL
;
while
(
true
)
{
SSubmitBlkIter
blkIter
=
{
0
};
if
(
tInitSubmitBlkIter
(
pBlock
,
&
blkIter
)
!=
TSDB_CODE_SUCCESS
)
{
tdFreeTSmaWrapper
(
pSW
);
break
;
}
STSRow
*
row
=
tGetSubmitBlkNext
(
&
blkIter
);
if
(
row
==
NULL
)
{
tdFreeTSmaWrapper
(
pSW
);
break
;
}
if
(
pSW
==
NULL
)
{
if
((
pSW
=
metaGetSmaInfoByTable
(
REPO_META
(
pTsdb
),
suid
))
==
NULL
)
{
break
;
}
if
((
pSW
->
number
)
<=
0
||
(
pSW
->
tSma
==
NULL
))
{
tdFreeTSmaWrapper
(
pSW
);
break
;
}
pTSma
=
pSW
->
tSma
;
}
interval
.
interval
=
pTSma
->
interval
;
interval
.
intervalUnit
=
pTSma
->
intervalUnit
;
interval
.
offset
=
pTSma
->
offset
;
interval
.
precision
=
REPO_CFG
(
pTsdb
)
->
precision
;
interval
.
sliding
=
pTSma
->
sliding
;
interval
.
slidingUnit
=
pTSma
->
slidingUnit
;
STimeWindow
tw
=
getActiveTimeWindowX
(
TD_ROW_KEY
(
row
),
&
interval
);
tsdbSetExpiredWindow
(
pTsdb
,
pItemsHash
,
pTSma
->
indexUid
,
TD_ROW_KEY
(
row
));
}
}
}
tsdbUnRefSmaStat
(
pTsdb
,
pStat
);
tsdbUnRefSmaStat
(
pTsdb
,
pStat
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
/**
* @brief When sma data received from stream computing, make the relative expired window valid.
*
* @param pTsdb
* @param pStat
* @param indexUid
* @param skey
* @return int32_t
*/
static
int32_t
tsdbResetExpiredWindow
(
STsdb
*
pTsdb
,
SSmaStat
*
pStat
,
int64_t
indexUid
,
TSKEY
skey
)
{
static
int32_t
tsdbResetExpiredWindow
(
STsdb
*
pTsdb
,
SSmaStat
*
pStat
,
int64_t
indexUid
,
TSKEY
skey
)
{
SSmaStatItem
*
pItem
=
NULL
;
SSmaStatItem
*
pItem
=
NULL
;
...
@@ -582,7 +668,7 @@ static int32_t tsdbInsertTSmaBlocks(STSmaWriteH *pSmaH, void *smaKey, uint32_t k
...
@@ -582,7 +668,7 @@ static int32_t tsdbInsertTSmaBlocks(STSmaWriteH *pSmaH, void *smaKey, uint32_t k
#ifdef _TEST_SMA_PRINT_DEBUG_LOG_
#ifdef _TEST_SMA_PRINT_DEBUG_LOG_
uint32_t
valueSize
=
0
;
uint32_t
valueSize
=
0
;
void
*
data
=
tsdbGetSmaDataByKey
(
pDBFile
,
smaKey
,
keyLen
,
&
valueSize
);
void
*
data
=
tsdbGetSmaDataByKey
(
pDBFile
,
smaKey
,
keyLen
,
&
valueSize
);
ASSERT
(
data
!=
NULL
);
ASSERT
(
data
!=
NULL
);
for
(
uint32_t
v
=
0
;
v
<
valueSize
;
v
+=
8
)
{
for
(
uint32_t
v
=
0
;
v
<
valueSize
;
v
+=
8
)
{
tsdbWarn
(
"vgId:%d insert sma data val[%d] %"
PRIi64
,
REPO_ID
(
pSmaH
->
pTsdb
),
v
,
*
(
int64_t
*
)
POINTER_SHIFT
(
data
,
v
));
tsdbWarn
(
"vgId:%d insert sma data val[%d] %"
PRIi64
,
REPO_ID
(
pSmaH
->
pTsdb
),
v
,
*
(
int64_t
*
)
POINTER_SHIFT
(
data
,
v
));
...
@@ -699,7 +785,7 @@ static int32_t tsdbInsertTSmaDataSection(STSmaWriteH *pSmaH, STSmaDataWrapper *p
...
@@ -699,7 +785,7 @@ static int32_t tsdbInsertTSmaDataSection(STSmaWriteH *pSmaH, STSmaDataWrapper *p
assert
(
pTbData
->
dataLen
>
0
);
assert
(
pTbData
->
dataLen
>
0
);
STSmaColData
*
pColData
=
(
STSmaColData
*
)
POINTER_SHIFT
(
pTbData
->
data
,
tbLen
);
STSmaColData
*
pColData
=
(
STSmaColData
*
)
POINTER_SHIFT
(
pTbData
->
data
,
tbLen
);
char
smaKey
[
SMA_KEY_LEN
]
=
{
0
};
char
smaKey
[
SMA_KEY_LEN
]
=
{
0
};
void
*
pSmaKey
=
&
smaKey
;
void
*
pSmaKey
=
&
smaKey
;
#if 0
#if 0
printf("tsdbInsertTSmaDataSection: index %" PRIi64 ", skey %" PRIi64 " table[%" PRIi64 "]col[%" PRIu16 "]\n",
printf("tsdbInsertTSmaDataSection: index %" PRIi64 ", skey %" PRIi64 " table[%" PRIi64 "]col[%" PRIu16 "]\n",
pData->indexUid, pData->skey, pTbData->tableUid, pColData->colId);
pData->indexUid, pData->skey, pTbData->tableUid, pColData->colId);
...
@@ -773,12 +859,11 @@ static int32_t tsdbGetTSmaDays(STsdb *pTsdb, int64_t interval, int32_t storageLe
...
@@ -773,12 +859,11 @@ static int32_t tsdbGetTSmaDays(STsdb *pTsdb, int64_t interval, int32_t storageLe
* @return int32_t
* @return int32_t
*/
*/
static
int32_t
tsdbInsertTSmaDataImpl
(
STsdb
*
pTsdb
,
char
*
msg
)
{
static
int32_t
tsdbInsertTSmaDataImpl
(
STsdb
*
pTsdb
,
char
*
msg
)
{
STsdbCfg
*
pCfg
=
REPO_CFG
(
pTsdb
);
STsdbCfg
*
pCfg
=
REPO_CFG
(
pTsdb
);
STSmaDataWrapper
*
pData
=
(
STSmaDataWrapper
*
)
msg
;
STSmaDataWrapper
*
pData
=
(
STSmaDataWrapper
*
)
msg
;
SSmaEnv
*
pEnv
=
atomic_load_ptr
(
&
pTsdb
->
pTSmaEnv
);
SSmaEnv
*
pEnv
=
atomic_load_ptr
(
&
pTsdb
->
pTSmaEnv
);
int64_t
indexUid
=
SMA_TEST_INDEX_UID
;
int64_t
indexUid
=
SMA_TEST_INDEX_UID
;
if
(
pEnv
==
NULL
)
{
if
(
pEnv
==
NULL
)
{
terrno
=
TSDB_CODE_INVALID_PTR
;
terrno
=
TSDB_CODE_INVALID_PTR
;
tsdbWarn
(
"vgId:%d insert tSma data failed since pTSmaEnv is NULL"
,
REPO_ID
(
pTsdb
));
tsdbWarn
(
"vgId:%d insert tSma data failed since pTSmaEnv is NULL"
,
REPO_ID
(
pTsdb
));
...
@@ -903,7 +988,6 @@ static int32_t tsdbDropTSmaDataImpl(STsdb *pTsdb, int64_t indexUid) {
...
@@ -903,7 +988,6 @@ static int32_t tsdbDropTSmaDataImpl(STsdb *pTsdb, int64_t indexUid) {
}
}
// clear sma data files
// clear sma data files
// TODO:
// TODO:
}
}
static
int32_t
tsdbSetRSmaDataFile
(
STSmaWriteH
*
pSmaH
,
STSmaDataWrapper
*
pData
,
int32_t
fid
)
{
static
int32_t
tsdbSetRSmaDataFile
(
STSmaWriteH
*
pSmaH
,
STSmaDataWrapper
*
pData
,
int32_t
fid
)
{
...
@@ -917,9 +1001,9 @@ static int32_t tsdbSetRSmaDataFile(STSmaWriteH *pSmaH, STSmaDataWrapper *pData,
...
@@ -917,9 +1001,9 @@ static int32_t tsdbSetRSmaDataFile(STSmaWriteH *pSmaH, STSmaDataWrapper *pData,
}
}
static
int32_t
tsdbInsertRSmaDataImpl
(
STsdb
*
pTsdb
,
char
*
msg
)
{
static
int32_t
tsdbInsertRSmaDataImpl
(
STsdb
*
pTsdb
,
char
*
msg
)
{
STsdbCfg
*
pCfg
=
REPO_CFG
(
pTsdb
);
STsdbCfg
*
pCfg
=
REPO_CFG
(
pTsdb
);
STSmaDataWrapper
*
pData
=
(
STSmaDataWrapper
*
)
msg
;
STSmaDataWrapper
*
pData
=
(
STSmaDataWrapper
*
)
msg
;
SSmaEnv
*
pEnv
=
atomic_load_ptr
(
&
pTsdb
->
pRSmaEnv
);
SSmaEnv
*
pEnv
=
atomic_load_ptr
(
&
pTsdb
->
pRSmaEnv
);
if
(
pEnv
==
NULL
)
{
if
(
pEnv
==
NULL
)
{
terrno
=
TSDB_CODE_INVALID_PTR
;
terrno
=
TSDB_CODE_INVALID_PTR
;
...
@@ -1137,7 +1221,7 @@ static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_
...
@@ -1137,7 +1221,7 @@ static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_
tReadH
.
dFile
.
path
,
*
(
tb_uid_t
*
)
smaKey
,
*
(
uint16_t
*
)
POINTER_SHIFT
(
smaKey
,
8
),
tReadH
.
dFile
.
path
,
*
(
tb_uid_t
*
)
smaKey
,
*
(
uint16_t
*
)
POINTER_SHIFT
(
smaKey
,
8
),
*
(
int64_t
*
)
POINTER_SHIFT
(
smaKey
,
10
),
SMA_KEY_LEN
);
*
(
int64_t
*
)
POINTER_SHIFT
(
smaKey
,
10
),
SMA_KEY_LEN
);
void
*
result
=
NULL
;
void
*
result
=
NULL
;
uint32_t
valueSize
=
0
;
uint32_t
valueSize
=
0
;
if
((
result
=
tsdbGetSmaDataByKey
(
&
tReadH
.
dFile
,
smaKey
,
SMA_KEY_LEN
,
&
valueSize
))
==
NULL
)
{
if
((
result
=
tsdbGetSmaDataByKey
(
&
tReadH
.
dFile
,
smaKey
,
SMA_KEY_LEN
,
&
valueSize
))
==
NULL
)
{
tsdbWarn
(
"vgId:%d get sma data failed from smaIndex %"
PRIi64
", smaKey %"
PRIx64
"-%"
PRIu16
"-%"
PRIx64
tsdbWarn
(
"vgId:%d get sma data failed from smaIndex %"
PRIi64
", smaKey %"
PRIx64
"-%"
PRIu16
"-%"
PRIx64
...
@@ -1219,15 +1303,8 @@ int32_t tsdbRemoveTSmaData(STsdb *pTsdb, void *smaIndex, STimeWindow *pWin) {
...
@@ -1219,15 +1303,8 @@ int32_t tsdbRemoveTSmaData(STsdb *pTsdb, void *smaIndex, STimeWindow *pWin) {
}
}
#endif
#endif
/**
* @brief Insert/Update tSma(Time-range-wise SMA) data from stream computing engine
// TODO: Who is responsible for resource allocate and release?
*
* @param pTsdb
* @param param
* @param msg
* @return int32_t
* TODO: Who is responsible for resource allocate and release?
*/
int32_t
tsdbInsertTSmaData
(
STsdb
*
pTsdb
,
char
*
msg
)
{
int32_t
tsdbInsertTSmaData
(
STsdb
*
pTsdb
,
char
*
msg
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
((
code
=
tsdbInsertTSmaDataImpl
(
pTsdb
,
msg
))
<
0
)
{
if
((
code
=
tsdbInsertTSmaDataImpl
(
pTsdb
,
msg
))
<
0
)
{
...
@@ -1236,21 +1313,14 @@ int32_t tsdbInsertTSmaData(STsdb *pTsdb, char *msg) {
...
@@ -1236,21 +1313,14 @@ int32_t tsdbInsertTSmaData(STsdb *pTsdb, char *msg) {
return
code
;
return
code
;
}
}
int32_t
tsdbUpdateSmaWindow
(
STsdb
*
pTsdb
,
int8_t
smaType
,
char
*
msg
)
{
int32_t
tsdbUpdateSmaWindow
(
STsdb
*
pTsdb
,
const
char
*
msg
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
((
code
=
tsdbUpdateExpiredWindow
(
pTsdb
,
smaType
,
msg
))
<
0
)
{
if
((
code
=
tsdbUpdateExpiredWindow
Impl
(
pTsdb
,
msg
))
<
0
)
{
tsdbWarn
(
"vgId:%d update expired sma window failed since %s"
,
REPO_ID
(
pTsdb
),
tstrerror
(
terrno
));
tsdbWarn
(
"vgId:%d update expired sma window failed since %s"
,
REPO_ID
(
pTsdb
),
tstrerror
(
terrno
));
}
}
return
code
;
return
code
;
}
}
/**
* @brief Insert Time-range-wise Rollup Sma(RSma) data
*
* @param pTsdb
* @param msg
* @return int32_t
*/
int32_t
tsdbInsertRSmaData
(
STsdb
*
pTsdb
,
char
*
msg
)
{
int32_t
tsdbInsertRSmaData
(
STsdb
*
pTsdb
,
char
*
msg
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
((
code
=
tsdbInsertRSmaDataImpl
(
pTsdb
,
msg
))
<
0
)
{
if
((
code
=
tsdbInsertRSmaDataImpl
(
pTsdb
,
msg
))
<
0
)
{
...
@@ -1259,20 +1329,7 @@ int32_t tsdbInsertRSmaData(STsdb *pTsdb, char *msg) {
...
@@ -1259,20 +1329,7 @@ int32_t tsdbInsertRSmaData(STsdb *pTsdb, char *msg) {
return
code
;
return
code
;
}
}
/**
* @brief Get tSma data
*
* @param pTsdb
* @param pData
* @param indexUid
* @param interval
* @param intervalUnit
* @param tableUid
* @param colId
* @param querySKey
* @param nMaxResult
* @return int32_t
*/
int32_t
tsdbGetTSmaData
(
STsdb
*
pTsdb
,
STSmaDataWrapper
*
pData
,
int64_t
indexUid
,
int64_t
interval
,
int8_t
intervalUnit
,
int32_t
tsdbGetTSmaData
(
STsdb
*
pTsdb
,
STSmaDataWrapper
*
pData
,
int64_t
indexUid
,
int64_t
interval
,
int8_t
intervalUnit
,
tb_uid_t
tableUid
,
col_id_t
colId
,
TSKEY
querySKey
,
int32_t
nMaxResult
)
{
tb_uid_t
tableUid
,
col_id_t
colId
,
TSKEY
querySKey
,
int32_t
nMaxResult
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
...
@@ -1283,13 +1340,7 @@ int32_t tsdbGetTSmaData(STsdb *pTsdb, STSmaDataWrapper *pData, int64_t indexUid,
...
@@ -1283,13 +1340,7 @@ int32_t tsdbGetTSmaData(STsdb *pTsdb, STSmaDataWrapper *pData, int64_t indexUid,
return
code
;
return
code
;
}
}
/**
* @brief Drop tSma Data and caches
*
* @param pTsdb
* @param msg
* @return int32_t
*/
int32_t
tsdbDropTSmaData
(
STsdb
*
pTsdb
,
int64_t
indexUid
)
{
int32_t
tsdbDropTSmaData
(
STsdb
*
pTsdb
,
int64_t
indexUid
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
((
code
=
tsdbDropTSmaDataImpl
(
pTsdb
,
indexUid
))
<
0
)
{
if
((
code
=
tsdbDropTSmaDataImpl
(
pTsdb
,
indexUid
))
<
0
)
{
...
...
source/dnode/vnode/src/tsdb/tsdbWrite.c
浏览文件 @
bdbf365e
...
@@ -33,47 +33,3 @@ int tsdbInsertData(STsdb *pTsdb, SSubmitReq *pMsg, SSubmitRsp *pRsp) {
...
@@ -33,47 +33,3 @@ int tsdbInsertData(STsdb *pTsdb, SSubmitReq *pMsg, SSubmitRsp *pRsp) {
}
}
return
tsdbMemTableInsert
(
pTsdb
,
pTsdb
->
mem
,
pMsg
,
NULL
);
return
tsdbMemTableInsert
(
pTsdb
,
pTsdb
->
mem
,
pMsg
,
NULL
);
}
}
#if 0
/**
* @brief Insert/Update tSma(Time-range-wise SMA) data from stream computing engine
*
* @param pTsdb
* @param param
* @param msg
* @return int32_t
* TODO: Who is responsible for resource allocate and release?
*/
int32_t tsdbInsertTSmaData(STsdb *pTsdb, char *msg) {
int32_t code = TSDB_CODE_SUCCESS;
if ((code = tsdbInsertTSmaDataImpl(pTsdb, msg)) < 0) {
tsdbWarn("vgId:%d insert tSma data failed since %s", REPO_ID(pTsdb), tstrerror(terrno));
}
return code;
}
int32_t tsdbUpdateSmaWindow(STsdb *pTsdb, int8_t smaType, char *msg) {
int32_t code = TSDB_CODE_SUCCESS;
if ((code = tsdbUpdateExpiredWindow(pTsdb, smaType, msg)) < 0) {
tsdbWarn("vgId:%d update expired sma window failed since %s", REPO_ID(pTsdb), tstrerror(terrno));
}
return code;
}
/**
* @brief Insert Time-range-wise Rollup Sma(RSma) data
*
* @param pTsdb
* @param param
* @param msg
* @return int32_t
*/
int32_t tsdbInsertRSmaData(STsdb *pTsdb, char *msg) {
int32_t code = TSDB_CODE_SUCCESS;
if ((code = tsdbInsertRSmaDataImpl(pTsdb, msg)) < 0) {
tsdbWarn("vgId:%d insert rSma data failed since %s", REPO_ID(pTsdb), tstrerror(terrno));
}
return code;
}
#endif
\ No newline at end of file
source/dnode/vnode/test/tsdbSmaTest.cpp
浏览文件 @
bdbf365e
...
@@ -98,7 +98,7 @@ TEST(testCase, tSma_Meta_Encode_Decode_Test) {
...
@@ -98,7 +98,7 @@ TEST(testCase, tSma_Meta_Encode_Decode_Test) {
tSma
.
slidingUnit
=
TIME_UNIT_HOUR
;
tSma
.
slidingUnit
=
TIME_UNIT_HOUR
;
tSma
.
sliding
=
0
;
tSma
.
sliding
=
0
;
tstrncpy
(
tSma
.
indexName
,
"sma_index_test"
,
TSDB_INDEX_NAME_LEN
);
tstrncpy
(
tSma
.
indexName
,
"sma_index_test"
,
TSDB_INDEX_NAME_LEN
);
t
strncpy
(
tSma
.
timezone
,
"Asia/Shanghai"
,
TD_TIMEZONE_LEN
)
;
t
Sma
.
timezoneInt
=
8
;
tSma
.
indexUid
=
2345678910
;
tSma
.
indexUid
=
2345678910
;
tSma
.
tableUid
=
1234567890
;
tSma
.
tableUid
=
1234567890
;
...
@@ -128,7 +128,7 @@ TEST(testCase, tSma_Meta_Encode_Decode_Test) {
...
@@ -128,7 +128,7 @@ TEST(testCase, tSma_Meta_Encode_Decode_Test) {
ASSERT_EQ
(
pSma
->
intervalUnit
,
qSma
->
intervalUnit
);
ASSERT_EQ
(
pSma
->
intervalUnit
,
qSma
->
intervalUnit
);
ASSERT_EQ
(
pSma
->
slidingUnit
,
qSma
->
slidingUnit
);
ASSERT_EQ
(
pSma
->
slidingUnit
,
qSma
->
slidingUnit
);
ASSERT_STRCASEEQ
(
pSma
->
indexName
,
qSma
->
indexName
);
ASSERT_STRCASEEQ
(
pSma
->
indexName
,
qSma
->
indexName
);
ASSERT_
STRCASEEQ
(
pSma
->
timezone
,
qSma
->
timezone
);
ASSERT_
EQ
(
pSma
->
timezoneInt
,
qSma
->
timezoneInt
);
ASSERT_EQ
(
pSma
->
indexUid
,
qSma
->
indexUid
);
ASSERT_EQ
(
pSma
->
indexUid
,
qSma
->
indexUid
);
ASSERT_EQ
(
pSma
->
tableUid
,
qSma
->
tableUid
);
ASSERT_EQ
(
pSma
->
tableUid
,
qSma
->
tableUid
);
ASSERT_EQ
(
pSma
->
interval
,
qSma
->
interval
);
ASSERT_EQ
(
pSma
->
interval
,
qSma
->
interval
);
...
@@ -150,7 +150,7 @@ TEST(testCase, tSma_Meta_Encode_Decode_Test) {
...
@@ -150,7 +150,7 @@ TEST(testCase, tSma_Meta_Encode_Decode_Test) {
TEST
(
testCase
,
tSma_metaDB_Put_Get_Del_Test
)
{
TEST
(
testCase
,
tSma_metaDB_Put_Get_Del_Test
)
{
const
char
*
smaIndexName1
=
"sma_index_test_1"
;
const
char
*
smaIndexName1
=
"sma_index_test_1"
;
const
char
*
smaIndexName2
=
"sma_index_test_2"
;
const
char
*
smaIndexName2
=
"sma_index_test_2"
;
const
char
*
timezone
=
"Asia/Shanghai"
;
int8_t
timezone
=
8
;
const
char
*
expr
=
"select count(a,b, top 20), from table interval 1d, sliding 1h;"
;
const
char
*
expr
=
"select count(a,b, top 20), from table interval 1d, sliding 1h;"
;
const
char
*
tagsFilter
=
"I'm tags filter"
;
const
char
*
tagsFilter
=
"I'm tags filter"
;
const
char
*
smaTestDir
=
"./smaTest"
;
const
char
*
smaTestDir
=
"./smaTest"
;
...
@@ -167,7 +167,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
...
@@ -167,7 +167,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
tSma
.
sliding
=
0
;
tSma
.
sliding
=
0
;
tSma
.
indexUid
=
indexUid1
;
tSma
.
indexUid
=
indexUid1
;
tstrncpy
(
tSma
.
indexName
,
smaIndexName1
,
TSDB_INDEX_NAME_LEN
);
tstrncpy
(
tSma
.
indexName
,
smaIndexName1
,
TSDB_INDEX_NAME_LEN
);
t
strncpy
(
tSma
.
timezone
,
timezone
,
TD_TIMEZONE_LEN
)
;
t
Sma
.
timezoneInt
=
8
;
tSma
.
tableUid
=
tbUid
;
tSma
.
tableUid
=
tbUid
;
tSma
.
exprLen
=
strlen
(
expr
);
tSma
.
exprLen
=
strlen
(
expr
);
...
@@ -207,7 +207,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
...
@@ -207,7 +207,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
qSmaCfg
=
metaGetSmaInfoByIndex
(
pMeta
,
indexUid1
);
qSmaCfg
=
metaGetSmaInfoByIndex
(
pMeta
,
indexUid1
);
assert
(
qSmaCfg
!=
NULL
);
assert
(
qSmaCfg
!=
NULL
);
printf
(
"name1 = %s
\n
"
,
qSmaCfg
->
indexName
);
printf
(
"name1 = %s
\n
"
,
qSmaCfg
->
indexName
);
printf
(
"timezone1 = %
s
\n
"
,
qSmaCfg
->
timezone
);
printf
(
"timezone1 = %
"
PRIi8
"
\n
"
,
qSmaCfg
->
timezoneInt
);
printf
(
"expr1 = %s
\n
"
,
qSmaCfg
->
expr
!=
NULL
?
qSmaCfg
->
expr
:
""
);
printf
(
"expr1 = %s
\n
"
,
qSmaCfg
->
expr
!=
NULL
?
qSmaCfg
->
expr
:
""
);
printf
(
"tagsFilter1 = %s
\n
"
,
qSmaCfg
->
tagsFilter
!=
NULL
?
qSmaCfg
->
tagsFilter
:
""
);
printf
(
"tagsFilter1 = %s
\n
"
,
qSmaCfg
->
tagsFilter
!=
NULL
?
qSmaCfg
->
tagsFilter
:
""
);
ASSERT_STRCASEEQ
(
qSmaCfg
->
indexName
,
smaIndexName1
);
ASSERT_STRCASEEQ
(
qSmaCfg
->
indexName
,
smaIndexName1
);
...
@@ -218,7 +218,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
...
@@ -218,7 +218,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
qSmaCfg
=
metaGetSmaInfoByIndex
(
pMeta
,
indexUid2
);
qSmaCfg
=
metaGetSmaInfoByIndex
(
pMeta
,
indexUid2
);
assert
(
qSmaCfg
!=
NULL
);
assert
(
qSmaCfg
!=
NULL
);
printf
(
"name2 = %s
\n
"
,
qSmaCfg
->
indexName
);
printf
(
"name2 = %s
\n
"
,
qSmaCfg
->
indexName
);
printf
(
"timezone2 = %
s
\n
"
,
qSmaCfg
->
timezone
);
printf
(
"timezone2 = %
"
PRIi8
"
\n
"
,
qSmaCfg
->
timezoneInt
);
printf
(
"expr2 = %s
\n
"
,
qSmaCfg
->
expr
!=
NULL
?
qSmaCfg
->
expr
:
""
);
printf
(
"expr2 = %s
\n
"
,
qSmaCfg
->
expr
!=
NULL
?
qSmaCfg
->
expr
:
""
);
printf
(
"tagsFilter2 = %s
\n
"
,
qSmaCfg
->
tagsFilter
!=
NULL
?
qSmaCfg
->
tagsFilter
:
""
);
printf
(
"tagsFilter2 = %s
\n
"
,
qSmaCfg
->
tagsFilter
!=
NULL
?
qSmaCfg
->
tagsFilter
:
""
);
ASSERT_STRCASEEQ
(
qSmaCfg
->
indexName
,
smaIndexName2
);
ASSERT_STRCASEEQ
(
qSmaCfg
->
indexName
,
smaIndexName2
);
...
@@ -246,13 +246,13 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
...
@@ -246,13 +246,13 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
assert
(
pSW
!=
NULL
);
assert
(
pSW
!=
NULL
);
ASSERT_EQ
(
pSW
->
number
,
nCntTSma
);
ASSERT_EQ
(
pSW
->
number
,
nCntTSma
);
ASSERT_STRCASEEQ
(
pSW
->
tSma
->
indexName
,
smaIndexName1
);
ASSERT_STRCASEEQ
(
pSW
->
tSma
->
indexName
,
smaIndexName1
);
ASSERT_
STRCASEEQ
(
pSW
->
tSma
->
timezone
,
timezone
);
ASSERT_
EQ
(
pSW
->
tSma
->
timezoneInt
,
timezone
);
ASSERT_STRCASEEQ
(
pSW
->
tSma
->
expr
,
expr
);
ASSERT_STRCASEEQ
(
pSW
->
tSma
->
expr
,
expr
);
ASSERT_STRCASEEQ
(
pSW
->
tSma
->
tagsFilter
,
tagsFilter
);
ASSERT_STRCASEEQ
(
pSW
->
tSma
->
tagsFilter
,
tagsFilter
);
ASSERT_EQ
(
pSW
->
tSma
->
indexUid
,
indexUid1
);
ASSERT_EQ
(
pSW
->
tSma
->
indexUid
,
indexUid1
);
ASSERT_EQ
(
pSW
->
tSma
->
tableUid
,
tbUid
);
ASSERT_EQ
(
pSW
->
tSma
->
tableUid
,
tbUid
);
ASSERT_STRCASEEQ
((
pSW
->
tSma
+
1
)
->
indexName
,
smaIndexName2
);
ASSERT_STRCASEEQ
((
pSW
->
tSma
+
1
)
->
indexName
,
smaIndexName2
);
ASSERT_
STRCASEEQ
((
pSW
->
tSma
+
1
)
->
timezone
,
timezone
);
ASSERT_
EQ
((
pSW
->
tSma
+
1
)
->
timezoneInt
,
timezone
);
ASSERT_STRCASEEQ
((
pSW
->
tSma
+
1
)
->
expr
,
expr
);
ASSERT_STRCASEEQ
((
pSW
->
tSma
+
1
)
->
expr
,
expr
);
ASSERT_STRCASEEQ
((
pSW
->
tSma
+
1
)
->
tagsFilter
,
tagsFilter
);
ASSERT_STRCASEEQ
((
pSW
->
tSma
+
1
)
->
tagsFilter
,
tagsFilter
);
ASSERT_EQ
((
pSW
->
tSma
+
1
)
->
indexUid
,
indexUid2
);
ASSERT_EQ
((
pSW
->
tSma
+
1
)
->
indexUid
,
indexUid2
);
...
@@ -284,7 +284,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
...
@@ -284,7 +284,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
TEST
(
testCase
,
tSma_Data_Insert_Query_Test
)
{
TEST
(
testCase
,
tSma_Data_Insert_Query_Test
)
{
// step 1: prepare meta
// step 1: prepare meta
const
char
*
smaIndexName1
=
"sma_index_test_1"
;
const
char
*
smaIndexName1
=
"sma_index_test_1"
;
const
char
*
timezone
=
"Asia/Shanghai"
;
const
int8_t
timezone
=
8
;
const
char
*
expr
=
"select count(a,b, top 20), from table interval 1d, sliding 1h;"
;
const
char
*
expr
=
"select count(a,b, top 20), from table interval 1d, sliding 1h;"
;
const
char
*
tagsFilter
=
"where tags.location='Beijing' and tags.district='ChaoYang'"
;
const
char
*
tagsFilter
=
"where tags.location='Beijing' and tags.district='ChaoYang'"
;
const
char
*
smaTestDir
=
"./smaTest"
;
const
char
*
smaTestDir
=
"./smaTest"
;
...
@@ -305,7 +305,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
...
@@ -305,7 +305,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
tSma
.
sliding
=
0
;
tSma
.
sliding
=
0
;
tSma
.
indexUid
=
indexUid1
;
tSma
.
indexUid
=
indexUid1
;
tstrncpy
(
tSma
.
indexName
,
smaIndexName1
,
TSDB_INDEX_NAME_LEN
);
tstrncpy
(
tSma
.
indexName
,
smaIndexName1
,
TSDB_INDEX_NAME_LEN
);
t
strncpy
(
tSma
.
timezone
,
timezone
,
TD_TIMEZONE_LEN
)
;
t
Sma
.
timezoneInt
=
timezone
;
tSma
.
tableUid
=
tbUid
;
tSma
.
tableUid
=
tbUid
;
tSma
.
exprLen
=
strlen
(
expr
);
tSma
.
exprLen
=
strlen
(
expr
);
...
@@ -369,7 +369,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
...
@@ -369,7 +369,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) {
char
*
msg
=
(
char
*
)
calloc
(
1
,
100
);
char
*
msg
=
(
char
*
)
calloc
(
1
,
100
);
ASSERT_NE
(
msg
,
nullptr
);
ASSERT_NE
(
msg
,
nullptr
);
ASSERT_EQ
(
tsdbUpdateSmaWindow
(
pTsdb
,
TSDB_SMA_TYPE_TIME_RANGE
,
msg
),
0
);
ASSERT_EQ
(
tsdbUpdateSmaWindow
(
pTsdb
,
msg
),
0
);
// init
// init
int32_t
allocCnt
=
0
;
int32_t
allocCnt
=
0
;
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
bdbf365e
...
@@ -243,6 +243,8 @@ typedef struct STaskAttr {
...
@@ -243,6 +243,8 @@ typedef struct STaskAttr {
struct
SOperatorInfo
;
struct
SOperatorInfo
;
typedef
void
(
*
__optr_encode_fn_t
)(
struct
SOperatorInfo
*
pOperator
,
char
**
result
,
int32_t
*
length
);
typedef
bool
(
*
__optr_decode_fn_t
)(
struct
SOperatorInfo
*
pOperator
,
char
*
result
,
int32_t
length
);
typedef
int32_t
(
*
__optr_open_fn_t
)(
struct
SOperatorInfo
*
param
);
typedef
int32_t
(
*
__optr_open_fn_t
)(
struct
SOperatorInfo
*
param
);
typedef
SSDataBlock
*
(
*
__optr_fn_t
)(
struct
SOperatorInfo
*
param
,
bool
*
newgroup
);
typedef
SSDataBlock
*
(
*
__optr_fn_t
)(
struct
SOperatorInfo
*
param
,
bool
*
newgroup
);
typedef
void
(
*
__optr_close_fn_t
)(
void
*
param
,
int32_t
num
);
typedef
void
(
*
__optr_close_fn_t
)(
void
*
param
,
int32_t
num
);
...
@@ -332,6 +334,8 @@ typedef struct SOperatorInfo {
...
@@ -332,6 +334,8 @@ typedef struct SOperatorInfo {
__optr_fn_t
cleanupFn
;
__optr_fn_t
cleanupFn
;
__optr_close_fn_t
closeFn
;
__optr_close_fn_t
closeFn
;
__optr_open_fn_t
_openFn
;
// DO NOT invoke this function directly
__optr_open_fn_t
_openFn
;
// DO NOT invoke this function directly
__optr_encode_fn_t
encodeResultRow
;
//
__optr_decode_fn_t
decodeResultRow
;
}
SOperatorInfo
;
}
SOperatorInfo
;
typedef
struct
{
typedef
struct
{
...
@@ -661,6 +665,9 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
...
@@ -661,6 +665,9 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
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
,
SOperatorInfo
*
createFillOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfCols
,
SInterval
*
pInterval
,
SSDataBlock
*
pResBlock
,
int32_t
fillType
,
char
*
fillVal
,
bool
multigroupResult
,
SExecTaskInfo
*
pTaskInfo
);
int32_t
fillType
,
char
*
fillVal
,
bool
multigroupResult
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createDistinctOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createTableBlockInfoScanOperator
(
void
*
pTsdbReadHandle
,
STaskRuntimeEnv
*
pRuntimeEnv
);
SOperatorInfo
*
createTableSeqScanOperatorInfo
(
void
*
pTsdbReadHandle
,
STaskRuntimeEnv
*
pRuntimeEnv
);
SOperatorInfo
*
createTableSeqScanOperatorInfo
(
void
*
pTsdbReadHandle
,
STaskRuntimeEnv
*
pRuntimeEnv
);
SOperatorInfo
*
createAllTimeIntervalOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SOperatorInfo
*
createAllTimeIntervalOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
...
@@ -671,9 +678,7 @@ SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntim
...
@@ -671,9 +678,7 @@ SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntim
SOperatorInfo
*
createAllMultiTableTimeIntervalOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SOperatorInfo
*
createAllMultiTableTimeIntervalOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createTagScanOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createTagScanOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createDistinctOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createTableBlockInfoScanOperator
(
void
*
pTsdbReadHandle
,
STaskRuntimeEnv
*
pRuntimeEnv
);
SOperatorInfo
*
createMultiwaySortOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
SOperatorInfo
*
createMultiwaySortOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
int32_t
numOfRows
,
void
*
merger
);
int32_t
numOfRows
,
void
*
merger
);
SOperatorInfo
*
createGlobalAggregateOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SOperatorInfo
*
createGlobalAggregateOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
bdbf365e
...
@@ -674,12 +674,7 @@ static void getInitialStartTimeWindow(SInterval* pInterval, int32_t precision, T
...
@@ -674,12 +674,7 @@ static void getInitialStartTimeWindow(SInterval* pInterval, int32_t precision, T
int64_t
key
=
w
->
skey
;
int64_t
key
=
w
->
skey
;
while
(
key
<
ts
)
{
// moving towards end
while
(
key
<
ts
)
{
// moving towards end
if
(
pInterval
->
intervalUnit
==
'n'
||
pInterval
->
intervalUnit
==
'y'
)
{
key
=
taosTimeAdd
(
key
,
pInterval
->
sliding
,
pInterval
->
slidingUnit
,
precision
);
key
=
taosTimeAdd
(
key
,
pInterval
->
sliding
,
pInterval
->
slidingUnit
,
precision
);
}
else
{
key
+=
pInterval
->
sliding
;
}
if
(
key
>=
ts
)
{
if
(
key
>=
ts
)
{
break
;
break
;
}
}
...
@@ -695,12 +690,7 @@ static STimeWindow getActiveTimeWindow(SResultRowInfo * pResultRowInfo, int64_t
...
@@ -695,12 +690,7 @@ static STimeWindow getActiveTimeWindow(SResultRowInfo * pResultRowInfo, int64_t
if
(
pResultRowInfo
->
curPos
==
-
1
)
{
// the first window, from the previous stored value
if
(
pResultRowInfo
->
curPos
==
-
1
)
{
// the first window, from the previous stored value
getInitialStartTimeWindow
(
pInterval
,
precision
,
ts
,
&
w
,
win
->
ekey
,
true
);
getInitialStartTimeWindow
(
pInterval
,
precision
,
ts
,
&
w
,
win
->
ekey
,
true
);
if
(
pInterval
->
intervalUnit
==
'n'
||
pInterval
->
intervalUnit
==
'y'
)
{
w
.
ekey
=
taosTimeAdd
(
w
.
skey
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
precision
)
-
1
;
w
.
ekey
=
taosTimeAdd
(
w
.
skey
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
precision
)
-
1
;
}
else
{
w
.
ekey
=
w
.
skey
+
pInterval
->
interval
-
1
;
}
}
else
{
}
else
{
w
=
getResultRow
(
pResultRowInfo
,
pResultRowInfo
->
curPos
)
->
win
;
w
=
getResultRow
(
pResultRowInfo
,
pResultRowInfo
->
curPos
)
->
win
;
}
}
...
@@ -722,7 +712,7 @@ static STimeWindow getActiveTimeWindow(SResultRowInfo * pResultRowInfo, int64_t
...
@@ -722,7 +712,7 @@ static STimeWindow getActiveTimeWindow(SResultRowInfo * pResultRowInfo, int64_t
}
}
w
.
skey
=
st
;
w
.
skey
=
st
;
w
.
ekey
=
w
.
skey
+
pInterval
->
interval
-
1
;
w
.
ekey
=
taosTimeAdd
(
w
.
skey
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
precision
)
-
1
;
}
}
}
}
return
w
;
return
w
;
...
@@ -2208,7 +2198,7 @@ static SqlFunctionCtx* createSqlFunctionCtx_rv(SExprInfo* pExprInfo, int32_t num
...
@@ -2208,7 +2198,7 @@ static SqlFunctionCtx* createSqlFunctionCtx_rv(SExprInfo* pExprInfo, int32_t num
}
}
for
(
int32_t
i
=
1
;
i
<
numOfOutput
;
++
i
)
{
for
(
int32_t
i
=
1
;
i
<
numOfOutput
;
++
i
)
{
(
*
rowCellInfoOffset
)[
i
]
=
(
int32_t
)((
*
rowCellInfoOffset
)[
i
-
1
]
+
sizeof
(
SResultRowEntryInfo
)
+
pFuncCtx
[
i
].
resDataInfo
.
interBufSize
);
(
*
rowCellInfoOffset
)[
i
]
=
(
int32_t
)((
*
rowCellInfoOffset
)[
i
-
1
]
+
sizeof
(
SResultRowEntryInfo
)
+
pFuncCtx
[
i
-
1
].
resDataInfo
.
interBufSize
);
}
}
setCtxTagColumnInfo
(
pFuncCtx
,
numOfOutput
);
setCtxTagColumnInfo
(
pFuncCtx
,
numOfOutput
);
...
@@ -2407,7 +2397,7 @@ static bool isCachedLastQuery(STaskAttr *pQueryAttr) {
...
@@ -2407,7 +2397,7 @@ static bool isCachedLastQuery(STaskAttr *pQueryAttr) {
/////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////
//todo refactor : return window
//todo refactor : return window
void
getAlignQueryTimeWindow
(
SInterval
*
pInterval
,
int32_t
precision
,
int64_t
key
,
int64_t
keyFirst
,
int64_t
keyLast
,
STimeWindow
*
win
)
{
void
getAlignQueryTimeWindow
(
SInterval
*
pInterval
,
int32_t
precision
,
int64_t
key
,
int64_t
keyFirst
,
int64_t
keyLast
,
STimeWindow
*
win
)
{
assert
(
key
>=
keyFirst
&&
key
<=
keyLast
&&
pInterval
->
sliding
<=
pInterval
->
interval
);
ASSERT
(
key
>=
keyFirst
&&
key
<=
keyLast
);
win
->
skey
=
taosTimeTruncate
(
key
,
pInterval
,
precision
);
win
->
skey
=
taosTimeTruncate
(
key
,
pInterval
,
precision
);
/*
/*
...
@@ -2417,10 +2407,8 @@ void getAlignQueryTimeWindow(SInterval* pInterval, int32_t precision, int64_t ke
...
@@ -2417,10 +2407,8 @@ void getAlignQueryTimeWindow(SInterval* pInterval, int32_t precision, int64_t ke
if
(
keyFirst
>
(
INT64_MAX
-
pInterval
->
interval
))
{
if
(
keyFirst
>
(
INT64_MAX
-
pInterval
->
interval
))
{
assert
(
keyLast
-
keyFirst
<
pInterval
->
interval
);
assert
(
keyLast
-
keyFirst
<
pInterval
->
interval
);
win
->
ekey
=
INT64_MAX
;
win
->
ekey
=
INT64_MAX
;
}
else
if
(
pInterval
->
intervalUnit
==
'n'
||
pInterval
->
intervalUnit
==
'y'
)
{
win
->
ekey
=
taosTimeAdd
(
win
->
skey
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
precision
)
-
1
;
}
else
{
}
else
{
win
->
ekey
=
win
->
skey
+
pInterval
->
interval
-
1
;
win
->
ekey
=
taosTimeAdd
(
win
->
skey
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
precision
)
-
1
;
}
}
}
}
...
@@ -6391,6 +6379,111 @@ static SSDataBlock* getAggregateResult(SOperatorInfo *pOperator, bool* newgroup)
...
@@ -6391,6 +6379,111 @@ static SSDataBlock* getAggregateResult(SOperatorInfo *pOperator, bool* newgroup)
return
(
blockDataGetNumOfRows
(
pInfo
->
pRes
)
!=
0
)
?
pInfo
->
pRes
:
NULL
;
return
(
blockDataGetNumOfRows
(
pInfo
->
pRes
)
!=
0
)
?
pInfo
->
pRes
:
NULL
;
}
}
static
void
aggEncodeResultRow
(
SOperatorInfo
*
pOperator
,
char
**
result
,
int32_t
*
length
)
{
SAggOperatorInfo
*
pAggInfo
=
pOperator
->
info
;
SAggSupporter
*
pSup
=
&
pAggInfo
->
aggSup
;
int32_t
size
=
taosHashGetSize
(
pSup
->
pResultRowHashTable
);
size_t
keyLen
=
POINTER_BYTES
;
// estimate the key length
int32_t
totalSize
=
sizeof
(
int32_t
)
+
size
*
(
sizeof
(
int32_t
)
+
keyLen
+
sizeof
(
int32_t
)
+
pSup
->
resultRowSize
);
*
result
=
calloc
(
1
,
totalSize
);
if
(
*
result
==
NULL
){
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
;
}
*
(
int32_t
*
)(
*
result
)
=
size
;
int32_t
offset
=
sizeof
(
int32_t
);
void
*
pIter
=
taosHashIterate
(
pSup
->
pResultRowHashTable
,
NULL
);
while
(
pIter
)
{
void
*
key
=
taosHashGetKey
(
pIter
,
&
keyLen
);
SResultRow
**
p1
=
(
SResultRow
**
)
pIter
;
// recalculate the result size
int32_t
realTotalSize
=
offset
+
sizeof
(
int32_t
)
+
keyLen
+
sizeof
(
int32_t
)
+
pSup
->
resultRowSize
;
if
(
realTotalSize
>
totalSize
){
char
*
tmp
=
realloc
(
*
result
,
realTotalSize
);
if
(
tmp
==
NULL
){
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
free
(
*
result
);
*
result
=
NULL
;
return
;
}
else
{
*
result
=
tmp
;
}
}
// save key
*
(
int32_t
*
)(
*
result
+
offset
)
=
keyLen
;
offset
+=
sizeof
(
int32_t
);
memcpy
(
*
result
+
offset
,
key
,
keyLen
);
offset
+=
keyLen
;
// save value
*
(
int32_t
*
)(
*
result
+
offset
)
=
pSup
->
resultRowSize
;
offset
+=
sizeof
(
int32_t
);
memcpy
(
*
result
+
offset
,
*
p1
,
pSup
->
resultRowSize
);
offset
+=
pSup
->
resultRowSize
;
pIter
=
taosHashIterate
(
pSup
->
pResultRowHashTable
,
pIter
);
}
if
(
length
)
{
*
length
=
offset
;
}
return
;
}
static
bool
aggDecodeResultRow
(
SOperatorInfo
*
pOperator
,
char
*
result
,
int32_t
length
)
{
if
(
!
result
||
length
<=
0
){
return
false
;
}
SAggOperatorInfo
*
pAggInfo
=
pOperator
->
info
;
SAggSupporter
*
pSup
=
&
pAggInfo
->
aggSup
;
SOptrBasicInfo
*
pInfo
=
&
pAggInfo
->
binfo
;
// int32_t size = taosHashGetSize(pSup->pResultRowHashTable);
int32_t
count
=
*
(
int32_t
*
)(
result
);
int32_t
offset
=
sizeof
(
int32_t
);
while
(
count
--
>
0
&&
length
>
offset
){
int32_t
keyLen
=
*
(
int32_t
*
)(
result
+
offset
);
offset
+=
sizeof
(
int32_t
);
uint64_t
tableGroupId
=
*
(
uint64_t
*
)(
result
+
offset
);
SResultRow
*
resultRow
=
getNewResultRow_rv
(
pSup
->
pResultBuf
,
tableGroupId
,
pSup
->
resultRowSize
);
if
(
!
resultRow
){
terrno
=
TSDB_CODE_TSC_INVALID_INPUT
;
return
false
;
}
// add a new result set for a new group
taosHashPut
(
pSup
->
pResultRowHashTable
,
result
+
offset
,
keyLen
,
&
resultRow
,
POINTER_BYTES
);
offset
+=
keyLen
;
int32_t
valueLen
=
*
(
int32_t
*
)(
result
+
offset
);
if
(
valueLen
!=
pSup
->
resultRowSize
){
terrno
=
TSDB_CODE_TSC_INVALID_INPUT
;
return
false
;
}
offset
+=
sizeof
(
int32_t
);
int32_t
pageId
=
resultRow
->
pageId
;
int32_t
pOffset
=
resultRow
->
offset
;
memcpy
(
resultRow
,
result
+
offset
,
valueLen
);
resultRow
->
pageId
=
pageId
;
resultRow
->
offset
=
pOffset
;
offset
+=
valueLen
;
initResultRow
(
resultRow
);
pInfo
->
resultRowInfo
.
pPosition
[
pInfo
->
resultRowInfo
.
size
++
]
=
(
SResultRowPosition
)
{.
pageId
=
resultRow
->
pageId
,
.
offset
=
resultRow
->
offset
};
}
if
(
offset
!=
length
){
terrno
=
TSDB_CODE_TSC_INVALID_INPUT
;
return
false
;
}
return
true
;
}
static
SSDataBlock
*
doMultiTableAggregate
(
SOperatorInfo
*
pOperator
,
bool
*
newgroup
)
{
static
SSDataBlock
*
doMultiTableAggregate
(
SOperatorInfo
*
pOperator
,
bool
*
newgroup
)
{
if
(
pOperator
->
status
==
OP_EXEC_DONE
)
{
if
(
pOperator
->
status
==
OP_EXEC_DONE
)
{
return
NULL
;
return
NULL
;
...
@@ -7086,10 +7179,10 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo *pOperator, bool* newgrou
...
@@ -7086,10 +7179,10 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo *pOperator, bool* newgrou
static
void
doHandleRemainBlockForNewGroupImpl
(
SFillOperatorInfo
*
pInfo
,
SResultInfo
*
pResultInfo
,
bool
*
newgroup
,
SExecTaskInfo
*
pTaskInfo
)
{
static
void
doHandleRemainBlockForNewGroupImpl
(
SFillOperatorInfo
*
pInfo
,
SResultInfo
*
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)? pTaskInfo->window.ekey:pInfo->existNewGroupBlock->info.window.ekey;
int64_t
ekey
=
Q_STATUS_EQUAL
(
pTaskInfo
->
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
,
pResultInfo
->
capacity
,
pInfo
->
p
);
doFillTimeIntervalGapsInResults
(
pInfo
->
pFillInfo
,
pInfo
->
pRes
,
pResultInfo
->
capacity
,
pInfo
->
p
);
...
@@ -7097,7 +7190,7 @@ static void doHandleRemainBlockForNewGroupImpl(SFillOperatorInfo *pInfo, SResult
...
@@ -7097,7 +7190,7 @@ static void doHandleRemainBlockForNewGroupImpl(SFillOperatorInfo *pInfo, SResult
*
newgroup
=
true
;
*
newgroup
=
true
;
}
}
static
void
doHandleRemainBlockFromNewGroup
(
SFillOperatorInfo
*
pInfo
,
SResultInfo
*
pResultInfo
,
bool
*
newgroup
)
{
static
void
doHandleRemainBlockFromNewGroup
(
SFillOperatorInfo
*
pInfo
,
SResultInfo
*
pResultInfo
,
bool
*
newgroup
,
SExecTaskInfo
*
pTaskInfo
)
{
if
(
taosFillHasMoreResults
(
pInfo
->
pFillInfo
))
{
if
(
taosFillHasMoreResults
(
pInfo
->
pFillInfo
))
{
*
newgroup
=
false
;
*
newgroup
=
false
;
doFillTimeIntervalGapsInResults
(
pInfo
->
pFillInfo
,
pInfo
->
pRes
,
(
int32_t
)
pResultInfo
->
capacity
,
pInfo
->
p
);
doFillTimeIntervalGapsInResults
(
pInfo
->
pFillInfo
,
pInfo
->
pRes
,
(
int32_t
)
pResultInfo
->
capacity
,
pInfo
->
p
);
...
@@ -7108,12 +7201,13 @@ static void doHandleRemainBlockFromNewGroup(SFillOperatorInfo *pInfo, SResultInf
...
@@ -7108,12 +7201,13 @@ static void doHandleRemainBlockFromNewGroup(SFillOperatorInfo *pInfo, SResultInf
// handle the cached new group data block
// handle the cached new group data block
if
(
pInfo
->
existNewGroupBlock
)
{
if
(
pInfo
->
existNewGroupBlock
)
{
// doHandleRemainBlockForNewGroupImpl(pInfo, pResultInfo, newgroup
);
doHandleRemainBlockForNewGroupImpl
(
pInfo
,
pResultInfo
,
newgroup
,
pTaskInfo
);
}
}
}
}
static
SSDataBlock
*
doFill
(
SOperatorInfo
*
pOperator
,
bool
*
newgroup
)
{
static
SSDataBlock
*
doFill
(
SOperatorInfo
*
pOperator
,
bool
*
newgroup
)
{
SFillOperatorInfo
*
pInfo
=
pOperator
->
info
;
SFillOperatorInfo
*
pInfo
=
pOperator
->
info
;
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
SResultInfo
*
pResultInfo
=
&
pOperator
->
resultInfo
;
SResultInfo
*
pResultInfo
=
&
pOperator
->
resultInfo
;
blockDataCleanup
(
pInfo
->
pRes
);
blockDataCleanup
(
pInfo
->
pRes
);
...
@@ -7121,7 +7215,7 @@ static SSDataBlock* doFill(SOperatorInfo *pOperator, bool* newgroup) {
...
@@ -7121,7 +7215,7 @@ static SSDataBlock* doFill(SOperatorInfo *pOperator, bool* newgroup) {
return
NULL
;
return
NULL
;
}
}
doHandleRemainBlockFromNewGroup
(
pInfo
,
pResultInfo
,
newgroup
);
doHandleRemainBlockFromNewGroup
(
pInfo
,
pResultInfo
,
newgroup
,
pTaskInfo
);
if
(
pInfo
->
pRes
->
info
.
rows
>
pResultInfo
->
threshold
||
(
!
pInfo
->
multigroupResult
&&
pInfo
->
pRes
->
info
.
rows
>
0
))
{
if
(
pInfo
->
pRes
->
info
.
rows
>
pResultInfo
->
threshold
||
(
!
pInfo
->
multigroupResult
&&
pInfo
->
pRes
->
info
.
rows
>
0
))
{
return
pInfo
->
pRes
;
return
pInfo
->
pRes
;
}
}
...
@@ -7142,7 +7236,7 @@ static SSDataBlock* doFill(SOperatorInfo *pOperator, bool* newgroup) {
...
@@ -7142,7 +7236,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
,
pTaskInfo
->
window
.
ekey
);
}
else
{
}
else
{
if
(
pBlock
==
NULL
)
{
if
(
pBlock
==
NULL
)
{
if
(
pInfo
->
totalInputRows
==
0
)
{
if
(
pInfo
->
totalInputRows
==
0
)
{
...
@@ -7150,7 +7244,7 @@ static SSDataBlock* doFill(SOperatorInfo *pOperator, bool* newgroup) {
...
@@ -7150,7 +7244,7 @@ static SSDataBlock* doFill(SOperatorInfo *pOperator, bool* newgroup) {
return
NULL
;
return
NULL
;
}
}
// taosFillSetStartInfo(pInfo->pFillInfo, 0, pRuntimeEnv->pQueryAttr
->window.ekey);
taosFillSetStartInfo
(
pInfo
->
pFillInfo
,
0
,
pTaskInfo
->
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
);
...
@@ -7168,14 +7262,13 @@ static SSDataBlock* doFill(SOperatorInfo *pOperator, bool* newgroup) {
...
@@ -7168,14 +7262,13 @@ static SSDataBlock* doFill(SOperatorInfo *pOperator, bool* newgroup) {
return
pInfo
->
pRes
;
return
pInfo
->
pRes
;
}
}
// doHandleRemainBlockFromNewGroup(pInfo, pRuntimeEnv, newgroup
);
doHandleRemainBlockFromNewGroup
(
pInfo
,
pResultInfo
,
newgroup
,
pTaskInfo
);
if
(
pInfo
->
pRes
->
info
.
rows
>
pOperator
->
resultInfo
.
threshold
||
pBlock
==
NULL
)
{
if
(
pInfo
->
pRes
->
info
.
rows
>
pOperator
->
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
,
pResultInfo
,
newgroup
,
pTaskInfo
);
if
(
pInfo
->
pRes
->
info
.
rows
>
pResultInfo
->
threshold
)
{
if
(
pInfo
->
pRes
->
info
.
rows
>
pResultInfo
->
threshold
)
{
return
pInfo
->
pRes
;
return
pInfo
->
pRes
;
}
}
...
@@ -7312,6 +7405,8 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo*
...
@@ -7312,6 +7405,8 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo*
pOperator
->
_openFn
=
doOpenAggregateOptr
;
pOperator
->
_openFn
=
doOpenAggregateOptr
;
pOperator
->
getNextFn
=
getAggregateResult
;
pOperator
->
getNextFn
=
getAggregateResult
;
pOperator
->
closeFn
=
destroyAggOperatorInfo
;
pOperator
->
closeFn
=
destroyAggOperatorInfo
;
pOperator
->
encodeResultRow
=
aggEncodeResultRow
;
pOperator
->
decodeResultRow
=
aggDecodeResultRow
;
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
@@ -7576,7 +7671,7 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
...
@@ -7576,7 +7671,7 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
}
}
pInfo
->
order
=
TSDB_ORDER_ASC
;
pInfo
->
order
=
TSDB_ORDER_ASC
;
pInfo
->
precision
=
TSDB_TIME_PRECISION_MI
CRO
;
pInfo
->
precision
=
TSDB_TIME_PRECISION_MI
LLI
;
pInfo
->
win
=
pTaskInfo
->
window
;
pInfo
->
win
=
pTaskInfo
->
window
;
pInfo
->
interval
=
*
pInterval
;
pInfo
->
interval
=
*
pInterval
;
...
@@ -7863,10 +7958,10 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExp
...
@@ -7863,10 +7958,10 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExp
pInfo
->
intervalInfo
=
*
pInterval
;
pInfo
->
intervalInfo
=
*
pInterval
;
SResultInfo
*
pResultInfo
=
&
pOperator
->
resultInfo
;
SResultInfo
*
pResultInfo
=
&
pOperator
->
resultInfo
;
// int32_t code = initFillInfo(pInfo, pExpr, numOfCols, fillVal,
, pResultInfo->capacity, pTaskInfo->id.str, pInterval, fillType);
int32_t
code
=
initFillInfo
(
pInfo
,
pExpr
,
numOfCols
,
(
int64_t
*
)
fillVal
,
pTaskInfo
->
window
,
pResultInfo
->
capacity
,
pTaskInfo
->
id
.
str
,
pInterval
,
fillType
);
//
if (code != TSDB_CODE_SUCCESS) {
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
//
goto _error;
goto
_error
;
//
}
}
pOperator
->
name
=
"FillOperator"
;
pOperator
->
name
=
"FillOperator"
;
pOperator
->
blockingOptr
=
false
;
pOperator
->
blockingOptr
=
false
;
...
@@ -7881,7 +7976,7 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExp
...
@@ -7881,7 +7976,7 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExp
pOperator
->
closeFn
=
destroySFillOperatorInfo
;
pOperator
->
closeFn
=
destroySFillOperatorInfo
;
int32_t
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
return
pOperator
;
return
pOperator
;
_error:
_error:
...
...
source/libs/function/CMakeLists.txt
浏览文件 @
bdbf365e
aux_source_directory
(
src FUNCTION_SRC
)
aux_source_directory
(
src FUNCTION_SRC
)
list
(
REMOVE_ITEM FUNCTION_SRC src/udfd.c
)
add_library
(
function STATIC
${
FUNCTION_SRC
}
)
add_library
(
function STATIC
${
FUNCTION_SRC
}
)
target_include_directories
(
target_include_directories
(
function
function
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/function"
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/function"
"
${
CMAKE_SOURCE_DIR
}
/contrib/libuv/include"
PRIVATE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
PRIVATE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
)
)
target_link_libraries
(
target_link_libraries
(
function
function
PUBLIC uv_a
PRIVATE os util common nodes
PRIVATE os util common nodes
)
)
add_executable
(
runUdf test/runUdf.c
)
target_include_directories
(
runUdf
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/function"
"
${
CMAKE_SOURCE_DIR
}
/contrib/libuv/include"
PRIVATE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
)
target_link_libraries
(
runUdf
PUBLIC uv_a
PRIVATE os util common nodes function
)
add_library
(
udf1 MODULE test/udf1.c
)
target_include_directories
(
udf1
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/function"
PRIVATE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
)
#SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/build/bin)
add_executable
(
udfd src/udfd.c
)
target_include_directories
(
udfd
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/function"
"
${
CMAKE_SOURCE_DIR
}
/contrib/libuv/include"
PRIVATE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
)
target_link_libraries
(
udfd
PUBLIC uv_a
PRIVATE os util common nodes function
)
source/libs/function/inc/tudf.h
浏览文件 @
bdbf365e
...
@@ -20,68 +20,116 @@
...
@@ -20,68 +20,116 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
#include "os.h"
//======================================================================================
#include "taoserror.h"
//begin API to taosd and qworker
/**
* start udf dameon service
* @return error code
*/
int32_t
startUdfService
();
/**
* stop udf dameon service
* @return error code
*/
int32_t
stopUdfService
();
enum
{
enum
{
TSDB_UDF_FUNC_NORMAL
=
0
,
TSDB_UDF_TYPE_SCALAR
=
0
,
TSDB_UDF_FUNC_INIT
,
TSDB_UDF_TYPE_AGGREGATE
=
1
TSDB_UDF_FUNC_FINALIZE
,
TSDB_UDF_FUNC_MERGE
,
TSDB_UDF_FUNC_DESTROY
,
TSDB_UDF_FUNC_MAX_NUM
};
};
typedef
struct
SUdfInit
{
enum
{
int32_t
maybe_null
;
/* 1 if function can return NULL */
TSDB_UDF_SCRIPT_BIN_LIB
=
0
,
uint32_t
decimals
;
/* for real functions */
TSDB_UDF_SCRIPT_LUA
=
1
,
uint64_t
length
;
/* For string functions */
};
char
*
ptr
;
/* free pointer for function data */
int32_t
const_item
;
/* 0 if result is independent of arguments */
// script like lua/javascript
void
*
script_ctx
;
void
(
*
destroyCtxFunc
)(
void
*
script_ctx
);
}
SUdfInit
;
typedef
struct
SUdfInfo
{
typedef
struct
SUdfInfo
{
int32_t
functionId
;
// system assigned function id
char
*
udfName
;
// function name
int32_t
funcType
;
// scalar function or aggregate function
int32_t
udfType
;
// scalar function or aggregate function
int8_t
scriptType
;
char
*
path
;
int8_t
resType
;
// result type
int8_t
resType
;
// result type
int16_t
resBytes
;
// result byte
int16_t
resBytes
;
// result byte
int32_t
contLen
;
// content length
int32_t
bufSize
;
//interbuf size
int32_t
bufSize
;
// interbuf size
char
*
name
;
// function name
void
*
handle
;
// handle loaded in mem
void
*
funcs
[
TSDB_UDF_FUNC_MAX_NUM
];
// function ptr
// for script like lua/javascript only
int
isScript
;
void
*
pScriptCtx
;
SUdfInit
init
;
char
*
content
;
char
*
path
;
}
SUdfInfo
;
}
SUdfInfo
;
typedef
void
*
UdfHandle
;
/**
* setup udf
* @param udf, in
* @param handle, out
* @return error code
*/
int32_t
setupUdf
(
SUdfInfo
*
udf
,
UdfHandle
*
handle
);
enum
{
TSDB_UDF_STEP_NORMAL
=
0
,
TSDB_UDF_STEP_MERGE
,
TSDb_UDF_STEP_FINALIZE
,
TSDB_UDF_STEP_MAX_NUM
};
/**
* call udf
* @param handle udf handle
* @param step
* @param state
* @param stateSize
* @param input
* @param newstate
* @param newStateSize
* @param output
* @return error code
*/
//TODO: must change the following after metadata flow and data flow between qworker and udfd is well defined
typedef
struct
SUdfDataBlock
{
char
*
data
;
int32_t
size
;
}
SUdfDataBlock
;
int32_t
callUdf
(
UdfHandle
handle
,
int8_t
step
,
char
*
state
,
int32_t
stateSize
,
SUdfDataBlock
input
,
char
**
newstate
,
int32_t
*
newStateSize
,
SUdfDataBlock
*
output
);
/**
* tearn down udf
* @param handle
* @return
*/
int32_t
teardownUdf
(
UdfHandle
handle
);
// end API to taosd and qworker
//=============================================================================================================================
// TODO: Must change
// begin API to UDF writer.
// script
// script
typedef
int32_t
(
*
scriptInitFunc
)(
void
*
pCtx
);
//
typedef int32_t (*scriptInitFunc)(void* pCtx);
typedef
void
(
*
scriptNormalFunc
)(
void
*
pCtx
,
char
*
data
,
int16_t
iType
,
int16_t
iBytes
,
int32_t
numOfRows
,
//
typedef void (*scriptNormalFunc)(void* pCtx, char* data, int16_t iType, int16_t iBytes, int32_t numOfRows,
int64_t
*
ptList
,
int64_t
key
,
char
*
dataOutput
,
char
*
tsOutput
,
int32_t
*
numOfOutput
,
//
int64_t* ptList, int64_t key, char* dataOutput, char* tsOutput, int32_t* numOfOutput,
int16_t
oType
,
int16_t
oBytes
);
//
int16_t oType, int16_t oBytes);
typedef
void
(
*
scriptFinalizeFunc
)(
void
*
pCtx
,
int64_t
key
,
char
*
dataOutput
,
int32_t
*
numOfOutput
);
//
typedef void (*scriptFinalizeFunc)(void* pCtx, int64_t key, char* dataOutput, int32_t* numOfOutput);
typedef
void
(
*
scriptMergeFunc
)(
void
*
pCtx
,
char
*
data
,
int32_t
numOfRows
,
char
*
dataOutput
,
int32_t
*
numOfOutput
);
//
typedef void (*scriptMergeFunc)(void* pCtx, char* data, int32_t numOfRows, char* dataOutput, int32_t* numOfOutput);
typedef
void
(
*
scriptDestroyFunc
)(
void
*
pCtx
);
//
typedef void (*scriptDestroyFunc)(void* pCtx);
// dynamic lib
// dynamic lib
typedef
void
(
*
udfNormalFunc
)(
char
*
data
,
int16_t
itype
,
int16_t
iBytes
,
int32_t
numOfRows
,
int64_t
*
ts
,
typedef
int32_t
(
*
TUdfInitFunc
)();
char
*
dataOutput
,
char
*
interBuf
,
char
*
tsOutput
,
int32_t
*
numOfOutput
,
int16_t
oType
,
typedef
void
(
*
TUdfDestroyFunc
)();
int16_t
oBytes
,
SUdfInit
*
buf
);
typedef
int32_t
(
*
udfInitFunc
)(
SUdfInit
*
data
);
typedef
void
(
*
TUdfFunc
)(
int8_t
step
,
typedef
void
(
*
udfFinalizeFunc
)(
char
*
dataOutput
,
char
*
interBuf
,
int32_t
*
numOfOutput
,
SUdfInit
*
buf
);
char
*
state
,
int32_t
stateSize
,
SUdfDataBlock
input
,
typedef
void
(
*
udfMergeFunc
)(
char
*
data
,
int32_t
numOfRows
,
char
*
dataOutput
,
int32_t
*
numOfOutput
,
SUdfInit
*
buf
);
char
**
newstate
,
int32_t
*
newStateSize
,
SUdfDataBlock
*
output
);
typedef
void
(
*
udfDestroyFunc
)(
SUdfInit
*
buf
);
//typedef void (*udfMergeFunc)(char *data, int32_t numOfRows, char *dataOutput, int32_t* numOfOutput);
//typedef void (*udfFinalizeFunc)(char* state, int32_t stateSize, SUdfDataBlock *output);
// end API to UDF writer
//=======================================================================================================================
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/libs/function/inc/tudfInt.h
0 → 100644
浏览文件 @
bdbf365e
/*
* 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/>.
*/
#ifndef TDENGINE_TUDF_INT_H
#define TDENGINE_TUDF_INT_H
#ifdef __cplusplus
extern
"C"
{
#endif
//TODO replaces them with fnDebug
//#define debugPrint(...) taosPrintLog("Function", DEBUG_INFO, 135, __VA_ARGS__)
#define debugPrint(...) {fprintf(stderr, __VA_ARGS__);fprintf(stderr, "\n");}
enum
{
UDF_TASK_SETUP
=
0
,
UDF_TASK_CALL
=
1
,
UDF_TASK_TEARDOWN
=
2
};
typedef
struct
SUdfSetupRequest
{
char
udfName
[
16
];
//
int8_t
scriptType
;
// 0:c, 1: lua, 2:js
int8_t
udfType
;
//udaf, udf
int16_t
pathSize
;
char
*
path
;
}
SUdfSetupRequest
;
typedef
struct
SUdfSetupResponse
{
int64_t
udfHandle
;
}
SUdfSetupResponse
;
typedef
struct
SUdfCallRequest
{
int64_t
udfHandle
;
int8_t
step
;
int32_t
inputBytes
;
char
*
input
;
int32_t
stateBytes
;
char
*
state
;
}
SUdfCallRequest
;
typedef
struct
SUdfCallResponse
{
int32_t
outputBytes
;
char
*
output
;
int32_t
newStateBytes
;
char
*
newState
;
}
SUdfCallResponse
;
typedef
struct
SUdfTeardownRequest
{
int64_t
udfHandle
;
}
SUdfTeardownRequest
;
typedef
struct
SUdfTeardownResponse
{
}
SUdfTeardownResponse
;
typedef
struct
SUdfRequest
{
int32_t
msgLen
;
int64_t
seqNum
;
int8_t
type
;
void
*
subReq
;
}
SUdfRequest
;
typedef
struct
SUdfResponse
{
int32_t
msgLen
;
int64_t
seqNum
;
int8_t
type
;
int32_t
code
;
void
*
subRsp
;
}
SUdfResponse
;
int32_t
decodeRequest
(
char
*
buf
,
int32_t
bufLen
,
SUdfRequest
**
pRequest
);
int32_t
encodeResponse
(
char
**
buf
,
int32_t
*
bufLen
,
SUdfResponse
*
response
);
int32_t
encodeRequest
(
char
**
buf
,
int32_t
*
bufLen
,
SUdfRequest
*
request
);
int32_t
decodeResponse
(
char
*
buf
,
int32_t
bufLen
,
SUdfResponse
**
pResponse
);
#ifdef __cplusplus
}
#endif
#endif // TDENGINE_TUDF_INT_H
source/libs/function/inc/udfc.h
0 → 100644
浏览文件 @
bdbf365e
//
// Created by shenglian on 28/02/22.
//
#ifndef UDF_UDF_H
#define UDF_UDF_H
#include <stdlib.h>
#define DEBUG
#ifdef DEBUG
#define debugPrint(...) fprintf(__VA_ARGS__)
#else
#define debugPrint(...)
/**/
#endif
enum
{
UDF_TASK_SETUP
=
0
,
UDF_TASK_CALL
=
1
,
UDF_TASK_TEARDOWN
=
2
};
typedef
struct
SSDataBlock
{
char
*
data
;
int32_t
size
;
}
SSDataBlock
;
typedef
struct
SUdfInfo
{
char
*
udfName
;
char
*
path
;
}
SUdfInfo
;
typedef
void
*
UdfHandle
;
int32_t
startUdfService
();
int32_t
stopUdfService
();
//int32_t setupUdf(SUdfInfo *udf, int32_t numOfUdfs, UdfHandle *handles);
int32_t
setupUdf
(
SUdfInfo
*
udf
,
UdfHandle
*
handle
);
int32_t
callUdf
(
UdfHandle
handle
,
int8_t
step
,
char
*
state
,
int32_t
stateSize
,
SSDataBlock
input
,
char
**
newstate
,
int32_t
*
newStateSize
,
SSDataBlock
*
output
);
int32_t
teardownUdf
(
UdfHandle
handle
);
typedef
struct
SUdfSetupRequest
{
char
udfName
[
16
];
//
int8_t
scriptType
;
// 0:c, 1: lua, 2:js
int8_t
udfType
;
//udaf, udf, udtf
int16_t
pathSize
;
char
*
path
;
}
SUdfSetupRequest
;
typedef
struct
SUdfSetupResponse
{
int64_t
udfHandle
;
}
SUdfSetupResponse
;
typedef
struct
SUdfCallRequest
{
int64_t
udfHandle
;
int8_t
step
;
int32_t
inputBytes
;
char
*
input
;
int32_t
stateBytes
;
char
*
state
;
}
SUdfCallRequest
;
typedef
struct
SUdfCallResponse
{
int32_t
outputBytes
;
char
*
output
;
int32_t
newStateBytes
;
char
*
newState
;
}
SUdfCallResponse
;
typedef
struct
SUdfTeardownRequest
{
int64_t
udfHandle
;
}
SUdfTeardownRequest
;
typedef
struct
SUdfTeardownResponse
{
}
SUdfTeardownResponse
;
typedef
struct
SUdfRequest
{
int32_t
msgLen
;
int64_t
seqNum
;
int8_t
type
;
void
*
subReq
;
}
SUdfRequest
;
typedef
struct
SUdfResponse
{
int32_t
msgLen
;
int64_t
seqNum
;
int8_t
type
;
int32_t
code
;
void
*
subRsp
;
}
SUdfResponse
;
int32_t
decodeRequest
(
char
*
buf
,
int32_t
bufLen
,
SUdfRequest
**
pRequest
);
int32_t
encodeResponse
(
char
**
buf
,
int32_t
*
bufLen
,
SUdfResponse
*
response
);
int32_t
encodeRequest
(
char
**
buf
,
int32_t
*
bufLen
,
SUdfRequest
*
request
);
int32_t
decodeResponse
(
char
*
buf
,
int32_t
bufLen
,
SUdfResponse
**
pResponse
);
#endif //UDF_UDF_H
source/libs/function/src/builtinsimpl.c
浏览文件 @
bdbf365e
...
@@ -528,11 +528,10 @@ void firstFunction(SqlFunctionCtx *pCtx) {
...
@@ -528,11 +528,10 @@ void firstFunction(SqlFunctionCtx *pCtx) {
char
*
buf
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
char
*
buf
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
SColumnInfoData
*
pInputCol
=
pInput
->
pData
[
0
];
SColumnInfoData
*
pInputCol
=
pInput
->
pData
[
0
];
// All null data column, return directly.
// All null data column, return directly.
if
(
pInput
->
pColumnDataAgg
[
0
]
->
numOfNull
==
pInput
->
totalRows
)
{
if
(
pInput
->
colDataAggIsSet
&&
(
pInput
->
pColumnDataAgg
[
0
]
->
numOfNull
==
pInput
->
totalRows
)
)
{
ASSERT
(
pInputCol
->
hasNull
==
true
);
ASSERT
(
pInputCol
->
hasNull
==
true
);
return
;
return
;
}
}
...
...
source/libs/function/src/tudf.c
浏览文件 @
bdbf365e
/*
* 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 "uv.h"
#include "os.h"
#include "tlog.h"
#include "tudf.h"
#include "tudf.h"
#include "tudfInt.h"
static
char
*
getUdfFuncName
(
char
*
funcname
,
char
*
name
,
int
type
)
{
//TODO: when startup, set thread poll size. add it to cfg
switch
(
type
)
{
//TODO: udfd restart when exist or aborts
case
TSDB_UDF_FUNC_NORMAL
:
//TODO: network error processing.
strcpy
(
funcname
,
name
);
//TODO: add unit test
//TODO: add lua support
void
onUdfcRead
(
uv_stream_t
*
client
,
ssize_t
nread
,
const
uv_buf_t
*
buf
);
enum
{
UV_TASK_CONNECT
=
0
,
UV_TASK_REQ_RSP
=
1
,
UV_TASK_DISCONNECT
=
2
};
typedef
struct
SUdfUvSession
{
int64_t
severHandle
;
uv_pipe_t
*
udfSvcPipe
;
}
SUdfUvSession
;
typedef
struct
SClientUvTaskNode
{
int8_t
type
;
int
errCode
;
uv_pipe_t
*
pipe
;
int64_t
seqNum
;
uv_buf_t
reqBuf
;
uv_sem_t
taskSem
;
uv_buf_t
rspBuf
;
struct
SClientUvTaskNode
*
prev
;
struct
SClientUvTaskNode
*
next
;
}
SClientUvTaskNode
;
typedef
struct
SClientUdfTask
{
int8_t
type
;
SUdfUvSession
*
session
;
int32_t
errCode
;
union
{
struct
{
SUdfSetupRequest
req
;
SUdfSetupResponse
rsp
;
}
_setup
;
struct
{
SUdfCallRequest
req
;
SUdfCallResponse
rsp
;
}
_call
;
struct
{
SUdfTeardownRequest
req
;
SUdfTeardownResponse
rsp
;
}
_teardown
;
};
}
SClientUdfTask
;
typedef
struct
SClientConnBuf
{
char
*
buf
;
int32_t
len
;
int32_t
cap
;
int32_t
total
;
}
SClientConnBuf
;
typedef
struct
SClientUvConn
{
uv_pipe_t
*
pipe
;
SClientUvTaskNode
taskQueue
;
SClientConnBuf
readBuf
;
}
SClientUvConn
;
uv_process_t
gUdfdProcess
;
uv_barrier_t
gUdfInitBarrier
;
uv_loop_t
gUdfdLoop
;
uv_thread_t
gUdfLoopThread
;
uv_async_t
gUdfLoopTaskAync
;
uv_async_t
gUdfLoopStopAsync
;
uv_mutex_t
gUdfTaskQueueMutex
;
int64_t
gUdfTaskSeqNum
=
0
;
//double circular linked list
typedef
SClientUvTaskNode
*
SClientUvTaskQueue
;
SClientUvTaskNode
gUdfQueueNode
;
SClientUvTaskQueue
gUdfTaskQueue
=
&
gUdfQueueNode
;
//add SClientUvTaskNode task that close conn
void
udfTaskQueueInit
(
SClientUvTaskQueue
q
)
{
q
->
next
=
q
;
q
->
prev
=
q
;
}
bool
udfTaskQueueIsEmpty
(
SClientUvTaskQueue
q
)
{
return
q
==
q
->
next
;
}
void
udfTaskQueueInsertTail
(
SClientUvTaskQueue
q
,
SClientUvTaskNode
*
e
)
{
e
->
next
=
q
;
e
->
prev
=
q
->
prev
;
e
->
prev
->
next
=
e
;
q
->
prev
=
e
;
}
void
udfTaskQueueInsertTaskAtHead
(
SClientUvTaskQueue
q
,
SClientUvTaskNode
*
e
)
{
e
->
next
=
q
->
next
;
e
->
prev
=
q
;
q
->
next
->
prev
=
e
;
q
->
next
=
e
;
}
void
udfTaskQueueRemoveTask
(
SClientUvTaskNode
*
e
)
{
e
->
prev
->
next
=
e
->
next
;
e
->
next
->
prev
=
e
->
prev
;
}
void
udfTaskQueueSplit
(
SClientUvTaskQueue
q
,
SClientUvTaskNode
*
from
,
SClientUvTaskQueue
n
)
{
n
->
prev
=
q
->
prev
;
n
->
prev
->
next
=
n
;
n
->
next
=
from
;
q
->
prev
=
from
->
prev
;
q
->
prev
->
next
=
q
;
from
->
prev
=
n
;
}
SClientUvTaskNode
*
udfTaskQueueHeadTask
(
SClientUvTaskQueue
q
)
{
return
q
->
next
;
}
SClientUvTaskNode
*
udfTaskQueueTailTask
(
SClientUvTaskQueue
q
)
{
return
q
->
prev
;
}
SClientUvTaskNode
*
udfTaskQueueNext
(
SClientUvTaskNode
*
e
)
{
return
e
->
next
;
}
void
udfTaskQueueMove
(
SClientUvTaskQueue
q
,
SClientUvTaskQueue
n
)
{
if
(
udfTaskQueueIsEmpty
(
q
))
{
udfTaskQueueInit
(
n
);
}
else
{
SClientUvTaskNode
*
h
=
udfTaskQueueHeadTask
(
q
);
udfTaskQueueSplit
(
q
,
h
,
n
);
}
}
int32_t
encodeRequest
(
char
**
pBuf
,
int32_t
*
pBufLen
,
SUdfRequest
*
request
)
{
debugPrint
(
"%s"
,
"encoding request"
);
int
len
=
sizeof
(
SUdfRequest
)
-
sizeof
(
void
*
);
switch
(
request
->
type
)
{
case
UDF_TASK_SETUP
:
{
SUdfSetupRequest
*
setup
=
(
SUdfSetupRequest
*
)
(
request
->
subReq
);
len
+=
sizeof
(
SUdfSetupRequest
)
-
1
*
sizeof
(
char
*
)
+
setup
->
pathSize
;
break
;
break
;
case
TSDB_UDF_FUNC_INIT
:
}
sprintf
(
funcname
,
"%s_init"
,
name
);
case
UDF_TASK_CALL
:
{
SUdfCallRequest
*
call
=
(
SUdfCallRequest
*
)
(
request
->
subReq
);
len
+=
sizeof
(
SUdfCallRequest
)
-
2
*
sizeof
(
char
*
)
+
call
->
inputBytes
+
call
->
stateBytes
;
break
;
break
;
case
TSDB_UDF_FUNC_FINALIZE
:
}
sprintf
(
funcname
,
"%s_finalize"
,
name
);
case
UDF_TASK_TEARDOWN
:
{
SUdfTeardownRequest
*
teardown
=
(
SUdfTeardownRequest
*
)
(
request
->
subReq
);
len
+=
sizeof
(
SUdfTeardownRequest
);
break
;
break
;
case
TSDB_UDF_FUNC_MERGE
:
}
sprintf
(
funcname
,
"%s_merge"
,
name
);
default:
break
;
break
;
case
TSDB_UDF_FUNC_DESTROY
:
}
sprintf
(
funcname
,
"%s_destroy"
,
name
);
char
*
bufBegin
=
malloc
(
len
);
char
*
buf
=
bufBegin
;
//skip msgLen first
buf
+=
sizeof
(
int32_t
);
*
(
int64_t
*
)
buf
=
request
->
seqNum
;
buf
+=
sizeof
(
int64_t
);
*
(
int8_t
*
)
buf
=
request
->
type
;
buf
+=
sizeof
(
int8_t
);
switch
(
request
->
type
)
{
case
UDF_TASK_SETUP
:
{
SUdfSetupRequest
*
setup
=
(
SUdfSetupRequest
*
)
(
request
->
subReq
);
memcpy
(
buf
,
setup
->
udfName
,
16
);
buf
+=
16
;
*
(
int8_t
*
)
buf
=
setup
->
scriptType
;
buf
+=
sizeof
(
int8_t
);
*
(
int8_t
*
)
buf
=
setup
->
udfType
;
buf
+=
sizeof
(
int8_t
);
*
(
int16_t
*
)
buf
=
setup
->
pathSize
;
buf
+=
sizeof
(
int16_t
);
memcpy
(
buf
,
setup
->
path
,
setup
->
pathSize
);
buf
+=
setup
->
pathSize
;
break
;
break
;
}
case
UDF_TASK_CALL
:
{
SUdfCallRequest
*
call
=
(
SUdfCallRequest
*
)
(
request
->
subReq
);
*
(
int64_t
*
)
buf
=
call
->
udfHandle
;
buf
+=
sizeof
(
int64_t
);
*
(
int8_t
*
)
buf
=
call
->
step
;
buf
+=
sizeof
(
int8_t
);
*
(
int32_t
*
)
buf
=
call
->
inputBytes
;
buf
+=
sizeof
(
int32_t
);
memcpy
(
buf
,
call
->
input
,
call
->
inputBytes
);
buf
+=
call
->
inputBytes
;
*
(
int32_t
*
)
buf
=
call
->
stateBytes
;
buf
+=
sizeof
(
int32_t
);
memcpy
(
buf
,
call
->
state
,
call
->
stateBytes
);
buf
+=
call
->
stateBytes
;
break
;
}
case
UDF_TASK_TEARDOWN
:
{
SUdfTeardownRequest
*
teardown
=
(
SUdfTeardownRequest
*
)
(
request
->
subReq
);
*
(
int64_t
*
)
buf
=
teardown
->
udfHandle
;
buf
+=
sizeof
(
int64_t
);
break
;
}
default:
default:
assert
(
0
);
break
;
break
;
}
}
return
funcname
;
request
->
msgLen
=
buf
-
bufBegin
;
*
(
int32_t
*
)
bufBegin
=
request
->
msgLen
;
*
pBuf
=
bufBegin
;
*
pBufLen
=
request
->
msgLen
;
return
0
;
}
}
#if 0
int32_t
decodeRequest
(
char
*
bufMsg
,
int32_t
bufLen
,
SUdfRequest
**
pRequest
)
{
int32_t initUdfInfo(SUdfInfo* pUdfInfo) {
debugPrint
(
"%s"
,
"decoding request"
);
if (pUdfInfo == NULL) {
if
(
*
(
int32_t
*
)
bufMsg
!=
bufLen
)
{
return TSDB_CODE_SUCCESS;
debugPrint
(
"%s"
,
"decoding request error"
);
return
-
1
;
}
}
////qError("script len: %d", pUdfInfo->contLen);
char
*
buf
=
bufMsg
;
if (isValidScript(pUdfInfo->content, pUdfInfo->contLen)) {
SUdfRequest
*
request
=
malloc
(
sizeof
(
SUdfRequest
));
pUdfInfo->isScript = 1;
request
->
subReq
=
NULL
;
pUdfInfo->pScriptCtx = createScriptCtx(pUdfInfo->content, pUdfInfo->resType, pUdfInfo->resBytes);
request
->
msgLen
=
*
(
int32_t
*
)
(
buf
);
if (pUdfInfo->pScriptCtx == NULL) {
buf
+=
sizeof
(
int32_t
);
return TSDB_CODE_QRY_SYS_ERROR;
request
->
seqNum
=
*
(
int64_t
*
)
(
buf
);
buf
+=
sizeof
(
int64_t
);
request
->
type
=
*
(
int8_t
*
)
(
buf
);
buf
+=
sizeof
(
int8_t
);
switch
(
request
->
type
)
{
case
UDF_TASK_SETUP
:
{
SUdfSetupRequest
*
setup
=
malloc
(
sizeof
(
SUdfSetupRequest
));
memcpy
(
setup
->
udfName
,
buf
,
16
);
buf
+=
16
;
setup
->
scriptType
=
*
(
int8_t
*
)
buf
;
buf
+=
sizeof
(
int8_t
);
setup
->
udfType
=
*
(
int8_t
*
)
buf
;
buf
+=
sizeof
(
int8_t
);
setup
->
pathSize
=
*
(
int16_t
*
)
buf
;
buf
+=
sizeof
(
int16_t
);
setup
->
path
=
buf
;
buf
+=
setup
->
pathSize
;
request
->
subReq
=
setup
;
break
;
}
}
tfree(pUdfInfo->content);
case
UDF_TASK_CALL
:
{
SUdfCallRequest
*
call
=
malloc
(
sizeof
(
SUdfCallRequest
));
pUdfInfo->funcs[TSDB_UDF_FUNC_INIT] = taosLoadScriptInit;
if (pUdfInfo->funcs[TSDB_UDF_FUNC_INIT] == NULL
call
->
udfHandle
=
*
(
int64_t
*
)
buf
;
|| (*(scriptInitFunc)pUdfInfo->funcs[TSDB_UDF_FUNC_INIT])(pUdfInfo->pScriptCtx) != TSDB_CODE_SUCCESS) {
buf
+=
sizeof
(
int64_t
);
return TSDB_CODE_QRY_SYS_ERROR;
call
->
step
=
*
(
int8_t
*
)
buf
;
buf
+=
sizeof
(
int8_t
);
call
->
inputBytes
=
*
(
int32_t
*
)
buf
;
buf
+=
sizeof
(
int32_t
);
call
->
input
=
buf
;
buf
+=
call
->
inputBytes
;
call
->
stateBytes
=
*
(
int32_t
*
)
buf
;
buf
+=
sizeof
(
int32_t
);
call
->
state
=
buf
;
buf
+=
call
->
stateBytes
;
request
->
subReq
=
call
;
break
;
}
}
pUdfInfo->funcs[TSDB_UDF_FUNC_NORMAL] = taosLoadScriptNormal;
case
UDF_TASK_TEARDOWN
:
{
SUdfTeardownRequest
*
teardown
=
malloc
(
sizeof
(
SUdfTeardownRequest
));
teardown
->
udfHandle
=
*
(
int64_t
*
)
buf
;
buf
+=
sizeof
(
int64_t
);
if (pUdfInfo->funcType == FUNCTION_TYPE_AGG) {
request
->
subReq
=
teardown
;
pUdfInfo->funcs[TSDB_UDF_FUNC_FINALIZE] = taosLoadScriptFinalize;
pUdfInfo->funcs[TSDB_UDF_FUNC_MERGE] = taosLoadScriptMerge;
}
}
pUdfInfo->funcs[TSDB_UDF_FUNC_DESTROY] = taosLoadScriptDestroy;
} else {
}
char path[PATH_MAX] = {0};
if
(
buf
-
bufMsg
!=
bufLen
)
{
taosGetTmpfilePath("script", path, tsTempDir);
debugPrint
(
"%s"
,
"decode request error"
);
free
(
request
->
subReq
);
free
(
request
);
return
-
1
;
}
*
pRequest
=
request
;
return
0
;
}
FILE* file = fopen(path, "w+");
int32_t
encodeResponse
(
char
**
pBuf
,
int32_t
*
pBufLen
,
SUdfResponse
*
response
)
{
debugPrint
(
"%s"
,
"encoding response"
);
// TODO check for failure of flush to disk
int32_t
len
=
sizeof
(
SUdfResponse
)
-
sizeof
(
void
*
);
/*size_t t = */ fwrite(pUdfInfo->content, pUdfInfo->contLen, 1, file);
fclose(file);
tfree(pUdfInfo->content);
pUdfInfo->path = strdup(path);
switch
(
response
->
type
)
{
case
UDF_TASK_SETUP
:
{
len
+=
sizeof
(
SUdfSetupResponse
);
break
;
}
case
UDF_TASK_CALL
:
{
SUdfCallResponse
*
callResp
=
(
SUdfCallResponse
*
)
(
response
->
subRsp
);
len
+=
sizeof
(
SUdfCallResponse
)
-
2
*
sizeof
(
char
*
)
+
callResp
->
outputBytes
+
callResp
->
newStateBytes
;
break
;
}
case
UDF_TASK_TEARDOWN
:
{
len
+=
sizeof
(
SUdfTeardownResponse
);
break
;
}
}
pUdfInfo->handle = taosLoadDll(path);
char
*
bufBegin
=
malloc
(
len
);
char
*
buf
=
bufBegin
;
if (NULL == pUdfInfo->handle) {
//skip msgLen
return TSDB_CODE_QRY_SYS_ERROR;
buf
+=
sizeof
(
int32_t
);
}
char funcname[FUNCTIONS_NAME_MAX_LENGTH + 10] = {0};
*
(
int64_t
*
)
buf
=
response
->
seqNum
;
pUdfInfo->funcs[TSDB_UDF_FUNC_NORMAL] = taosLoadSym(pUdfInfo->handle, getUdfFuncName(funcname, pUdfInfo->name, TSDB_UDF_FUNC_NORMAL));
buf
+=
sizeof
(
int64_t
);
if (NULL == pUdfInfo->funcs[TSDB_UDF_FUNC_NORMAL]) {
*
(
int8_t
*
)
buf
=
response
->
type
;
return TSDB_CODE_QRY_SYS_ERROR;
buf
+=
sizeof
(
int8_t
);
*
(
int32_t
*
)
buf
=
response
->
code
;
buf
+=
sizeof
(
int32_t
);
switch
(
response
->
type
)
{
case
UDF_TASK_SETUP
:
{
SUdfSetupResponse
*
setupResp
=
(
SUdfSetupResponse
*
)
(
response
->
subRsp
);
*
(
int64_t
*
)
buf
=
setupResp
->
udfHandle
;
buf
+=
sizeof
(
int64_t
);
break
;
}
case
UDF_TASK_CALL
:
{
SUdfCallResponse
*
callResp
=
(
SUdfCallResponse
*
)
(
response
->
subRsp
);
*
(
int32_t
*
)
buf
=
callResp
->
outputBytes
;
buf
+=
sizeof
(
int32_t
);
memcpy
(
buf
,
callResp
->
output
,
callResp
->
outputBytes
);
buf
+=
callResp
->
outputBytes
;
*
(
int32_t
*
)
buf
=
callResp
->
newStateBytes
;
buf
+=
sizeof
(
int32_t
);
memcpy
(
buf
,
callResp
->
newState
,
callResp
->
newStateBytes
);
buf
+=
callResp
->
newStateBytes
;
break
;
}
case
UDF_TASK_TEARDOWN
:
{
SUdfTeardownResponse
*
teardownResp
=
(
SUdfTeardownResponse
*
)
(
response
->
subRsp
);
break
;
}
default:
break
;
}
}
response
->
msgLen
=
buf
-
bufBegin
;
*
(
int32_t
*
)
bufBegin
=
response
->
msgLen
;
*
pBuf
=
bufBegin
;
*
pBufLen
=
response
->
msgLen
;
return
0
;
}
pUdfInfo->funcs[TSDB_UDF_FUNC_INIT] = taosLoadSym(pUdfInfo->handle, getUdfFuncName(funcname, pUdfInfo->name, TSDB_UDF_FUNC_INIT));
int32_t
decodeResponse
(
char
*
bufMsg
,
int32_t
bufLen
,
SUdfResponse
**
pResponse
)
{
debugPrint
(
"%s"
,
"decoding response"
);
if (pUdfInfo->funcType == FUNCTION_TYPE_AGG) {
if
(
*
(
int32_t
*
)
bufMsg
!=
bufLen
)
{
pUdfInfo->funcs[TSDB_UDF_FUNC_FINALIZE] = taosLoadSym(pUdfInfo->handle, getUdfFuncName(funcname, pUdfInfo->name, TSDB_UDF_FUNC_FINALIZE));
debugPrint
(
"%s"
,
"can not decode response"
);
pUdfInfo->funcs[TSDB_UDF_FUNC_MERGE] = taosLoadSym(pUdfInfo->handle, getUdfFuncName(funcname, pUdfInfo->name, TSDB_UDF_FUNC_MERGE));
return
-
1
;
}
char
*
buf
=
bufMsg
;
SUdfResponse
*
rsp
=
malloc
(
sizeof
(
SUdfResponse
));
rsp
->
msgLen
=
*
(
int32_t
*
)
buf
;
buf
+=
sizeof
(
int32_t
);
rsp
->
seqNum
=
*
(
int64_t
*
)
buf
;
buf
+=
sizeof
(
int64_t
);
rsp
->
type
=
*
(
int8_t
*
)
buf
;
buf
+=
sizeof
(
int8_t
);
rsp
->
code
=
*
(
int32_t
*
)
buf
;
buf
+=
sizeof
(
int32_t
);
switch
(
rsp
->
type
)
{
case
UDF_TASK_SETUP
:
{
SUdfSetupResponse
*
setupRsp
=
(
SUdfSetupResponse
*
)
malloc
(
sizeof
(
SUdfSetupResponse
));
setupRsp
->
udfHandle
=
*
(
int64_t
*
)
buf
;
buf
+=
sizeof
(
int64_t
);
rsp
->
subRsp
=
(
char
*
)
setupRsp
;
break
;
}
}
case
UDF_TASK_CALL
:
{
SUdfCallResponse
*
callRsp
=
(
SUdfCallResponse
*
)
malloc
(
sizeof
(
SUdfCallResponse
));
callRsp
->
outputBytes
=
*
(
int32_t
*
)
buf
;
buf
+=
sizeof
(
int32_t
);
callRsp
->
output
=
buf
;
buf
+=
callRsp
->
outputBytes
;
callRsp
->
newStateBytes
=
*
(
int32_t
*
)
buf
;
buf
+=
sizeof
(
int32_t
);
pUdfInfo->funcs[TSDB_UDF_FUNC_DESTROY] = taosLoadSym(pUdfInfo->handle, getUdfFuncName(funcname, pUdfInfo->name, TSDB_UDF_FUNC_DESTROY));
callRsp
->
newState
=
buf
;
buf
+=
callRsp
->
newStateBytes
;
if (pUdfInfo->funcs[TSDB_UDF_FUNC_INIT]) {
rsp
->
subRsp
=
callRsp
;
return (*(udfInitFunc)pUdfInfo->funcs[TSDB_UDF_FUNC_INIT])(&pUdfInfo->init);
break
;
}
case
UDF_TASK_TEARDOWN
:
{
SUdfTeardownResponse
*
teardownRsp
=
(
SUdfTeardownResponse
*
)
malloc
(
sizeof
(
SUdfTeardownResponse
));
rsp
->
subRsp
=
teardownRsp
;
break
;
}
default:
break
;
}
}
if
(
buf
-
bufMsg
!=
bufLen
)
{
debugPrint
(
"%s"
,
"can not decode response"
);
free
(
rsp
->
subRsp
);
free
(
rsp
);
return
-
1
;
}
}
*
pResponse
=
rsp
;
return
0
;
}
return TSDB_CODE_SUCCESS;
void
onUdfdExit
(
uv_process_t
*
req
,
int64_t
exit_status
,
int
term_signal
)
{
debugPrint
(
"Process exited with status %"
PRId64
", signal %d"
,
exit_status
,
term_signal
);
uv_close
((
uv_handle_t
*
)
req
,
NULL
);
//TODO: restart the udfd process
}
}
void destroyUdfInfo(SUdfInfo* pUdfInfo) {
void
onUdfcPipeClose
(
uv_handle_t
*
handle
)
{
if (pUdfInfo == NULL) {
SClientUvConn
*
conn
=
handle
->
data
;
return;
if
(
!
udfTaskQueueIsEmpty
(
&
conn
->
taskQueue
))
{
SClientUvTaskNode
*
task
=
udfTaskQueueHeadTask
(
&
conn
->
taskQueue
);
task
->
errCode
=
0
;
uv_sem_post
(
&
task
->
taskSem
);
}
}
if (pUdfInfo->funcs[TSDB_UDF_FUNC_DESTROY]) {
free
(
conn
->
readBuf
.
buf
);
if (pUdfInfo->isScript) {
free
(
conn
);
(*(scriptDestroyFunc)pUdfInfo->funcs[TSDB_UDF_FUNC_DESTROY])(pUdfInfo->pScriptCtx);
free
((
uv_pipe_t
*
)
handle
);
tfree(pUdfInfo->content);
}else{
}
(*(udfDestroyFunc)pUdfInfo->funcs[TSDB_UDF_FUNC_DESTROY])(&pUdfInfo->init);
int32_t
udfcGetUvTaskResponseResult
(
SClientUdfTask
*
task
,
SClientUvTaskNode
*
uvTask
)
{
debugPrint
(
"%s"
,
"get uv task result"
);
if
(
uvTask
->
type
==
UV_TASK_REQ_RSP
)
{
if
(
uvTask
->
rspBuf
.
base
!=
NULL
)
{
SUdfResponse
*
rsp
;
decodeResponse
(
uvTask
->
rspBuf
.
base
,
uvTask
->
rspBuf
.
len
,
&
rsp
);
task
->
errCode
=
rsp
->
code
;
switch
(
task
->
type
)
{
case
UDF_TASK_SETUP
:
{
//TODO: copy or not
task
->
_setup
.
rsp
=
*
(
SUdfSetupResponse
*
)
(
rsp
->
subRsp
);
break
;
}
case
UDF_TASK_CALL
:
{
task
->
_call
.
rsp
=
*
(
SUdfCallResponse
*
)
(
rsp
->
subRsp
);
//TODO: copy or not
break
;
}
case
UDF_TASK_TEARDOWN
:
{
task
->
_teardown
.
rsp
=
*
(
SUdfTeardownResponse
*
)
(
rsp
->
subRsp
);
//TODO: copy or not?
break
;
}
default:
{
break
;
}
}
}
}
tfree(pUdfInfo->name);
// TODO: the call buffer is setup and freed by udf invocation
free
(
uvTask
->
rspBuf
.
base
);
free
(
rsp
->
subRsp
);
free
(
rsp
);
}
else
{
task
->
errCode
=
uvTask
->
errCode
;
}
}
else
if
(
uvTask
->
type
==
UV_TASK_CONNECT
)
{
task
->
errCode
=
uvTask
->
errCode
;
}
else
if
(
uvTask
->
type
==
UV_TASK_DISCONNECT
)
{
task
->
errCode
=
uvTask
->
errCode
;
}
return
0
;
}
if (pUdfInfo->path) {
void
udfcAllocateBuffer
(
uv_handle_t
*
handle
,
size_t
suggestedSize
,
uv_buf_t
*
buf
)
{
unlink(pUdfInfo->path);
debugPrint
(
"%s"
,
"client allocate buffer to receive from pipe"
);
SClientUvConn
*
conn
=
handle
->
data
;
SClientConnBuf
*
connBuf
=
&
conn
->
readBuf
;
int32_t
msgHeadSize
=
sizeof
(
int32_t
)
+
sizeof
(
int64_t
);
if
(
connBuf
->
cap
==
0
)
{
connBuf
->
buf
=
malloc
(
msgHeadSize
);
if
(
connBuf
->
buf
)
{
connBuf
->
len
=
0
;
connBuf
->
cap
=
msgHeadSize
;
connBuf
->
total
=
-
1
;
buf
->
base
=
connBuf
->
buf
;
buf
->
len
=
connBuf
->
cap
;
}
else
{
//TODO: log error
buf
->
base
=
NULL
;
buf
->
len
=
0
;
}
}
else
{
connBuf
->
cap
=
connBuf
->
total
>
connBuf
->
cap
?
connBuf
->
total
:
connBuf
->
cap
;
void
*
resultBuf
=
realloc
(
connBuf
->
buf
,
connBuf
->
cap
);
if
(
resultBuf
)
{
connBuf
->
buf
=
resultBuf
;
buf
->
base
=
connBuf
->
buf
+
connBuf
->
len
;
buf
->
len
=
connBuf
->
cap
-
connBuf
->
len
;
}
else
{
//TODO: log error free connBuf->buf
buf
->
base
=
NULL
;
buf
->
len
=
0
;
}
}
}
tfree(pUdfInfo->path);
debugPrint
(
"
\t
conn buf cap - len - total : %d - %d - %d"
,
connBuf
->
cap
,
connBuf
->
len
,
connBuf
->
total
);
tfree(pUdfInfo->content);
taosCloseDll(pUdfInfo->handle);
}
tfree(pUdfInfo);
bool
isUdfcUvMsgComplete
(
SClientConnBuf
*
connBuf
)
{
if
(
connBuf
->
total
==
-
1
&&
connBuf
->
len
>=
sizeof
(
int32_t
))
{
connBuf
->
total
=
*
(
int32_t
*
)
(
connBuf
->
buf
);
}
if
(
connBuf
->
len
==
connBuf
->
cap
&&
connBuf
->
total
==
connBuf
->
cap
)
{
return
true
;
}
return
false
;
}
}
void doInvokeUdf(struct SUdfInfo* pUdfInfo, SqlFunctionCtx *pCtx, int32_t idx, int32_t type) {
void
udfcUvHandleRsp
(
SClientUvConn
*
conn
)
{
int32_t output = 0;
SClientConnBuf
*
connBuf
=
&
conn
->
readBuf
;
int64_t
seqNum
=
*
(
int64_t
*
)
(
connBuf
->
buf
+
sizeof
(
int32_t
));
// msglen int32_t then seqnum
if (
pUdfInfo == NULL || pUdfInfo->funcs[type] == NULL
) {
if
(
udfTaskQueueIsEmpty
(
&
conn
->
taskQueue
)
)
{
//
qError("empty udf function, type:%d", type);
//
LOG error
return
;
return
;
}
}
bool
found
=
false
;
SClientUvTaskNode
*
taskFound
=
NULL
;
SClientUvTaskNode
*
task
=
udfTaskQueueNext
(
&
conn
->
taskQueue
);
while
(
task
!=
&
conn
->
taskQueue
)
{
if
(
task
->
seqNum
==
seqNum
)
{
if
(
found
==
false
)
{
found
=
true
;
taskFound
=
task
;
}
else
{
//LOG error;
continue
;
}
}
task
=
udfTaskQueueNext
(
task
);
}
// //qDebug("invoke udf function:%s,%p", pUdfInfo->name, pUdfInfo->funcs[type]);
if
(
taskFound
)
{
taskFound
->
rspBuf
=
uv_buf_init
(
connBuf
->
buf
,
connBuf
->
len
);
switch (type) {
udfTaskQueueRemoveTask
(
taskFound
);
case TSDB_UDF_FUNC_NORMAL:
uv_sem_post
(
&
taskFound
->
taskSem
);
if (pUdfInfo->isScript) {
(*(scriptNormalFunc)pUdfInfo->funcs[TSDB_UDF_FUNC_NORMAL])(pUdfInfo->pScriptCtx,
(char *)pCtx->pInput + idx * pCtx->inputType, pCtx->inputType, pCtx->inputBytes, pCtx->size, pCtx->ptsList, pCtx->startTs, pCtx->pOutput,
(char *)pCtx->ptsOutputBuf, &output, pCtx->resDataInfo.type, pCtx->resDataInfo.bytes);
}
else
{
}
else
{
SResultRowEntryInfo *pResInfo = GET_RES_INFO(pCtx);
//LOG error
}
connBuf
->
buf
=
NULL
;
connBuf
->
total
=
-
1
;
connBuf
->
len
=
0
;
connBuf
->
cap
=
0
;
}
void *interBuf = (void *)GET_ROWCELL_INTERBUF(pResInfo);
void
udfcUvHandleError
(
SClientUvConn
*
conn
)
{
uv_close
((
uv_handle_t
*
)
conn
->
pipe
,
onUdfcPipeClose
);
}
(*(udfNormalFunc)pUdfInfo->funcs[TSDB_UDF_FUNC_NORMAL])((char *)pCtx->pInput + idx * pCtx->inputType, pCtx->inputType, pCtx->inputBytes, pCtx->size, pCtx->ptsList,
void
onUdfcRead
(
uv_stream_t
*
client
,
ssize_t
nread
,
const
uv_buf_t
*
buf
)
{
pCtx->pOutput, interBuf, (char *)pCtx->ptsOutputBuf, &output, pCtx->resDataInfo.type, pCtx->resDataInfo.bytes, &pUdfInfo->init
);
debugPrint
(
"%s, nread: %zd"
,
"client read from pipe"
,
nread
);
}
if
(
nread
==
0
)
return
;
if (pUdfInfo->funcType == TSDB_FUNC_TYPE_AGGREGATE) {
SClientUvConn
*
conn
=
client
->
data
;
pCtx->resultInfo->numOfRes = output;
SClientConnBuf
*
connBuf
=
&
conn
->
readBuf
;
} else {
if
(
nread
>
0
)
{
pCtx->resultInfo->numOfRes += output;
connBuf
->
len
+=
nread
;
if
(
isUdfcUvMsgComplete
(
connBuf
))
{
udfcUvHandleRsp
(
conn
);
}
}
if (pCtx->resultInfo->numOfRes > 0) {
}
pCtx->resultInfo->hasResult = DATA_SET_FLAG;
if
(
nread
<
0
)
{
debugPrint
(
"
\t
client read error: %s"
,
uv_strerror
(
nread
));
if
(
nread
==
UV_EOF
)
{
//TODO:
}
udfcUvHandleError
(
conn
);
}
}
break;
}
case TSDB_UDF_FUNC_MERGE:
void
onUdfClientWrite
(
uv_write_t
*
write
,
int
status
)
{
if (pUdfInfo->isScript) {
debugPrint
(
"%s"
,
"after writing to pipe"
);
(*(scriptMergeFunc)pUdfInfo->funcs[TSDB_UDF_FUNC_MERGE])(pUdfInfo->pScriptCtx, pCtx->pInput, pCtx->size, pCtx->pOutput, &output);
SClientUvTaskNode
*
uvTask
=
write
->
data
;
if
(
status
==
0
)
{
uv_pipe_t
*
pipe
=
uvTask
->
pipe
;
SClientUvConn
*
conn
=
pipe
->
data
;
udfTaskQueueInsertTail
(
&
conn
->
taskQueue
,
uvTask
);
}
else
{
}
else
{
(*(udfMergeFunc)pUdfInfo->funcs[TSDB_UDF_FUNC_MERGE])(pCtx->pInput, pCtx->size, pCtx->pOutput, &output, &pUdfInfo->init)
;
//TODO Log error
;
}
}
debugPrint
(
"
\t
length:%zu"
,
uvTask
->
reqBuf
.
len
);
free
(
write
);
free
(
uvTask
->
reqBuf
.
base
);
}
// set the output value exist
void
onUdfClientConnect
(
uv_connect_t
*
connect
,
int
status
)
{
pCtx->resultInfo->numOfRes = output;
SClientUvTaskNode
*
uvTask
=
connect
->
data
;
if (output > 0) {
uvTask
->
errCode
=
status
;
pCtx->resultInfo->hasResult = DATA_SET_FLAG;
if
(
status
!=
0
)
{
//TODO: LOG error
}
}
uv_read_start
((
uv_stream_t
*
)
uvTask
->
pipe
,
udfcAllocateBuffer
,
onUdfcRead
);
free
(
connect
);
uv_sem_post
(
&
uvTask
->
taskSem
);
}
break;
int32_t
createUdfcUvTask
(
SClientUdfTask
*
task
,
int8_t
uvTaskType
,
SClientUvTaskNode
**
pUvTask
)
{
SClientUvTaskNode
*
uvTask
=
calloc
(
1
,
sizeof
(
SClientUvTaskNode
));
case TSDB_UDF_FUNC_FINALIZE: {
uvTask
->
type
=
uvTaskType
;
SResultRowEntryInfo *pResInfo = GET_RES_INFO(pCtx);
void *interBuf = (void *)GET_ROWCELL_INTERBUF(pResInfo);
if
(
uvTaskType
==
UV_TASK_CONNECT
)
{
if (pUdfInfo->isScript) {
}
else
if
(
uvTaskType
==
UV_TASK_REQ_RSP
)
{
(*(scriptFinalizeFunc)pUdfInfo->funcs[TSDB_UDF_FUNC_FINALIZE])(pUdfInfo->pScriptCtx, pCtx->startTs, pCtx->pOutput, &output);
uvTask
->
pipe
=
task
->
session
->
udfSvcPipe
;
SUdfRequest
request
;
request
.
type
=
task
->
type
;
request
.
seqNum
=
gUdfTaskSeqNum
++
;
if
(
task
->
type
==
UDF_TASK_SETUP
)
{
request
.
subReq
=
&
task
->
_setup
.
req
;
request
.
type
=
UDF_TASK_SETUP
;
}
else
if
(
task
->
type
==
UDF_TASK_CALL
)
{
request
.
subReq
=
&
task
->
_call
.
req
;
request
.
type
=
UDF_TASK_CALL
;
}
else
if
(
task
->
type
==
UDF_TASK_TEARDOWN
)
{
request
.
subReq
=
&
task
->
_teardown
.
req
;
request
.
type
=
UDF_TASK_TEARDOWN
;
}
else
{
}
else
{
(*(udfFinalizeFunc)pUdfInfo->funcs[TSDB_UDF_FUNC_FINALIZE])(pCtx->pOutput, interBuf, &output, &pUdfInfo->init);
//TODO log and return error
}
}
// set the output value exist
char
*
buf
=
NULL
;
pCtx->resultInfo->numOfRes = output;
int32_t
bufLen
=
0
;
if (output > 0) {
encodeRequest
(
&
buf
,
&
bufLen
,
&
request
);
pCtx->resultInfo->hasResult = DATA_SET_FLAG;
uvTask
->
reqBuf
=
uv_buf_init
(
buf
,
bufLen
);
uvTask
->
seqNum
=
request
.
seqNum
;
}
else
if
(
uvTaskType
==
UV_TASK_DISCONNECT
)
{
uvTask
->
pipe
=
task
->
session
->
udfSvcPipe
;
}
}
uv_sem_init
(
&
uvTask
->
taskSem
,
0
);
*
pUvTask
=
uvTask
;
return
0
;
}
int32_t
queueUvUdfTask
(
SClientUvTaskNode
*
uvTask
)
{
debugPrint
(
"%s, %d"
,
"queue uv task"
,
uvTask
->
type
);
uv_mutex_lock
(
&
gUdfTaskQueueMutex
);
udfTaskQueueInsertTail
(
gUdfTaskQueue
,
uvTask
);
uv_mutex_unlock
(
&
gUdfTaskQueueMutex
);
uv_async_send
(
&
gUdfLoopTaskAync
);
uv_sem_wait
(
&
uvTask
->
taskSem
);
uv_sem_destroy
(
&
uvTask
->
taskSem
);
return
0
;
}
int32_t
startUvUdfTask
(
SClientUvTaskNode
*
uvTask
)
{
debugPrint
(
"%s, type %d"
,
"start uv task "
,
uvTask
->
type
);
switch
(
uvTask
->
type
)
{
case
UV_TASK_CONNECT
:
{
uv_pipe_t
*
pipe
=
malloc
(
sizeof
(
uv_pipe_t
));
uv_pipe_init
(
&
gUdfdLoop
,
pipe
,
0
);
uvTask
->
pipe
=
pipe
;
SClientUvConn
*
conn
=
malloc
(
sizeof
(
SClientUvConn
));
conn
->
pipe
=
pipe
;
conn
->
readBuf
.
len
=
0
;
conn
->
readBuf
.
cap
=
0
;
conn
->
readBuf
.
buf
=
0
;
conn
->
readBuf
.
total
=
-
1
;
udfTaskQueueInit
(
&
conn
->
taskQueue
);
pipe
->
data
=
conn
;
uv_connect_t
*
connReq
=
malloc
(
sizeof
(
uv_connect_t
));
connReq
->
data
=
uvTask
;
uv_pipe_connect
(
connReq
,
pipe
,
"udf.sock"
,
onUdfClientConnect
);
break
;
break
;
}
}
case
UV_TASK_REQ_RSP
:
{
uv_pipe_t
*
pipe
=
uvTask
->
pipe
;
uv_write_t
*
write
=
malloc
(
sizeof
(
uv_write_t
));
write
->
data
=
uvTask
;
uv_write
(
write
,
(
uv_stream_t
*
)
pipe
,
&
uvTask
->
reqBuf
,
1
,
onUdfClientWrite
);
break
;
}
}
case
UV_TASK_DISCONNECT
:
{
SClientUvConn
*
conn
=
uvTask
->
pipe
->
data
;
udfTaskQueueInsertTail
(
&
conn
->
taskQueue
,
uvTask
);
uv_close
((
uv_handle_t
*
)
uvTask
->
pipe
,
onUdfcPipeClose
);
break
;
}
default:
{
break
;
}
}
return
0
;
}
}
#endif
void
udfClientAsyncCb
(
uv_async_t
*
async
)
{
\ No newline at end of file
SClientUvTaskNode
node
;
SClientUvTaskQueue
q
=
&
node
;
udfTaskQueueInit
(
q
);
uv_mutex_lock
(
&
gUdfTaskQueueMutex
);
udfTaskQueueMove
(
gUdfTaskQueue
,
q
);
uv_mutex_unlock
(
&
gUdfTaskQueueMutex
);
while
(
!
udfTaskQueueIsEmpty
(
q
))
{
SClientUvTaskNode
*
task
=
udfTaskQueueHeadTask
(
q
);
udfTaskQueueRemoveTask
(
task
);
startUvUdfTask
(
task
);
}
}
void
udfStopAsyncCb
(
uv_async_t
*
async
)
{
uv_stop
(
&
gUdfdLoop
);
uv_loop_close
(
&
gUdfdLoop
);
}
void
startUdfd
(
void
*
argsThread
)
{
uv_loop_init
(
&
gUdfdLoop
);
//TODO: path
uv_process_options_t
options
;
static
char
path
[
256
]
=
{
0
};
size_t
cwdSize
;
uv_cwd
(
path
,
&
cwdSize
);
strcat
(
path
,
"./udfd"
);
char
*
args
[
2
]
=
{
path
,
NULL
};
options
.
args
=
args
;
options
.
file
=
path
;
options
.
exit_cb
=
onUdfdExit
;
int
err
=
uv_spawn
(
&
gUdfdLoop
,
&
gUdfdProcess
,
&
options
);
if
(
err
!=
0
)
{
debugPrint
(
"can not spawn udfd. path: %s, error: %s"
,
path
,
uv_strerror
(
err
));
}
uv_async_init
(
&
gUdfdLoop
,
&
gUdfLoopTaskAync
,
udfClientAsyncCb
);
uv_async_init
(
&
gUdfdLoop
,
&
gUdfLoopStopAsync
,
udfStopAsyncCb
);
uv_mutex_init
(
&
gUdfTaskQueueMutex
);
udfTaskQueueInit
(
gUdfTaskQueue
);
uv_barrier_wait
(
&
gUdfInitBarrier
);
uv_run
(
&
gUdfdLoop
,
UV_RUN_DEFAULT
);
}
int32_t
startUdfService
()
{
uv_barrier_init
(
&
gUdfInitBarrier
,
2
);
uv_thread_create
(
&
gUdfLoopThread
,
startUdfd
,
0
);
uv_barrier_wait
(
&
gUdfInitBarrier
);
return
0
;
}
int32_t
stopUdfService
()
{
uv_barrier_destroy
(
&
gUdfInitBarrier
);
uv_process_kill
(
&
gUdfdProcess
,
SIGINT
);
uv_async_send
(
&
gUdfLoopStopAsync
);
uv_mutex_destroy
(
&
gUdfTaskQueueMutex
);
uv_thread_join
(
&
gUdfLoopThread
);
return
0
;
}
int32_t
udfcRunUvTask
(
SClientUdfTask
*
task
,
int8_t
uvTaskType
)
{
SClientUvTaskNode
*
uvTask
=
NULL
;
createUdfcUvTask
(
task
,
uvTaskType
,
&
uvTask
);
queueUvUdfTask
(
uvTask
);
udfcGetUvTaskResponseResult
(
task
,
uvTask
);
if
(
uvTaskType
==
UV_TASK_CONNECT
)
{
task
->
session
->
udfSvcPipe
=
uvTask
->
pipe
;
}
free
(
uvTask
);
uvTask
=
NULL
;
return
task
->
errCode
;
}
int32_t
setupUdf
(
SUdfInfo
*
udfInfo
,
UdfHandle
*
handle
)
{
debugPrint
(
"%s"
,
"client setup udf"
);
SClientUdfTask
*
task
=
malloc
(
sizeof
(
SClientUdfTask
));
task
->
errCode
=
0
;
task
->
session
=
malloc
(
sizeof
(
SUdfUvSession
));
task
->
type
=
UDF_TASK_SETUP
;
SUdfSetupRequest
*
req
=
&
task
->
_setup
.
req
;
memcpy
(
req
->
udfName
,
udfInfo
->
udfName
,
16
);
req
->
path
=
udfInfo
->
path
;
req
->
pathSize
=
strlen
(
req
->
path
)
+
1
;
req
->
udfType
=
udfInfo
->
udfType
;
req
->
scriptType
=
udfInfo
->
scriptType
;
int32_t
errCode
=
udfcRunUvTask
(
task
,
UV_TASK_CONNECT
);
if
(
errCode
!=
0
)
{
//TODO: log error
return
-
1
;
}
udfcRunUvTask
(
task
,
UV_TASK_REQ_RSP
);
SUdfSetupResponse
*
rsp
=
&
task
->
_setup
.
rsp
;
task
->
session
->
severHandle
=
rsp
->
udfHandle
;
*
handle
=
task
->
session
;
int32_t
err
=
task
->
errCode
;
free
(
task
);
return
err
;
}
int32_t
callUdf
(
UdfHandle
handle
,
int8_t
step
,
char
*
state
,
int32_t
stateSize
,
SUdfDataBlock
input
,
char
**
newState
,
int32_t
*
newStateSize
,
SUdfDataBlock
*
output
)
{
debugPrint
(
"%s"
,
"client call udf"
);
SClientUdfTask
*
task
=
malloc
(
sizeof
(
SClientUdfTask
));
task
->
errCode
=
0
;
task
->
session
=
(
SUdfUvSession
*
)
handle
;
task
->
type
=
UDF_TASK_CALL
;
SUdfCallRequest
*
req
=
&
task
->
_call
.
req
;
req
->
state
=
state
;
req
->
stateBytes
=
stateSize
;
req
->
inputBytes
=
input
.
size
;
req
->
input
=
input
.
data
;
req
->
udfHandle
=
task
->
session
->
severHandle
;
req
->
step
=
step
;
udfcRunUvTask
(
task
,
UV_TASK_REQ_RSP
);
SUdfCallResponse
*
rsp
=
&
task
->
_call
.
rsp
;
*
newState
=
rsp
->
newState
;
*
newStateSize
=
rsp
->
newStateBytes
;
output
->
size
=
rsp
->
outputBytes
;
output
->
data
=
rsp
->
output
;
int32_t
err
=
task
->
errCode
;
free
(
task
);
return
err
;
}
int32_t
teardownUdf
(
UdfHandle
handle
)
{
debugPrint
(
"%s"
,
"client teardown udf"
);
SClientUdfTask
*
task
=
malloc
(
sizeof
(
SClientUdfTask
));
task
->
errCode
=
0
;
task
->
session
=
(
SUdfUvSession
*
)
handle
;
task
->
type
=
UDF_TASK_TEARDOWN
;
SUdfTeardownRequest
*
req
=
&
task
->
_teardown
.
req
;
req
->
udfHandle
=
task
->
session
->
severHandle
;
udfcRunUvTask
(
task
,
UV_TASK_REQ_RSP
);
SUdfTeardownResponse
*
rsp
=
&
task
->
_teardown
.
rsp
;
int32_t
err
=
task
->
errCode
;
udfcRunUvTask
(
task
,
UV_TASK_DISCONNECT
);
free
(
task
->
session
);
free
(
task
);
return
err
;
}
source/libs/function/src/udfd.c
0 → 100644
浏览文件 @
bdbf365e
/*
* 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 "uv.h"
#include "os.h"
#include "tlog.h"
#include "tudf.h"
#include "tudfInt.h"
static
uv_loop_t
*
loop
;
typedef
struct
SUdfdUvConn
{
uv_stream_t
*
client
;
char
*
inputBuf
;
int32_t
inputLen
;
int32_t
inputCap
;
int32_t
inputTotal
;
}
SUdfdUvConn
;
typedef
struct
SUvUdfWork
{
uv_stream_t
*
client
;
uv_buf_t
input
;
uv_buf_t
output
;
}
SUvUdfWork
;
typedef
struct
SUdf
{
int32_t
refCount
;
char
name
[
16
];
int8_t
type
;
uv_lib_t
lib
;
TUdfFunc
normalFunc
;
}
SUdf
;
//TODO: low priority: change name onxxx to xxxCb, and udfc or udfd as prefix
//TODO: add private udf structure.
typedef
struct
SUdfHandle
{
SUdf
*
udf
;
}
SUdfHandle
;
void
udfdProcessRequest
(
uv_work_t
*
req
)
{
SUvUdfWork
*
uvUdf
=
(
SUvUdfWork
*
)
(
req
->
data
);
SUdfRequest
*
request
=
NULL
;
decodeRequest
(
uvUdf
->
input
.
base
,
uvUdf
->
input
.
len
,
&
request
);
switch
(
request
->
type
)
{
case
UDF_TASK_SETUP
:
{
debugPrint
(
"%s"
,
"process setup request"
);
SUdf
*
udf
=
malloc
(
sizeof
(
SUdf
));
udf
->
refCount
=
0
;
SUdfSetupRequest
*
setup
=
request
->
subReq
;
strcpy
(
udf
->
name
,
setup
->
udfName
);
int
err
=
uv_dlopen
(
setup
->
path
,
&
udf
->
lib
);
if
(
err
!=
0
)
{
debugPrint
(
"can not load library %s. error: %s"
,
setup
->
path
,
uv_strerror
(
err
));
//TODO set error
}
char
normalFuncName
[
32
]
=
{
0
};
strcpy
(
normalFuncName
,
setup
->
udfName
);
//TODO error,
//TODO find all functions normal, init, destroy, normal, merge, finalize
uv_dlsym
(
&
udf
->
lib
,
normalFuncName
,
(
void
**
)
(
&
udf
->
normalFunc
));
SUdfHandle
*
handle
=
malloc
(
sizeof
(
SUdfHandle
));
handle
->
udf
=
udf
;
udf
->
refCount
++
;
//TODO: allocate private structure and call init function and set it to handle
SUdfResponse
*
rsp
=
malloc
(
sizeof
(
SUdfResponse
));
rsp
->
seqNum
=
request
->
seqNum
;
rsp
->
type
=
request
->
type
;
rsp
->
code
=
0
;
SUdfSetupResponse
*
subRsp
=
malloc
(
sizeof
(
SUdfSetupResponse
));
subRsp
->
udfHandle
=
(
int64_t
)
(
handle
);
rsp
->
subRsp
=
subRsp
;
char
*
buf
;
int32_t
len
;
encodeResponse
(
&
buf
,
&
len
,
rsp
);
uvUdf
->
output
=
uv_buf_init
(
buf
,
len
);
free
(
rsp
->
subRsp
);
free
(
rsp
);
free
(
request
->
subReq
);
free
(
request
);
free
(
uvUdf
->
input
.
base
);
break
;
}
case
UDF_TASK_CALL
:
{
debugPrint
(
"%s"
,
"process call request"
);
SUdfCallRequest
*
call
=
request
->
subReq
;
SUdfHandle
*
handle
=
(
SUdfHandle
*
)
(
call
->
udfHandle
);
SUdf
*
udf
=
handle
->
udf
;
char
*
newState
;
int32_t
newStateSize
;
SUdfDataBlock
input
=
{.
data
=
call
->
input
,
.
size
=
call
->
inputBytes
};
SUdfDataBlock
output
;
//TODO: call different functions according to the step
udf
->
normalFunc
(
call
->
step
,
call
->
state
,
call
->
stateBytes
,
input
,
&
newState
,
&
newStateSize
,
&
output
);
SUdfResponse
*
rsp
=
malloc
(
sizeof
(
SUdfResponse
));
rsp
->
seqNum
=
request
->
seqNum
;
rsp
->
type
=
request
->
type
;
rsp
->
code
=
0
;
SUdfCallResponse
*
subRsp
=
malloc
(
sizeof
(
SUdfCallResponse
));
subRsp
->
outputBytes
=
output
.
size
;
subRsp
->
output
=
output
.
data
;
subRsp
->
newStateBytes
=
newStateSize
;
subRsp
->
newState
=
newState
;
rsp
->
subRsp
=
subRsp
;
char
*
buf
;
int32_t
len
;
encodeResponse
(
&
buf
,
&
len
,
rsp
);
uvUdf
->
output
=
uv_buf_init
(
buf
,
len
);
free
(
rsp
->
subRsp
);
free
(
rsp
);
free
(
newState
);
free
(
output
.
data
);
free
(
request
->
subReq
);
free
(
request
);
free
(
uvUdf
->
input
.
base
);
break
;
}
case
UDF_TASK_TEARDOWN
:
{
debugPrint
(
"%s"
,
"process teardown request"
);
SUdfTeardownRequest
*
teardown
=
request
->
subReq
;
SUdfHandle
*
handle
=
(
SUdfHandle
*
)
(
teardown
->
udfHandle
);
SUdf
*
udf
=
handle
->
udf
;
udf
->
refCount
--
;
if
(
udf
->
refCount
==
0
)
{
uv_dlclose
(
&
udf
->
lib
);
}
free
(
udf
);
//TODO: call destroy and free udf private
free
(
handle
);
SUdfResponse
*
rsp
=
malloc
(
sizeof
(
SUdfResponse
));
rsp
->
seqNum
=
request
->
seqNum
;
rsp
->
type
=
request
->
type
;
rsp
->
code
=
0
;
SUdfTeardownResponse
*
subRsp
=
malloc
(
sizeof
(
SUdfTeardownResponse
));
rsp
->
subRsp
=
subRsp
;
char
*
buf
;
int32_t
len
;
encodeResponse
(
&
buf
,
&
len
,
rsp
);
uvUdf
->
output
=
uv_buf_init
(
buf
,
len
);
free
(
rsp
->
subRsp
);
free
(
rsp
);
free
(
request
->
subReq
);
free
(
request
);
free
(
uvUdf
->
input
.
base
);
break
;
}
default:
{
break
;
}
}
}
void
udfdOnWrite
(
uv_write_t
*
req
,
int
status
)
{
debugPrint
(
"%s"
,
"after writing to pipe"
);
if
(
status
<
0
)
{
debugPrint
(
"Write error %s"
,
uv_err_name
(
status
));
}
SUvUdfWork
*
work
=
(
SUvUdfWork
*
)
req
->
data
;
debugPrint
(
"
\t
length: %zu"
,
work
->
output
.
len
);
free
(
work
->
output
.
base
);
free
(
work
);
free
(
req
);
}
void
udfdSendResponse
(
uv_work_t
*
work
,
int
status
)
{
debugPrint
(
"%s"
,
"send response"
);
SUvUdfWork
*
udfWork
=
(
SUvUdfWork
*
)
(
work
->
data
);
uv_write_t
*
write_req
=
malloc
(
sizeof
(
uv_write_t
));
write_req
->
data
=
udfWork
;
uv_write
(
write_req
,
udfWork
->
client
,
&
udfWork
->
output
,
1
,
udfdOnWrite
);
free
(
work
);
}
void
udfdAllocBuffer
(
uv_handle_t
*
handle
,
size_t
suggestedSize
,
uv_buf_t
*
buf
)
{
debugPrint
(
"%s"
,
"allocate buffer for read"
);
SUdfdUvConn
*
ctx
=
handle
->
data
;
int32_t
msgHeadSize
=
sizeof
(
int32_t
)
+
sizeof
(
int64_t
);
if
(
ctx
->
inputCap
==
0
)
{
ctx
->
inputBuf
=
malloc
(
msgHeadSize
);
if
(
ctx
->
inputBuf
)
{
ctx
->
inputLen
=
0
;
ctx
->
inputCap
=
msgHeadSize
;
ctx
->
inputTotal
=
-
1
;
buf
->
base
=
ctx
->
inputBuf
;
buf
->
len
=
ctx
->
inputCap
;
}
else
{
//TODO: log error
buf
->
base
=
NULL
;
buf
->
len
=
0
;
}
}
else
{
ctx
->
inputCap
=
ctx
->
inputTotal
>
ctx
->
inputCap
?
ctx
->
inputTotal
:
ctx
->
inputCap
;
void
*
inputBuf
=
realloc
(
ctx
->
inputBuf
,
ctx
->
inputCap
);
if
(
inputBuf
)
{
ctx
->
inputBuf
=
inputBuf
;
buf
->
base
=
ctx
->
inputBuf
+
ctx
->
inputLen
;
buf
->
len
=
ctx
->
inputCap
-
ctx
->
inputLen
;
}
else
{
//TODO: log error
buf
->
base
=
NULL
;
buf
->
len
=
0
;
}
}
debugPrint
(
"
\t
input buf cap - len - total : %d - %d - %d"
,
ctx
->
inputCap
,
ctx
->
inputLen
,
ctx
->
inputTotal
);
}
bool
isUdfdUvMsgComplete
(
SUdfdUvConn
*
pipe
)
{
if
(
pipe
->
inputTotal
==
-
1
&&
pipe
->
inputLen
>=
sizeof
(
int32_t
))
{
pipe
->
inputTotal
=
*
(
int32_t
*
)
(
pipe
->
inputBuf
);
}
if
(
pipe
->
inputLen
==
pipe
->
inputCap
&&
pipe
->
inputTotal
==
pipe
->
inputCap
)
{
return
true
;
}
return
false
;
}
void
udfdHandleRequest
(
SUdfdUvConn
*
conn
)
{
uv_work_t
*
work
=
malloc
(
sizeof
(
uv_work_t
));
SUvUdfWork
*
udfWork
=
malloc
(
sizeof
(
SUvUdfWork
));
udfWork
->
client
=
conn
->
client
;
udfWork
->
input
=
uv_buf_init
(
conn
->
inputBuf
,
conn
->
inputLen
);
conn
->
inputBuf
=
NULL
;
conn
->
inputLen
=
0
;
conn
->
inputCap
=
0
;
conn
->
inputTotal
=
-
1
;
work
->
data
=
udfWork
;
uv_queue_work
(
loop
,
work
,
udfdProcessRequest
,
udfdSendResponse
);
}
void
udfdPipeCloseCb
(
uv_handle_t
*
pipe
)
{
SUdfdUvConn
*
conn
=
pipe
->
data
;
free
(
conn
->
client
);
free
(
conn
->
inputBuf
);
free
(
conn
);
}
void
udfdUvHandleError
(
SUdfdUvConn
*
conn
)
{
uv_close
((
uv_handle_t
*
)
conn
->
client
,
udfdPipeCloseCb
);
}
void
udfdPipeRead
(
uv_stream_t
*
client
,
ssize_t
nread
,
const
uv_buf_t
*
buf
)
{
debugPrint
(
"%s, nread: %zd"
,
"read from pipe"
,
nread
);
if
(
nread
==
0
)
return
;
SUdfdUvConn
*
conn
=
client
->
data
;
if
(
nread
>
0
)
{
conn
->
inputLen
+=
nread
;
if
(
isUdfdUvMsgComplete
(
conn
))
{
udfdHandleRequest
(
conn
);
}
else
{
//log error or continue;
}
return
;
}
if
(
nread
<
0
)
{
debugPrint
(
"Read error %s"
,
uv_err_name
(
nread
));
if
(
nread
==
UV_EOF
)
{
//TODO check more when close
}
else
{
}
udfdUvHandleError
(
conn
);
}
}
void
udfdOnNewConnection
(
uv_stream_t
*
server
,
int
status
)
{
debugPrint
(
"%s"
,
"on new connection"
);
if
(
status
<
0
)
{
// TODO
return
;
}
uv_pipe_t
*
client
=
(
uv_pipe_t
*
)
malloc
(
sizeof
(
uv_pipe_t
));
uv_pipe_init
(
loop
,
client
,
0
);
if
(
uv_accept
(
server
,
(
uv_stream_t
*
)
client
)
==
0
)
{
SUdfdUvConn
*
ctx
=
malloc
(
sizeof
(
SUdfdUvConn
));
ctx
->
client
=
(
uv_stream_t
*
)
client
;
ctx
->
inputBuf
=
0
;
ctx
->
inputLen
=
0
;
ctx
->
inputCap
=
0
;
client
->
data
=
ctx
;
ctx
->
client
=
(
uv_stream_t
*
)
client
;
uv_read_start
((
uv_stream_t
*
)
client
,
udfdAllocBuffer
,
udfdPipeRead
);
}
else
{
uv_close
((
uv_handle_t
*
)
client
,
NULL
);
}
}
void
removeListeningPipe
(
int
sig
)
{
uv_fs_t
req
;
uv_fs_unlink
(
loop
,
&
req
,
"udf.sock"
,
NULL
);
exit
(
0
);
}
int
main
()
{
debugPrint
(
"libuv version: %x"
,
UV_VERSION_HEX
);
loop
=
uv_default_loop
();
uv_fs_t
req
;
uv_fs_unlink
(
loop
,
&
req
,
"udf.sock"
,
NULL
);
uv_pipe_t
server
;
uv_pipe_init
(
loop
,
&
server
,
0
);
signal
(
SIGINT
,
removeListeningPipe
);
int
r
;
if
((
r
=
uv_pipe_bind
(
&
server
,
"udf.sock"
)))
{
debugPrint
(
"Bind error %s
\n
"
,
uv_err_name
(
r
));
removeListeningPipe
(
0
);
return
1
;
}
if
((
r
=
uv_listen
((
uv_stream_t
*
)
&
server
,
128
,
udfdOnNewConnection
)))
{
debugPrint
(
"Listen error %s"
,
uv_err_name
(
r
));
return
2
;
}
uv_run
(
loop
,
UV_RUN_DEFAULT
);
uv_loop_close
(
loop
);
}
source/libs/function/test/runUdf.c
0 → 100644
浏览文件 @
bdbf365e
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "uv.h"
#include "tudf.h"
int
main
(
int
argc
,
char
*
argv
[])
{
startUdfService
();
uv_sleep
(
1000
);
char
path
[
256
]
=
{
0
};
size_t
cwdSize
=
256
;
int
err
=
uv_cwd
(
path
,
&
cwdSize
);
if
(
err
!=
0
)
{
fprintf
(
stderr
,
"err cwd: %s
\n
"
,
uv_strerror
(
err
));
return
err
;
}
fprintf
(
stdout
,
"current working directory:%s
\n
"
,
path
);
strcat
(
path
,
"/libudf1.so"
);
SUdfInfo
udfInfo
=
{.
udfName
=
"udf1"
,
.
path
=
path
};
UdfHandle
handle
;
setupUdf
(
&
udfInfo
,
&
handle
);
//char state[5000000] = "state";
//char input[5000000] = "input";
int
dataSize
=
500
;
int
callCount
=
2
;
if
(
argc
>
1
)
dataSize
=
atoi
(
argv
[
1
]);
if
(
argc
>
2
)
callCount
=
atoi
(
argv
[
2
]);
char
*
state
=
malloc
(
dataSize
);
char
*
input
=
malloc
(
dataSize
);
SUdfDataBlock
blockInput
=
{.
data
=
input
,
.
size
=
dataSize
};
SUdfDataBlock
blockOutput
;
char
*
newState
;
int32_t
newStateSize
;
for
(
int
l
=
0
;
l
<
callCount
;
++
l
)
{
callUdf
(
handle
,
0
,
state
,
dataSize
,
blockInput
,
&
newState
,
&
newStateSize
,
&
blockOutput
);
}
free
(
state
);
free
(
input
);
teardownUdf
(
handle
);
stopUdfService
();
}
source/libs/function/test/udf1.c
0 → 100644
浏览文件 @
bdbf365e
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "tudf.h"
void
udf1
(
int8_t
step
,
char
*
state
,
int32_t
stateSize
,
SUdfDataBlock
input
,
char
**
newState
,
int32_t
*
newStateSize
,
SUdfDataBlock
*
output
)
{
fprintf
(
stdout
,
"%s, step:%d
\n
"
,
"udf function called"
,
step
);
char
*
newStateBuf
=
malloc
(
stateSize
);
memcpy
(
newStateBuf
,
state
,
stateSize
);
*
newState
=
newStateBuf
;
*
newStateSize
=
stateSize
;
char
*
outputBuf
=
malloc
(
input
.
size
);
memcpy
(
outputBuf
,
input
.
data
,
input
.
size
);
output
->
data
=
outputBuf
;
output
->
size
=
input
.
size
;
return
;
}
source/libs/nodes/src/nodesCloneFuncs.c
浏览文件 @
bdbf365e
...
@@ -141,12 +141,12 @@ static SNode* valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) {
...
@@ -141,12 +141,12 @@ static SNode* valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) {
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_VARBINARY
:
case
TSDB_DATA_TYPE_VARBINARY
:
pDst
->
datum
.
p
=
malloc
(
pSrc
->
node
.
resType
.
bytes
+
VARSTR_HEADER_SIZE
);
pDst
->
datum
.
p
=
malloc
(
pSrc
->
node
.
resType
.
bytes
+
VARSTR_HEADER_SIZE
+
1
);
if
(
NULL
==
pDst
->
datum
.
p
)
{
if
(
NULL
==
pDst
->
datum
.
p
)
{
nodesDestroyNode
(
pDst
);
nodesDestroyNode
(
pDst
);
return
NULL
;
return
NULL
;
}
}
memcpy
(
pDst
->
datum
.
p
,
pSrc
->
datum
.
p
,
pSrc
->
node
.
resType
.
bytes
+
VARSTR_HEADER_SIZE
);
memcpy
(
pDst
->
datum
.
p
,
pSrc
->
datum
.
p
,
pSrc
->
node
.
resType
.
bytes
+
VARSTR_HEADER_SIZE
+
1
);
break
;
break
;
case
TSDB_DATA_TYPE_JSON
:
case
TSDB_DATA_TYPE_JSON
:
case
TSDB_DATA_TYPE_DECIMAL
:
case
TSDB_DATA_TYPE_DECIMAL
:
...
...
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
bdbf365e
...
@@ -1480,7 +1480,7 @@ static int32_t jsonToDatum(const SJson* pJson, void* pObj) {
...
@@ -1480,7 +1480,7 @@ static int32_t jsonToDatum(const SJson* pJson, void* pObj) {
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_VARBINARY
:
{
case
TSDB_DATA_TYPE_VARBINARY
:
{
pNode
->
datum
.
p
=
calloc
(
1
,
pNode
->
node
.
resType
.
bytes
);
pNode
->
datum
.
p
=
calloc
(
1
,
pNode
->
node
.
resType
.
bytes
+
VARSTR_HEADER_SIZE
+
1
);
if
(
NULL
==
pNode
->
datum
.
p
)
{
if
(
NULL
==
pNode
->
datum
.
p
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
break
;
break
;
...
@@ -1807,6 +1807,45 @@ static int32_t groupingSetNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -1807,6 +1807,45 @@ static int32_t groupingSetNodeToJson(const void* pObj, SJson* pJson) {
return
code
;
return
code
;
}
}
static
const
char
*
jkIntervalWindowInterval
=
"Interval"
;
static
const
char
*
jkIntervalWindowOffset
=
"Offset"
;
static
const
char
*
jkIntervalWindowSliding
=
"Sliding"
;
static
const
char
*
jkIntervalWindowFill
=
"Fill"
;
static
int32_t
intervalWindowNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SIntervalWindowNode
*
pNode
=
(
const
SIntervalWindowNode
*
)
pObj
;
int32_t
code
=
tjsonAddObject
(
pJson
,
jkIntervalWindowInterval
,
nodeToJson
,
pNode
->
pInterval
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddObject
(
pJson
,
jkIntervalWindowOffset
,
nodeToJson
,
pNode
->
pOffset
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddObject
(
pJson
,
jkIntervalWindowSliding
,
nodeToJson
,
pNode
->
pSliding
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddObject
(
pJson
,
jkIntervalWindowFill
,
nodeToJson
,
pNode
->
pFill
);
}
return
code
;
}
static
int32_t
jsonToIntervalWindowNode
(
const
SJson
*
pJson
,
void
*
pObj
)
{
SIntervalWindowNode
*
pNode
=
(
SIntervalWindowNode
*
)
pObj
;
int32_t
code
=
jsonToNodeObject
(
pJson
,
jkIntervalWindowInterval
,
&
pNode
->
pInterval
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkIntervalWindowOffset
,
&
pNode
->
pOffset
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkIntervalWindowSliding
,
&
pNode
->
pSliding
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkIntervalWindowFill
,
&
pNode
->
pFill
);
}
return
code
;
}
static
const
char
*
jkNodeListDataType
=
"DataType"
;
static
const
char
*
jkNodeListDataType
=
"DataType"
;
static
const
char
*
jkNodeListNodeList
=
"NodeList"
;
static
const
char
*
jkNodeListNodeList
=
"NodeList"
;
...
@@ -2119,8 +2158,9 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -2119,8 +2158,9 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
case
QUERY_NODE_LIMIT
:
case
QUERY_NODE_LIMIT
:
case
QUERY_NODE_STATE_WINDOW
:
case
QUERY_NODE_STATE_WINDOW
:
case
QUERY_NODE_SESSION_WINDOW
:
case
QUERY_NODE_SESSION_WINDOW
:
case
QUERY_NODE_INTERVAL_WINDOW
:
break
;
break
;
case
QUERY_NODE_INTERVAL_WINDOW
:
return
intervalWindowNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_NODE_LIST
:
case
QUERY_NODE_NODE_LIST
:
return
nodeListNodeToJson
(
pObj
,
pJson
);
return
nodeListNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_FILL
:
case
QUERY_NODE_FILL
:
...
@@ -2222,7 +2262,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
...
@@ -2222,7 +2262,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
// case QUERY_NODE_LIMIT:
// case QUERY_NODE_LIMIT:
// case QUERY_NODE_STATE_WINDOW:
// case QUERY_NODE_STATE_WINDOW:
// case QUERY_NODE_SESSION_WINDOW:
// case QUERY_NODE_SESSION_WINDOW:
// case QUERY_NODE_INTERVAL_WINDOW:
case
QUERY_NODE_INTERVAL_WINDOW
:
return
jsonToIntervalWindowNode
(
pJson
,
pObj
);
case
QUERY_NODE_NODE_LIST
:
case
QUERY_NODE_NODE_LIST
:
return
jsonToNodeListNode
(
pJson
,
pObj
);
return
jsonToNodeListNode
(
pJson
,
pObj
);
// case QUERY_NODE_FILL:
// case QUERY_NODE_FILL:
...
...
source/libs/parser/inc/parAst.h
浏览文件 @
bdbf365e
...
@@ -150,9 +150,9 @@ SNode* createDropUserStmt(SAstCreateContext* pCxt, SToken* pUserName);
...
@@ -150,9 +150,9 @@ SNode* createDropUserStmt(SAstCreateContext* pCxt, SToken* pUserName);
SNode
*
createCreateDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pFqdn
,
const
SToken
*
pPort
);
SNode
*
createCreateDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pFqdn
,
const
SToken
*
pPort
);
SNode
*
createDropDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnode
);
SNode
*
createDropDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnode
);
SNode
*
createAlterDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnode
,
const
SToken
*
pConfig
,
const
SToken
*
pValue
);
SNode
*
createAlterDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnode
,
const
SToken
*
pConfig
,
const
SToken
*
pValue
);
SNode
*
createCreateIndexStmt
(
SAstCreateContext
*
pCxt
,
EIndexType
type
,
SToken
*
pIndexName
,
SToken
*
pTableName
,
SNodeList
*
pCols
,
SNode
*
pOptions
);
SNode
*
createCreateIndexStmt
(
SAstCreateContext
*
pCxt
,
EIndexType
type
,
bool
ignoreExists
,
SToken
*
pIndexName
,
SToken
*
pTableName
,
SNodeList
*
pCols
,
SNode
*
pOptions
);
SNode
*
createIndexOption
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pFuncs
,
SNode
*
pInterval
,
SNode
*
pOffset
,
SNode
*
pSliding
);
SNode
*
createIndexOption
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pFuncs
,
SNode
*
pInterval
,
SNode
*
pOffset
,
SNode
*
pSliding
);
SNode
*
createDropIndexStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pIndexName
,
SToken
*
pTableName
);
SNode
*
createDropIndexStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SToken
*
pIndexName
,
SToken
*
pTableName
);
SNode
*
createCreateQnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnodeId
);
SNode
*
createCreateQnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnodeId
);
SNode
*
createDropQnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnodeId
);
SNode
*
createDropQnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnodeId
);
SNode
*
createCreateTopicStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pTopicName
,
SNode
*
pQuery
,
const
SToken
*
pSubscribeDbName
);
SNode
*
createCreateTopicStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pTopicName
,
SNode
*
pQuery
,
const
SToken
*
pSubscribeDbName
);
...
...
source/libs/parser/inc/parInsertData.h
浏览文件 @
bdbf365e
...
@@ -118,7 +118,7 @@ static FORCE_INLINE void getMemRowAppendInfo(SSchema *pSchema, uint8_t rowType,
...
@@ -118,7 +118,7 @@ static FORCE_INLINE void getMemRowAppendInfo(SSchema *pSchema, uint8_t rowType,
}
}
static
FORCE_INLINE
int32_t
setBlockInfo
(
SSubmitBlk
*
pBlocks
,
STableDataBlocks
*
dataBuf
,
int32_t
numOfRows
)
{
static
FORCE_INLINE
int32_t
setBlockInfo
(
SSubmitBlk
*
pBlocks
,
STableDataBlocks
*
dataBuf
,
int32_t
numOfRows
)
{
pBlocks
->
tid
=
dataBuf
->
pTableMeta
->
suid
;
pBlocks
->
suid
=
(
TSDB_NORMAL_TABLE
==
dataBuf
->
pTableMeta
->
tableType
?
dataBuf
->
pTableMeta
->
uid
:
dataBuf
->
pTableMeta
->
suid
)
;
pBlocks
->
uid
=
dataBuf
->
pTableMeta
->
uid
;
pBlocks
->
uid
=
dataBuf
->
pTableMeta
->
uid
;
pBlocks
->
sversion
=
dataBuf
->
pTableMeta
->
sversion
;
pBlocks
->
sversion
=
dataBuf
->
pTableMeta
->
sversion
;
...
...
source/libs/parser/inc/sql.y
浏览文件 @
bdbf365e
...
@@ -313,10 +313,11 @@ func_name_list(A) ::= func_name_list(B) NK_COMMA col_name(C).
...
@@ -313,10 +313,11 @@ func_name_list(A) ::= func_name_list(B) NK_COMMA col_name(C).
func_name(A) ::= function_name(B). { A = createFunctionNode(pCxt, &B, NULL); }
func_name(A) ::= function_name(B). { A = createFunctionNode(pCxt, &B, NULL); }
/************************************************ create index ********************************************************/
/************************************************ create index ********************************************************/
cmd ::= CREATE SMA INDEX index_name(A) ON table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, &A, &B, NULL, C); }
cmd ::= CREATE SMA INDEX not_exists_opt(D)
cmd ::= CREATE FULLTEXT INDEX
index_name(A) ON table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, D, &A, &B, NULL, C); }
index_name(A) ON table_name(B) NK_LP col_name_list(C) NK_RP. { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, &A, &B, C, NULL); }
cmd ::= CREATE FULLTEXT INDEX not_exists_opt(D)
cmd ::= DROP INDEX index_name(A) ON table_name(B). { pCxt->pRootNode = createDropIndexStmt(pCxt, &A, &B); }
index_name(A) ON table_name(B) NK_LP col_name_list(C) NK_RP. { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, D, &A, &B, C, NULL); }
cmd ::= DROP INDEX exists_opt(C) index_name(A) ON table_name(B). { pCxt->pRootNode = createDropIndexStmt(pCxt, C, &A, &B); }
index_options(A) ::= . { A = NULL; }
index_options(A) ::= . { A = NULL; }
index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL
index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
bdbf365e
...
@@ -1160,13 +1160,14 @@ SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const
...
@@ -1160,13 +1160,14 @@ SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const
return
(
SNode
*
)
pStmt
;
return
(
SNode
*
)
pStmt
;
}
}
SNode
*
createCreateIndexStmt
(
SAstCreateContext
*
pCxt
,
EIndexType
type
,
SToken
*
pIndexName
,
SToken
*
pTableName
,
SNodeList
*
pCols
,
SNode
*
pOptions
)
{
SNode
*
createCreateIndexStmt
(
SAstCreateContext
*
pCxt
,
EIndexType
type
,
bool
ignoreExists
,
SToken
*
pIndexName
,
SToken
*
pTableName
,
SNodeList
*
pCols
,
SNode
*
pOptions
)
{
if
(
!
checkIndexName
(
pCxt
,
pIndexName
)
||
!
checkTableName
(
pCxt
,
pTableName
))
{
if
(
!
checkIndexName
(
pCxt
,
pIndexName
)
||
!
checkTableName
(
pCxt
,
pTableName
))
{
return
NULL
;
return
NULL
;
}
}
SCreateIndexStmt
*
pStmt
=
nodesMakeNode
(
QUERY_NODE_CREATE_INDEX_STMT
);
SCreateIndexStmt
*
pStmt
=
nodesMakeNode
(
QUERY_NODE_CREATE_INDEX_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
CHECK_OUT_OF_MEM
(
pStmt
);
pStmt
->
indexType
=
type
;
pStmt
->
indexType
=
type
;
pStmt
->
ignoreExists
=
ignoreExists
;
strncpy
(
pStmt
->
indexName
,
pIndexName
->
z
,
pIndexName
->
n
);
strncpy
(
pStmt
->
indexName
,
pIndexName
->
z
,
pIndexName
->
n
);
strncpy
(
pStmt
->
tableName
,
pTableName
->
z
,
pTableName
->
n
);
strncpy
(
pStmt
->
tableName
,
pTableName
->
z
,
pTableName
->
n
);
pStmt
->
pCols
=
pCols
;
pStmt
->
pCols
=
pCols
;
...
@@ -1184,12 +1185,13 @@ SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInt
...
@@ -1184,12 +1185,13 @@ SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInt
return
(
SNode
*
)
pOptions
;
return
(
SNode
*
)
pOptions
;
}
}
SNode
*
createDropIndexStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pIndexName
,
SToken
*
pTableName
)
{
SNode
*
createDropIndexStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SToken
*
pIndexName
,
SToken
*
pTableName
)
{
if
(
!
checkIndexName
(
pCxt
,
pIndexName
)
||
!
checkTableName
(
pCxt
,
pTableName
))
{
if
(
!
checkIndexName
(
pCxt
,
pIndexName
)
||
!
checkTableName
(
pCxt
,
pTableName
))
{
return
NULL
;
return
NULL
;
}
}
SDropIndexStmt
*
pStmt
=
nodesMakeNode
(
QUERY_NODE_DROP_INDEX_STMT
);
SDropIndexStmt
*
pStmt
=
nodesMakeNode
(
QUERY_NODE_DROP_INDEX_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
CHECK_OUT_OF_MEM
(
pStmt
);
pStmt
->
ignoreNotExists
=
ignoreNotExists
;
strncpy
(
pStmt
->
indexName
,
pIndexName
->
z
,
pIndexName
->
n
);
strncpy
(
pStmt
->
indexName
,
pIndexName
->
z
,
pIndexName
->
n
);
strncpy
(
pStmt
->
tableName
,
pTableName
->
z
,
pTableName
->
n
);
strncpy
(
pStmt
->
tableName
,
pTableName
->
z
,
pTableName
->
n
);
return
(
SNode
*
)
pStmt
;
return
(
SNode
*
)
pStmt
;
...
...
source/libs/parser/src/parInsert.c
浏览文件 @
bdbf365e
...
@@ -48,11 +48,6 @@
...
@@ -48,11 +48,6 @@
} \
} \
} while (0)
} while (0)
enum
{
TSDB_USE_SERVER_TS
=
0
,
TSDB_USE_CLI_TS
=
1
,
};
typedef
struct
SInsertParseContext
{
typedef
struct
SInsertParseContext
{
SParseContext
*
pComCxt
;
// input
SParseContext
*
pComCxt
;
// input
char
*
pSql
;
// input
char
*
pSql
;
// input
...
@@ -264,7 +259,7 @@ static void buildMsgHeader(STableDataBlocks* src, SVgDataBlocks* blocks) {
...
@@ -264,7 +259,7 @@ static void buildMsgHeader(STableDataBlocks* src, SVgDataBlocks* blocks) {
while
(
numOfBlocks
--
)
{
while
(
numOfBlocks
--
)
{
int32_t
dataLen
=
blk
->
dataLen
;
int32_t
dataLen
=
blk
->
dataLen
;
blk
->
uid
=
htobe64
(
blk
->
uid
);
blk
->
uid
=
htobe64
(
blk
->
uid
);
blk
->
tid
=
htonl
(
blk
->
t
id
);
blk
->
suid
=
htobe64
(
blk
->
su
id
);
blk
->
padding
=
htonl
(
blk
->
padding
);
blk
->
padding
=
htonl
(
blk
->
padding
);
blk
->
sversion
=
htonl
(
blk
->
sversion
);
blk
->
sversion
=
htonl
(
blk
->
sversion
);
blk
->
dataLen
=
htonl
(
blk
->
dataLen
);
blk
->
dataLen
=
htonl
(
blk
->
dataLen
);
...
@@ -303,20 +298,7 @@ static int32_t checkTimestamp(STableDataBlocks *pDataBlocks, const char *start)
...
@@ -303,20 +298,7 @@ static int32_t checkTimestamp(STableDataBlocks *pDataBlocks, const char *start)
}
}
TSKEY
k
=
*
(
TSKEY
*
)
start
;
TSKEY
k
=
*
(
TSKEY
*
)
start
;
if
(
k
<=
pDataBlocks
->
prevTS
)
{
if
(
k
==
INT64_MIN
)
{
if
(
pDataBlocks
->
tsSource
==
TSDB_USE_CLI_TS
)
{
return
TSDB_CODE_FAILED
;
// client time/server time can not be mixed
}
pDataBlocks
->
tsSource
=
TSDB_USE_SERVER_TS
;
}
else
{
if
(
pDataBlocks
->
tsSource
==
TSDB_USE_SERVER_TS
)
{
return
TSDB_CODE_FAILED
;
// client time/server time can not be mixed
}
pDataBlocks
->
tsSource
=
TSDB_USE_CLI_TS
;
}
if
(
k
<=
pDataBlocks
->
prevTS
&&
(
pDataBlocks
->
tsSource
==
TSDB_USE_CLI_TS
))
{
pDataBlocks
->
ordered
=
false
;
pDataBlocks
->
ordered
=
false
;
}
}
...
...
source/libs/parser/src/parInsertData.c
浏览文件 @
bdbf365e
...
@@ -141,7 +141,6 @@ static int32_t createDataBlock(size_t defaultSize, int32_t rowSize, int32_t star
...
@@ -141,7 +141,6 @@ static int32_t createDataBlock(size_t defaultSize, int32_t rowSize, int32_t star
dataBuf
->
prevTS
=
INT64_MIN
;
dataBuf
->
prevTS
=
INT64_MIN
;
dataBuf
->
rowSize
=
rowSize
;
dataBuf
->
rowSize
=
rowSize
;
dataBuf
->
size
=
startOffset
;
dataBuf
->
size
=
startOffset
;
dataBuf
->
tsSource
=
-
1
;
dataBuf
->
vgId
=
dataBuf
->
pTableMeta
->
vgId
;
dataBuf
->
vgId
=
dataBuf
->
pTableMeta
->
vgId
;
assert
(
defaultSize
>
0
&&
pTableMeta
!=
NULL
&&
dataBuf
->
pTableMeta
!=
NULL
);
assert
(
defaultSize
>
0
&&
pTableMeta
!=
NULL
&&
dataBuf
->
pTableMeta
!=
NULL
);
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
bdbf365e
...
@@ -383,7 +383,7 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
...
@@ -383,7 +383,7 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) {
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_VARBINARY
:
{
case
TSDB_DATA_TYPE_VARBINARY
:
{
pVal
->
datum
.
p
=
calloc
(
1
,
pVal
->
node
.
resType
.
bytes
+
VARSTR_HEADER_SIZE
);
pVal
->
datum
.
p
=
calloc
(
1
,
pVal
->
node
.
resType
.
bytes
+
VARSTR_HEADER_SIZE
+
1
);
if
(
NULL
==
pVal
->
datum
.
p
)
{
if
(
NULL
==
pVal
->
datum
.
p
)
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_OUT_OF_MEMORY
);
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_OUT_OF_MEMORY
);
}
}
...
@@ -1406,34 +1406,110 @@ static int32_t translateShowTables(STranslateContext* pCxt) {
...
@@ -1406,34 +1406,110 @@ static int32_t translateShowTables(STranslateContext* pCxt) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
translateCreateSmaIndex
(
STranslateContext
*
pCxt
,
SCreateIndexStmt
*
pStmt
)
{
static
int32_t
getSmaIndexDstVgId
(
STranslateContext
*
pCxt
,
char
*
pTableName
,
int32_t
*
pVgId
)
{
SVCreateTSmaReq
createSmaReq
=
{
0
};
SVgroupInfo
vg
=
{
0
};
int32_t
code
=
getTableHashVgroup
(
pCxt
,
pCxt
->
pParseCxt
->
db
,
pTableName
,
&
vg
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pVgId
=
vg
.
vgId
;
}
return
code
;
}
if
(
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
(
SValueNode
*
)
pStmt
->
pOptions
->
pInterval
)
||
static
int32_t
getSmaIndexSql
(
STranslateContext
*
pCxt
,
char
**
pSql
,
int32_t
*
pLen
)
{
(
NULL
!=
pStmt
->
pOptions
->
pOffset
&&
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
(
SValueNode
*
)
pStmt
->
pOptions
->
pOffset
))
||
*
pSql
=
strdup
(
pCxt
->
pParseCxt
->
pSql
);
(
NULL
!=
pStmt
->
pOptions
->
pSliding
&&
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
(
SValueNode
*
)
pStmt
->
pOptions
->
pSliding
))
)
{
if
(
NULL
==
*
pSql
)
{
return
pCxt
->
errCode
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
*
pLen
=
pCxt
->
pParseCxt
->
sqlLen
+
1
;
return
TSDB_CODE_SUCCESS
;
}
createSmaReq
.
tSma
.
intervalUnit
=
((
SValueNode
*
)
pStmt
->
pOptions
->
pInterval
)
->
unit
;
static
int32_t
getSmaIndexExpr
(
STranslateContext
*
pCxt
,
SCreateIndexStmt
*
pStmt
,
char
**
pExpr
,
int32_t
*
pLen
)
{
createSmaReq
.
tSma
.
slidingUnit
=
(
NULL
!=
pStmt
->
pOptions
->
pSliding
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pSliding
)
->
unit
:
0
);
return
nodesListToString
(
pStmt
->
pOptions
->
pFuncs
,
false
,
pExpr
,
pLen
);
strcpy
(
createSmaReq
.
tSma
.
indexName
,
pStmt
->
indexName
);
}
SName
name
;
static
int32_t
getSmaIndexBuildAst
(
STranslateContext
*
pCxt
,
SCreateIndexStmt
*
pStmt
,
char
**
pAst
,
int32_t
*
pLen
)
{
name
.
type
=
TSDB_TABLE_NAME_T
;
SSelectStmt
*
pSelect
=
nodesMakeNode
(
QUERY_NODE_SELECT_STMT
);
name
.
acctId
=
pCxt
->
pParseCxt
->
acctId
;
if
(
NULL
==
pSelect
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
SRealTableNode
*
pTable
=
nodesMakeNode
(
QUERY_NODE_REAL_TABLE
);
if
(
NULL
==
pTable
)
{
nodesDestroyNode
(
pSelect
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
strcpy
(
pTable
->
table
.
dbName
,
pCxt
->
pParseCxt
->
db
);
strcpy
(
pTable
->
table
.
tableName
,
pStmt
->
tableName
);
pSelect
->
pFromTable
=
(
SNode
*
)
pTable
;
pSelect
->
pProjectionList
=
nodesCloneList
(
pStmt
->
pOptions
->
pFuncs
);
if
(
NULL
==
pTable
)
{
nodesDestroyNode
(
pSelect
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
SIntervalWindowNode
*
pInterval
=
nodesMakeNode
(
QUERY_NODE_INTERVAL_WINDOW
);
if
(
NULL
==
pInterval
)
{
nodesDestroyNode
(
pSelect
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pSelect
->
pWindow
=
(
SNode
*
)
pInterval
;
pInterval
->
pInterval
=
nodesCloneNode
(
pStmt
->
pOptions
->
pInterval
);
pInterval
->
pOffset
=
nodesCloneNode
(
pStmt
->
pOptions
->
pOffset
);
pInterval
->
pSliding
=
nodesCloneNode
(
pStmt
->
pOptions
->
pSliding
);
if
(
NULL
==
pInterval
->
pInterval
||
(
NULL
!=
pStmt
->
pOptions
->
pOffset
&&
NULL
==
pInterval
->
pOffset
)
||
(
NULL
!=
pStmt
->
pOptions
->
pSliding
&&
NULL
==
pInterval
->
pSliding
))
{
nodesDestroyNode
(
pSelect
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
int32_t
code
=
translateQuery
(
pCxt
,
(
SNode
*
)
pSelect
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesNodeToString
(
pSelect
,
false
,
pAst
,
pLen
);
}
nodesDestroyNode
(
pSelect
);
return
code
;
}
static
int32_t
buildCreateSmaReq
(
STranslateContext
*
pCxt
,
SCreateIndexStmt
*
pStmt
,
SMCreateSmaReq
*
pReq
)
{
SName
name
=
{
.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
strcpy
(
name
.
dbname
,
pCxt
->
pParseCxt
->
db
);
strcpy
(
name
.
dbname
,
pCxt
->
pParseCxt
->
db
);
strcpy
(
name
.
tname
,
pStmt
->
indexName
);
tNameExtractFullName
(
&
name
,
pReq
->
name
);
strcpy
(
name
.
tname
,
pStmt
->
tableName
);
strcpy
(
name
.
tname
,
pStmt
->
tableName
);
STableMeta
*
pMeta
=
NULL
;
name
.
tname
[
strlen
(
pStmt
->
tableName
)]
=
'\0'
;
int32_t
code
=
catalogGetTableMeta
(
pCxt
->
pParseCxt
->
pCatalog
,
pCxt
->
pParseCxt
->
pTransporter
,
&
pCxt
->
pParseCxt
->
mgmtEpSet
,
&
name
,
&
pMeta
);
tNameExtractFullName
(
&
name
,
pReq
->
stb
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
pReq
->
igExists
=
pStmt
->
ignoreExists
;
pReq
->
interval
=
((
SValueNode
*
)
pStmt
->
pOptions
->
pInterval
)
->
datum
.
i
;
pReq
->
intervalUnit
=
((
SValueNode
*
)
pStmt
->
pOptions
->
pInterval
)
->
unit
;
pReq
->
offset
=
(
NULL
!=
pStmt
->
pOptions
->
pOffset
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pOffset
)
->
datum
.
i
:
0
);
pReq
->
sliding
=
(
NULL
!=
pStmt
->
pOptions
->
pSliding
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pSliding
)
->
datum
.
i
:
pReq
->
interval
);
pReq
->
slidingUnit
=
(
NULL
!=
pStmt
->
pOptions
->
pSliding
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pSliding
)
->
unit
:
pReq
->
intervalUnit
);
int32_t
code
=
getSmaIndexDstVgId
(
pCxt
,
pStmt
->
tableName
,
&
pReq
->
dstVgId
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
getSmaIndexSql
(
pCxt
,
&
pReq
->
sql
,
&
pReq
->
sqlLen
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
getSmaIndexExpr
(
pCxt
,
pStmt
,
&
pReq
->
expr
,
&
pReq
->
exprLen
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
getSmaIndexBuildAst
(
pCxt
,
pStmt
,
&
pReq
->
ast
,
&
pReq
->
astLen
);
}
return
code
;
return
code
;
}
static
int32_t
translateCreateSmaIndex
(
STranslateContext
*
pCxt
,
SCreateIndexStmt
*
pStmt
)
{
if
(
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
(
SValueNode
*
)
pStmt
->
pOptions
->
pInterval
)
||
(
NULL
!=
pStmt
->
pOptions
->
pOffset
&&
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
(
SValueNode
*
)
pStmt
->
pOptions
->
pOffset
))
||
(
NULL
!=
pStmt
->
pOptions
->
pSliding
&&
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
(
SValueNode
*
)
pStmt
->
pOptions
->
pSliding
)))
{
return
pCxt
->
errCode
;
}
}
createSmaReq
.
tSma
.
tableUid
=
pMeta
->
uid
;
SMCreateSmaReq
createSmaReq
=
{
0
};
createSmaReq
.
tSma
.
interval
=
((
SValueNode
*
)
pStmt
->
pOptions
->
pInterval
)
->
datum
.
i
;
int32_t
code
=
buildCreateSmaReq
(
pCxt
,
pStmt
,
&
createSmaReq
);
createSmaReq
.
tSma
.
sliding
=
(
NULL
!=
pStmt
->
pOptions
->
pSliding
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pSliding
)
->
datum
.
i
:
0
);
code
=
nodesListToString
(
pStmt
->
pOptions
->
pFuncs
,
false
,
&
createSmaReq
.
tSma
.
expr
,
&
createSmaReq
.
tSma
.
exprLen
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
code
;
return
code
;
}
}
...
@@ -1443,15 +1519,14 @@ static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt
...
@@ -1443,15 +1519,14 @@ static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
pCxt
->
pCmdMsg
->
epSet
=
pCxt
->
pParseCxt
->
mgmtEpSet
;
pCxt
->
pCmdMsg
->
epSet
=
pCxt
->
pParseCxt
->
mgmtEpSet
;
pCxt
->
pCmdMsg
->
msgType
=
TDMT_
V
ND_CREATE_SMA
;
pCxt
->
pCmdMsg
->
msgType
=
TDMT_
M
ND_CREATE_SMA
;
pCxt
->
pCmdMsg
->
msgLen
=
tSerializeS
VCreateTSmaReq
(
NULL
,
&
createSmaReq
);
pCxt
->
pCmdMsg
->
msgLen
=
tSerializeS
MCreateSmaReq
(
NULL
,
0
,
&
createSmaReq
);
pCxt
->
pCmdMsg
->
pMsg
=
malloc
(
pCxt
->
pCmdMsg
->
msgLen
);
pCxt
->
pCmdMsg
->
pMsg
=
malloc
(
pCxt
->
pCmdMsg
->
msgLen
);
if
(
NULL
==
pCxt
->
pCmdMsg
->
pMsg
)
{
if
(
NULL
==
pCxt
->
pCmdMsg
->
pMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
void
*
pBuf
=
pCxt
->
pCmdMsg
->
pMsg
;
tSerializeSMCreateSmaReq
(
pCxt
->
pCmdMsg
->
pMsg
,
pCxt
->
pCmdMsg
->
msgLen
,
&
createSmaReq
);
tSerializeSVCreateTSmaReq
(
&
pBuf
,
&
createSmaReq
);
tFreeSMCreateSmaReq
(
&
createSmaReq
);
tdDestroyTSma
(
&
createSmaReq
.
tSma
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -1696,24 +1771,27 @@ static int32_t translateSubquery(STranslateContext* pCxt, SNode* pNode) {
...
@@ -1696,24 +1771,27 @@ static int32_t translateSubquery(STranslateContext* pCxt, SNode* pNode) {
return
code
;
return
code
;
}
}
static
int32_t
setReslutSchema
(
STranslateContext
*
pCxt
,
SQuery
*
pQuery
)
{
int32_t
qExtractResultSchema
(
const
SNode
*
pRoot
,
int32_t
*
numOfCols
,
SSchema
**
pSchema
)
{
if
(
QUERY_NODE_SELECT_STMT
==
nodeType
(
p
Query
->
p
Root
))
{
if
(
QUERY_NODE_SELECT_STMT
==
nodeType
(
pRoot
))
{
SSelectStmt
*
pSelect
=
(
SSelectStmt
*
)
pQuery
->
pRoot
;
SSelectStmt
*
pSelect
=
(
SSelectStmt
*
)
pRoot
;
pQuery
->
numOfRes
Cols
=
LIST_LENGTH
(
pSelect
->
pProjectionList
);
*
numOf
Cols
=
LIST_LENGTH
(
pSelect
->
pProjectionList
);
pQuery
->
pResSchema
=
calloc
(
pQuery
->
numOfResCols
,
sizeof
(
SSchema
));
*
pSchema
=
calloc
((
*
numOfCols
)
,
sizeof
(
SSchema
));
if
(
NULL
==
pQuery
->
pResSchema
)
{
if
(
NULL
==
(
*
pSchema
)
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_OUT_OF_MEMORY
)
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
SNode
*
pNode
;
SNode
*
pNode
;
int32_t
index
=
0
;
int32_t
index
=
0
;
FOREACH
(
pNode
,
pSelect
->
pProjectionList
)
{
FOREACH
(
pNode
,
pSelect
->
pProjectionList
)
{
SExprNode
*
pExpr
=
(
SExprNode
*
)
pNode
;
SExprNode
*
pExpr
=
(
SExprNode
*
)
pNode
;
pQuery
->
pResSchema
[
index
].
type
=
pExpr
->
resType
.
type
;
(
*
pSchema
)[
index
].
type
=
pExpr
->
resType
.
type
;
pQuery
->
pResSchema
[
index
].
bytes
=
pExpr
->
resType
.
bytes
;
(
*
pSchema
)[
index
].
bytes
=
pExpr
->
resType
.
bytes
;
strcpy
(
pQuery
->
pResSchema
[
index
].
name
,
pExpr
->
aliasName
);
(
*
pSchema
)[
index
].
colId
=
index
+
1
;
strcpy
((
*
pSchema
)[
index
].
name
,
pExpr
->
aliasName
);
index
+=
1
;
index
+=
1
;
}
}
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -2297,7 +2375,7 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) {
...
@@ -2297,7 +2375,7 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) {
pQuery
->
haveResultSet
=
true
;
pQuery
->
haveResultSet
=
true
;
pQuery
->
directRpc
=
false
;
pQuery
->
directRpc
=
false
;
pQuery
->
msgType
=
TDMT_VND_QUERY
;
pQuery
->
msgType
=
TDMT_VND_QUERY
;
code
=
setReslutSchema
(
pCxt
,
pQuery
);
code
=
qExtractResultSchema
(
pQuery
->
pRoot
,
&
pQuery
->
numOfResCols
,
&
pQuery
->
pResSchema
);
break
;
break
;
case
QUERY_NODE_VNODE_MODIF_STMT
:
case
QUERY_NODE_VNODE_MODIF_STMT
:
pQuery
->
haveResultSet
=
false
;
pQuery
->
haveResultSet
=
false
;
...
...
source/libs/parser/src/sql.c
浏览文件 @
bdbf365e
...
@@ -131,17 +131,17 @@ typedef union {
...
@@ -131,17 +131,17 @@ typedef union {
#define ParseCTX_PARAM
#define ParseCTX_PARAM
#define ParseCTX_FETCH
#define ParseCTX_FETCH
#define ParseCTX_STORE
#define ParseCTX_STORE
#define YYNSTATE 4
27
#define YYNSTATE 4
30
#define YYNRULE 337
#define YYNRULE 337
#define YYNTOKEN 163
#define YYNTOKEN 163
#define YY_MAX_SHIFT 42
6
#define YY_MAX_SHIFT 42
9
#define YY_MIN_SHIFTREDUCE 6
59
#define YY_MIN_SHIFTREDUCE 6
62
#define YY_MAX_SHIFTREDUCE 99
5
#define YY_MAX_SHIFTREDUCE 99
8
#define YY_ERROR_ACTION 99
6
#define YY_ERROR_ACTION 99
9
#define YY_ACCEPT_ACTION
997
#define YY_ACCEPT_ACTION
1000
#define YY_NO_ACTION
998
#define YY_NO_ACTION
1001
#define YY_MIN_REDUCE
999
#define YY_MIN_REDUCE
1002
#define YY_MAX_REDUCE 133
5
#define YY_MAX_REDUCE 133
8
/************* End control #defines *******************************************/
/************* End control #defines *******************************************/
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
...
@@ -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
6
)
#define YY_ACTTAB_COUNT (126
3
)
static
const
YYACTIONTYPE
yy_action
[]
=
{
static
const
YYACTIONTYPE
yy_action
[]
=
{
/* 0 */
104
2
,
1201
,
222
,
43
,
24
,
168
,
359
,
1197
,
1203
,
1092
,
/* 0 */
104
5
,
1204
,
225
,
43
,
24
,
170
,
362
,
1200
,
1206
,
1095
,
/* 10 */
2
47
,
266
,
89
,
31
,
29
,
27
,
26
,
25
,
20
,
1201
,
/* 10 */
2
50
,
269
,
89
,
31
,
29
,
27
,
26
,
25
,
20
,
1204
,
/* 20 */
1
098
,
27
,
26
,
25
,
1081
,
1197
,
1202
,
1103
,
31
,
29
,
/* 20 */
1
101
,
27
,
26
,
25
,
1084
,
1200
,
1205
,
1106
,
31
,
29
,
/* 30 */
27
,
26
,
25
,
3
58
,
997
,
78
,
206
,
866
,
77
,
76
,
/* 30 */
27
,
26
,
25
,
3
61
,
1000
,
78
,
209
,
869
,
77
,
76
,
/* 40 */
75
,
74
,
73
,
72
,
71
,
70
,
69
,
10
88
,
208
,
411
,
/* 40 */
75
,
74
,
73
,
72
,
71
,
70
,
69
,
10
91
,
211
,
414
,
/* 50 */
41
0
,
409
,
408
,
407
,
406
,
405
,
404
,
403
,
402
,
401
,
/* 50 */
41
3
,
412
,
411
,
410
,
409
,
408
,
407
,
406
,
405
,
404
,
/* 60 */
40
0
,
399
,
398
,
397
,
396
,
395
,
394
,
393
,
1000
,
105
,
/* 60 */
40
3
,
402
,
401
,
400
,
399
,
398
,
397
,
396
,
1003
,
105
,
/* 70 */
2
67
,
1011
,
878
,
31
,
29
,
27
,
26
,
25
,
1228
,
131
,
/* 70 */
2
70
,
1014
,
881
,
31
,
29
,
27
,
26
,
25
,
1231
,
132
,
/* 80 */
90
1
,
346
,
111
,
246
,
234
,
343
,
1213
,
1177
,
272
,
78
,
/* 80 */
90
4
,
349
,
111
,
249
,
237
,
346
,
1216
,
1180
,
275
,
78
,
/* 90 */
13
0
,
22
,
77
,
76
,
75
,
74
,
73
,
72
,
71
,
70
,
/* 90 */
13
1
,
22
,
77
,
76
,
75
,
74
,
73
,
72
,
71
,
70
,
/* 100 */
69
,
31
,
29
,
27
,
26
,
25
,
12
28
,
1314
,
208
,
288
,
/* 100 */
69
,
31
,
29
,
27
,
26
,
25
,
12
31
,
1317
,
211
,
291
,
/* 110 */
3
17
,
283
,
267
,
343
,
287
,
44
,
902
,
286
,
128
,
284
,
/* 110 */
3
20
,
286
,
270
,
346
,
290
,
44
,
905
,
289
,
129
,
287
,
/* 120 */
117
,
34
2
,
285
,
345
,
1312
,
23
,
229
,
1189
,
896
,
897
,
/* 120 */
117
,
34
5
,
288
,
348
,
1315
,
23
,
232
,
1192
,
899
,
900
,
/* 130 */
898
,
899
,
900
,
904
,
905
,
906
,
1079
,
201
,
1214
,
1217
,
/* 130 */
901
,
902
,
903
,
907
,
908
,
909
,
1082
,
204
,
1217
,
1220
,
/* 140 */
90
1
,
769
,
382
,
381
,
380
,
773
,
379
,
775
,
776
,
378
,
/* 140 */
90
4
,
772
,
385
,
384
,
383
,
776
,
382
,
778
,
779
,
381
,
/* 150 */
7
78
,
375
,
109
,
784
,
372
,
786
,
787
,
369
,
366
,
1148
,
/* 150 */
7
81
,
378
,
109
,
787
,
375
,
789
,
790
,
372
,
369
,
1151
,
/* 160 */
121
3
,
846
,
127
,
1141
,
302
,
221
,
125
,
43
,
323
,
186
,
/* 160 */
121
6
,
849
,
128
,
1144
,
305
,
224
,
125
,
43
,
326
,
189
,
/* 170 */
114
6
,
358
,
1133
,
30
,
28
,
938
,
902
,
844
,
255
,
239
,
/* 170 */
114
9
,
361
,
1136
,
30
,
28
,
941
,
905
,
847
,
258
,
242
,
/* 180 */
12
28
,
231
,
392
,
846
,
1099
,
23
,
229
,
343
,
896
,
897
,
/* 180 */
12
31
,
234
,
395
,
849
,
1102
,
23
,
232
,
346
,
899
,
900
,
/* 190 */
898
,
899
,
900
,
904
,
905
,
906
,
1201
,
345
,
358
,
844
,
/* 190 */
901
,
902
,
903
,
907
,
908
,
909
,
1204
,
348
,
361
,
847
,
/* 200 */
89
3
,
1189
,
1197
,
1202
,
303
,
359
,
331
,
845
,
12
,
118
,
/* 200 */
89
6
,
1192
,
1200
,
1205
,
306
,
362
,
334
,
848
,
12
,
118
,
/* 210 */
66
,
61
,
121
4
,
1217
,
1253
,
1213
,
962
,
276
,
207
,
1249
,
/* 210 */
66
,
61
,
121
7
,
1220
,
1256
,
1216
,
965
,
279
,
210
,
1252
,
/* 220 */
116
5
,
10
,
122
,
121
,
30
,
28
,
1103
,
120
,
1314
,
845
,
/* 220 */
116
8
,
10
,
122
,
121
,
30
,
28
,
1106
,
120
,
1317
,
848
,
/* 230 */
131
4
,
1
,
231
,
423
,
846
,
1228
,
313
,
960
,
961
,
963
,
/* 230 */
131
7
,
1
,
234
,
426
,
849
,
1231
,
316
,
963
,
964
,
966
,
/* 240 */
96
4
,
117
,
330
,
117
,
1213
,
1312
,
242
,
1312
,
10
,
321
,
/* 240 */
96
7
,
117
,
333
,
117
,
1216
,
1315
,
245
,
1315
,
10
,
324
,
/* 250 */
84
4
,
334
,
345
,
1168
,
1170
,
423
,
1189
,
346
,
696
,
12
,
/* 250 */
84
7
,
337
,
348
,
1171
,
1173
,
426
,
1192
,
349
,
699
,
12
,
/* 260 */
69
5
,
847
,
850
,
1178
,
1228
,
359
,
62
,
1214
,
1217
,
1253
,
/* 260 */
69
8
,
850
,
853
,
1181
,
1231
,
362
,
62
,
1217
,
1220
,
1256
,
/* 270 */
66
,
33
0
,
280
,
224
,
1249
,
112
,
279
,
282
,
697
,
327
,
/* 270 */
66
,
33
3
,
283
,
227
,
1252
,
112
,
282
,
285
,
700
,
330
,
/* 280 */
84
5
,
345
,
1
,
847
,
850
,
1189
,
1103
,
164
,
118
,
9
,
/* 280 */
84
8
,
348
,
1
,
850
,
853
,
1192
,
1106
,
166
,
118
,
9
,
/* 290 */
8
,
59
,
121
3
,
309
,
1280
,
62
,
1214
,
1217
,
1253
,
281
,
/* 290 */
8
,
59
,
121
6
,
312
,
1283
,
62
,
1217
,
1220
,
1256
,
284
,
/* 300 */
92
,
93
,
22
4
,
1249
,
112
,
1314
,
423
,
327
,
1095
,
106
,
/* 300 */
92
,
93
,
22
7
,
1252
,
112
,
1317
,
426
,
330
,
1098
,
106
,
/* 310 */
107
0
,
903
,
1228
,
31
,
29
,
27
,
26
,
25
,
1313
,
343
,
/* 310 */
107
3
,
906
,
1231
,
31
,
29
,
27
,
26
,
25
,
1316
,
346
,
/* 320 */
21
,
121
3
,
1312
,
1281
,
392
,
1267
,
90
,
868
,
92
,
345
,
/* 320 */
21
,
121
6
,
1315
,
1284
,
395
,
1270
,
90
,
871
,
92
,
348
,
/* 330 */
9
07
,
419
,
418
,
1189
,
847
,
850
,
114
,
1260
,
1261
,
867
,
/* 330 */
9
10
,
422
,
421
,
1192
,
850
,
853
,
114
,
1263
,
1264
,
870
,
/* 340 */
126
5
,
1228
,
1264
,
62
,
1214
,
1217
,
1253
,
331
,
343
,
118
,
/* 340 */
126
8
,
1231
,
1267
,
62
,
1217
,
1220
,
1256
,
334
,
346
,
118
,
/* 350 */
22
4
,
1249
,
1326
,
695
,
90
,
1094
,
1213
,
864
,
345
,
914
,
/* 350 */
22
7
,
1252
,
1329
,
698
,
90
,
1097
,
1216
,
867
,
348
,
917
,
/* 360 */
12
28
,
1287
,
1189
,
865
,
161
,
1260
,
326
,
343
,
325
,
274
,
/* 360 */
12
31
,
1290
,
1192
,
868
,
163
,
1263
,
329
,
346
,
328
,
277
,
/* 370 */
23
5
,
1314
,
62
,
1214
,
1217
,
1253
,
1228
,
359
,
104
,
224
,
/* 370 */
23
8
,
1317
,
62
,
1217
,
1220
,
1256
,
1231
,
362
,
104
,
227
,
/* 380 */
12
49
,
1326
,
1100
,
343
,
117
,
1213
,
1105
,
385
,
1312
,
1022
,
/* 380 */
12
52
,
1329
,
1103
,
346
,
117
,
1216
,
1108
,
388
,
1315
,
1025
,
/* 390 */
131
0
,
1090
,
320
,
345
,
30
,
28
,
1189
,
1189
,
1103
,
1021
,
/* 390 */
131
3
,
1093
,
323
,
348
,
30
,
28
,
1192
,
1192
,
1106
,
1024
,
/* 400 */
12
67
,
333
,
231
,
104
,
846
,
1228
,
1080
,
62
,
1214
,
1217
,
/* 400 */
12
70
,
336
,
234
,
104
,
849
,
1231
,
1083
,
62
,
1217
,
1220
,
/* 410 */
125
3
,
1106
,
343
,
1148
,
224
,
1249
,
1326
,
1263
,
359
,
236
,
/* 410 */
125
6
,
1109
,
346
,
1151
,
227
,
1252
,
1329
,
1266
,
362
,
239
,
/* 420 */
84
4
,
1148
,
345
,
356
,
1146
,
1271
,
1189
,
243
,
163
,
12
,
/* 420 */
84
7
,
1151
,
348
,
359
,
1149
,
1274
,
1192
,
246
,
165
,
12
,
/* 430 */
11
89
,
331
,
1146
,
30
,
28
,
1012
,
196
,
1214
,
1217
,
1103
,
/* 430 */
11
92
,
334
,
1149
,
30
,
28
,
1015
,
199
,
1217
,
1220
,
1106
,
/* 440 */
11
89
,
231
,
1213
,
846
,
191
,
1020
,
1019
,
1018
,
136
,
193
,
/* 440 */
11
92
,
234
,
1216
,
849
,
194
,
1023
,
1022
,
1021
,
137
,
196
,
/* 450 */
84
5
,
134
,
1
,
1038
,
316
,
1314
,
30
,
28
,
344
,
844
,
/* 450 */
84
8
,
135
,
1
,
1041
,
319
,
1317
,
30
,
28
,
347
,
847
,
/* 460 */
6
,
19
2
,
1228
,
389
,
231
,
1213
,
846
,
388
,
117
,
343
,
/* 460 */
6
,
19
5
,
1231
,
392
,
234
,
1216
,
849
,
391
,
117
,
346
,
/* 470 */
10
17
,
123
,
1312
,
1148
,
118
,
289
,
423
,
322
,
318
,
345
,
/* 470 */
10
20
,
123
,
1315
,
1151
,
118
,
292
,
426
,
325
,
321
,
348
,
/* 480 */
101
6
,
1015
,
844
,
1189
,
1169
,
1228
,
1189
,
1189
,
1189
,
845
,
/* 480 */
101
9
,
1018
,
847
,
1192
,
1172
,
1231
,
1192
,
1192
,
1192
,
848
,
/* 490 */
39
0
,
7
,
343
,
63
,
1214
,
1217
,
1253
,
1148
,
869
,
1086
,
/* 490 */
39
3
,
7
,
346
,
63
,
1217
,
1220
,
1256
,
1151
,
872
,
1089
,
/* 500 */
125
2
,
1249
,
345
,
1045
,
847
,
850
,
1189
,
945
,
1147
,
387
,
/* 500 */
125
5
,
1252
,
348
,
1048
,
850
,
853
,
1192
,
948
,
1150
,
390
,
/* 510 */
38
6
,
1189
,
845
,
866
,
7
,
423
,
63
,
1214
,
1217
,
1253
,
/* 510 */
38
9
,
1192
,
848
,
869
,
7
,
426
,
63
,
1217
,
1220
,
1256
,
/* 520 */
24
1
,
1189
,
1189
,
341
,
1249
,
30
,
28
,
300
,
104
,
30
,
/* 520 */
24
4
,
1192
,
1192
,
344
,
1252
,
30
,
28
,
303
,
104
,
30
,
/* 530 */
28
,
64
,
38
4
,
231
,
338
,
846
,
1105
,
231
,
423
,
846
,
/* 530 */
28
,
64
,
38
7
,
234
,
341
,
849
,
1108
,
234
,
426
,
849
,
/* 540 */
298
,
1213
,
1267
,
847
,
850
,
999
,
31
,
29
,
27
,
26
,
/* 540 */
301
,
1216
,
1270
,
850
,
853
,
1002
,
31
,
29
,
27
,
26
,
/* 550 */
25
,
84
4
,
288
,
933
,
283
,
844
,
1014
,
287
,
118
,
1262
,
/* 550 */
25
,
84
7
,
291
,
936
,
286
,
847
,
1017
,
290
,
118
,
1265
,
/* 560 */
28
6
,
1228
,
284
,
118
,
1213
,
285
,
847
,
850
,
343
,
87
,
/* 560 */
28
9
,
1231
,
287
,
118
,
1216
,
288
,
850
,
853
,
346
,
87
,
/* 570 */
86
,
85
,
84
,
83
,
82
,
81
,
80
,
79
,
34
5
,
864
,
/* 570 */
86
,
85
,
84
,
83
,
82
,
81
,
80
,
79
,
34
8
,
867
,
/* 580 */
103
3
,
845
,
1189
,
7
,
1228
,
845
,
248
,
1
,
1071
,
260
,
/* 580 */
103
6
,
848
,
1192
,
7
,
1231
,
848
,
251
,
1
,
1074
,
263
,
/* 590 */
101
3
,
343
,
107
,
1214
,
1217
,
937
,
426
,
1189
,
261
,
149
,
/* 590 */
101
6
,
346
,
107
,
1217
,
1220
,
940
,
429
,
1192
,
264
,
151
,
/* 600 */
121
3
,
345
,
291
,
165
,
359
,
1189
,
244
,
423
,
339
,
357
,
/* 600 */
121
6
,
348
,
294
,
167
,
362
,
1192
,
247
,
426
,
342
,
360
,
/* 610 */
18
4
,
423
,
305
,
88
,
104
,
63
,
1214
,
1217
,
1253
,
415
,
/* 610 */
18
7
,
426
,
308
,
88
,
104
,
63
,
1217
,
1220
,
1256
,
418
,
/* 620 */
12
28
,
183
,
1105
,
1250
,
98
,
1103
,
1010
,
343
,
314
,
332
,
/* 620 */
12
31
,
186
,
1108
,
1253
,
98
,
1106
,
1013
,
346
,
317
,
335
,
/* 630 */
13
27
,
1189
,
1031
,
1009
,
1008
,
847
,
850
,
345
,
359
,
847
,
/* 630 */
13
30
,
1192
,
1034
,
1012
,
1011
,
850
,
853
,
348
,
362
,
850
,
/* 640 */
85
0
,
1189
,
1142
,
181
,
230
,
359
,
60
,
1007
,
1006
,
179
,
/* 640 */
85
3
,
1192
,
1145
,
184
,
233
,
362
,
60
,
1010
,
1009
,
182
,
/* 650 */
24
5
,
202
,
1214
,
1217
,
294
,
1005
,
158
,
1004
,
1213
,
1103
,
/* 650 */
24
8
,
205
,
1217
,
1220
,
297
,
1008
,
160
,
1007
,
1216
,
1106
,
/* 660 */
127
2
,
933
,
1229
,
1213
,
273
,
259
,
1103
,
1189
,
254
,
253
,
/* 660 */
127
5
,
936
,
1232
,
1216
,
276
,
262
,
1106
,
1192
,
257
,
256
,
/* 670 */
25
2
,
251
,
250
,
335
,
1189
,
1189
,
1003
,
853
,
1228
,
138
,
/* 670 */
25
5
,
254
,
253
,
338
,
1192
,
1192
,
1006
,
856
,
1231
,
139
,
/* 680 */
35
5
,
1213
,
137
,
1228
,
140
,
343
,
1213
,
139
,
1189
,
1189
,
/* 680 */
35
8
,
1216
,
138
,
1231
,
141
,
346
,
1216
,
140
,
1192
,
1192
,
/* 690 */
34
3
,
852
,
991
,
992
,
308
,
345
,
1189
,
146
,
1189
,
1189
,
/* 690 */
34
6
,
855
,
994
,
995
,
311
,
348
,
1192
,
147
,
1192
,
1192
,
/* 700 */
34
5
,
1228
,
310
,
327
,
1189
,
328
,
1228
,
856
,
343
,
202
,
/* 700 */
34
8
,
1231
,
313
,
330
,
1192
,
331
,
1231
,
859
,
346
,
205
,
/* 710 */
121
4
,
1217
,
1002
,
343
,
107
,
1214
,
1217
,
1189
,
345
,
9
,
/* 710 */
121
7
,
1220
,
1005
,
346
,
107
,
1217
,
1220
,
1192
,
348
,
9
,
/* 720 */
8
,
85
5
,
1189
,
345
,
92
,
228
,
864
,
1189
,
1213
,
936
,
/* 720 */
8
,
85
8
,
1192
,
348
,
92
,
231
,
867
,
1192
,
1216
,
939
,
/* 730 */
23
2
,
1213
,
202
,
1214
,
1217
,
1283
,
1213
,
202
,
1214
,
1217
,
/* 730 */
23
5
,
1216
,
205
,
1217
,
1220
,
1286
,
1216
,
205
,
1217
,
1220
,
/* 740 */
31
,
29
,
27
,
26
,
25
,
33
6
,
327
,
1167
,
1228
,
52
,
/* 740 */
31
,
29
,
27
,
26
,
25
,
33
9
,
330
,
1170
,
1231
,
52
,
/* 750 */
90
,
12
28
,
1328
,
1189
,
167
,
343
,
1228
,
1078
,
343
,
329
,
/* 750 */
90
,
12
31
,
1331
,
1192
,
169
,
346
,
1231
,
1081
,
346
,
332
,
/* 760 */
113
,
126
0
,
1261
,
343
,
1265
,
345
,
1096
,
92
,
345
,
1189
,
/* 760 */
113
,
126
3
,
1264
,
346
,
1268
,
348
,
1099
,
92
,
348
,
1192
,
/* 770 */
2
,
119
,
11
89
,
345
,
1213
,
142
,
257
,
1189
,
141
,
200
,
/* 770 */
2
,
119
,
11
92
,
348
,
1216
,
143
,
260
,
1192
,
142
,
203
,
/* 780 */
121
4
,
1217
,
203
,
1214
,
1217
,
959
,
154
,
194
,
1214
,
1217
,
/* 780 */
121
7
,
1220
,
206
,
1217
,
1220
,
962
,
156
,
197
,
1217
,
1220
,
/* 790 */
2
49
,
256
,
258
,
90
,
1228
,
262
,
1213
,
41
,
152
,
878
,
/* 790 */
2
52
,
259
,
261
,
90
,
1231
,
265
,
1216
,
41
,
154
,
881
,
/* 800 */
9
08
,
343
,
1213
,
115
,
1260
,
1261
,
872
,
1265
,
994
,
995
,
/* 800 */
9
11
,
346
,
1216
,
115
,
1263
,
1264
,
875
,
1268
,
997
,
998
,
/* 810 */
26
3
,
345
,
32
,
264
,
389
,
1189
,
1228
,
124
,
388
,
871
,
/* 810 */
26
6
,
348
,
32
,
267
,
392
,
1192
,
1231
,
124
,
391
,
874
,
/* 820 */
87
5
,
58
,
1228
,
343
,
42
,
204
,
1214
,
1217
,
1207
,
343
,
/* 820 */
87
8
,
58
,
1231
,
346
,
127
,
207
,
1217
,
1220
,
1210
,
346
,
/* 830 */
121
3
,
54
,
32
,
345
,
839
,
265
,
1213
,
1189
,
268
,
345
,
/* 830 */
121
6
,
54
,
32
,
348
,
842
,
268
,
1216
,
1192
,
271
,
348
,
/* 840 */
120
5
,
390
,
129
,
1189
,
275
,
870
,
32
,
195
,
1214
,
1217
,
/* 840 */
120
8
,
393
,
42
,
1192
,
278
,
130
,
32
,
198
,
1217
,
1220
,
/* 850 */
12
28
,
277
,
68
,
205
,
1214
,
1217
,
1228
,
343
,
173
,
1093
,
/* 850 */
12
31
,
873
,
68
,
208
,
1217
,
1220
,
1231
,
346
,
175
,
280
,
/* 860 */
3
87
,
386
,
220
,
343
,
1213
,
133
,
351
,
345
,
178
,
1089
,
/* 860 */
3
90
,
389
,
223
,
346
,
1216
,
1096
,
354
,
348
,
181
,
134
,
/* 870 */
17
1
,
1189
,
135
,
345
,
762
,
100
,
101
,
1189
,
95
,
109
1
,
/* 870 */
17
3
,
1192
,
1092
,
348
,
765
,
136
,
100
,
1192
,
95
,
10
1
,
/* 880 */
96
,
122
5
,
1214
,
1217
,
1228
,
1087
,
98
,
1224
,
1214
,
1217
,
/* 880 */
96
,
122
8
,
1217
,
1220
,
1231
,
1094
,
98
,
1227
,
1217
,
1220
,
/* 890 */
7
57
,
343
,
1213
,
102
,
790
,
794
,
103
,
800
,
1213
,
799
,
/* 890 */
7
60
,
346
,
1216
,
1090
,
793
,
797
,
102
,
803
,
1216
,
802
,
/* 900 */
3
07
,
345
,
41
,
304
,
145
,
1189
,
364
,
96
,
99
,
97
,
/* 900 */
3
10
,
348
,
41
,
103
,
146
,
1192
,
367
,
96
,
99
,
97
,
/* 910 */
306
,
98
,
1228
,
869
,
315
,
1223
,
1214
,
1217
,
1228
,
343
,
/* 910 */
149
,
98
,
1231
,
307
,
309
,
1226
,
1217
,
1220
,
1231
,
346
,
/* 920 */
96
,
1284
,
349
,
1294
,
150
,
343
,
312
,
850
,
1293
,
345
,
/* 920 */
96
,
872
,
318
,
1297
,
1287
,
346
,
352
,
152
,
853
,
348
,
/* 930 */
153
,
223
,
1213
,
1189
,
319
,
345
,
5
,
110
,
1274
,
1189
,
/* 930 */
315
,
1296
,
1216
,
1192
,
226
,
348
,
5
,
159
,
155
,
1192
,
/* 940 */
121
3
,
324
,
157
,
211
,
1214
,
1217
,
238
,
237
,
311
,
210
,
/* 940 */
121
6
,
322
,
327
,
214
,
1217
,
1220
,
241
,
240
,
1277
,
213
,
/* 950 */
121
4
,
1217
,
1228
,
4
,
933
,
91
,
858
,
868
,
1268
,
343
,
/* 950 */
121
7
,
1220
,
1231
,
314
,
4
,
161
,
861
,
936
,
91
,
346
,
/* 960 */
12
28
,
33
,
159
,
160
,
1311
,
225
,
1329
,
343
,
1213
,
345
,
/* 960 */
12
31
,
871
,
110
,
1271
,
33
,
162
,
228
,
346
,
1216
,
348
,
/* 970 */
337
,
340
,
851
,
1189
,
293
,
215
,
166
,
345
,
17
,
1235
,
/* 970 */
1332
,
340
,
854
,
1192
,
296
,
218
,
343
,
348
,
17
,
1238
,
/* 980 */
117
6
,
1189
,
347
,
212
,
1214
,
1217
,
348
,
233
,
1228
,
301
,
/* 980 */
117
9
,
1192
,
168
,
215
,
1217
,
1220
,
350
,
1314
,
1231
,
304
,
/* 990 */
1175
,
209
,
1214
,
1217
,
352
,
343
,
353
,
280
,
354
,
175
,
/* 990 */
351
,
212
,
1217
,
1220
,
355
,
346
,
1178
,
283
,
356
,
236
,
/* 1000 */
51
,
279
,
854
,
144
,
185
,
345
,
296
,
187
,
53
,
1189
,
/* 1000 */
177
,
282
,
857
,
145
,
357
,
348
,
299
,
179
,
53
,
1192
,
/* 1010 */
1104
,
290
,
182
,
216
,
143
,
214
,
213
,
422
,
278
,
199
,
/* 1010 */
51
,
293
,
188
,
219
,
144
,
217
,
216
,
190
,
281
,
202
,
/* 1020 */
121
4
,
1217
,
362
,
197
,
281
,
198
,
189
,
190
,
360
,
1183
,
/* 1020 */
121
7
,
1220
,
1107
,
365
,
284
,
185
,
425
,
200
,
363
,
201
,
/* 1030 */
822
,
1160
,
1159
,
94
,
1158
,
1157
,
1156
,
1155
,
1154
,
40
,
/* 1030 */
192
,
193
,
1186
,
825
,
1163
,
1162
,
94
,
1161
,
1160
,
40
,
/* 1040 */
115
3
,
824
,
39
,
1152
,
1151
,
1150
,
1149
,
1044
,
1182
,
1173
,
/* 1040 */
115
9
,
1158
,
39
,
1157
,
1156
,
827
,
1155
,
1154
,
1153
,
1152
,
/* 1050 */
126
,
1082
,
708
,
1043
,
1041
,
269
,
859
,
850
,
270
,
271
,
/* 1050 */
1047
,
1185
,
1176
,
126
,
1085
,
711
,
862
,
853
,
1046
,
1044
,
/* 1060 */
1030
,
1029
,
1026
,
1084
,
67
,
132
,
805
,
1083
,
804
,
1039
,
/* 1060 */
272
,
273
,
274
,
1033
,
1032
,
1029
,
1087
,
67
,
133
,
808
,
/* 1070 */
10
34
,
737
,
803
,
1032
,
1025
,
1024
,
1181
,
736
,
217
,
735
,
/* 1070 */
10
86
,
807
,
1042
,
1037
,
740
,
806
,
1035
,
739
,
1028
,
220
,
/* 1080 */
73
4
,
218
,
1180
,
36
,
1172
,
45
,
219
,
148
,
297
,
3
,
/* 1080 */
73
8
,
1027
,
221
,
737
,
222
,
1184
,
1183
,
36
,
1175
,
150
,
/* 1090 */
733
,
65
,
32
,
732
,
299
,
14
,
292
,
151
,
958
,
15
,
/* 1090 */
300
,
302
,
3
,
736
,
735
,
65
,
45
,
32
,
14
,
153
,
/* 1100 */
1205
,
147
,
162
,
295
,
37
,
11
,
156
,
19
,
34
,
48
,
/* 1100 */
295
,
37
,
15
,
158
,
19
,
298
,
1208
,
34
,
11
,
164
,
/* 1110 */
8
,
350
,
894
,
1171
,
177
,
998
,
998
,
998
,
998
,
998
,
/* 1110 */
48
,
8
,
35
,
16
,
148
,
897
,
353
,
1174
,
180
,
1001
,
/* 1120 */
998
,
783
,
998
,
998
,
998
,
998
,
998
,
998
,
980
,
979
,
/* 1120 */
1001
,
1001
,
1001
,
1001
,
1001
,
1001
,
1001
,
1001
,
1001
,
1001
,
/* 1130 */
226
,
984
,
983
,
227
,
860
,
998
,
998
,
998
,
108
,
998
,
/* 1130 */
983
,
982
,
229
,
987
,
986
,
230
,
863
,
1001
,
1001
,
1001
,
/* 1140 */
998
,
176
,
998
,
998
,
998
,
998
,
998
,
155
,
998
,
952
,
/* 1140 */
1001
,
1001
,
1001
,
178
,
1001
,
961
,
1001
,
108
,
1001
,
157
,
/* 1150 */
46
,
998
,
951
,
47
,
998
,
768
,
930
,
929
,
998
,
985
,
/* 1150 */
1001
,
955
,
46
,
1001
,
954
,
933
,
1001
,
47
,
1001
,
1001
,
/* 1160 */
9
98
,
998
,
35
,
998
,
998
,
998
,
998
,
998
,
876
,
11
6
,
/* 1160 */
9
32
,
1001
,
988
,
1001
,
1001
,
1001
,
1001
,
1001
,
1001
,
36
6
,
/* 1170 */
13
,
18
,
16
,
170
,
956
,
998
,
172
,
174
,
169
,
49
,
/* 1170 */
879
,
13
,
116
,
18
,
243
,
172
,
959
,
174
,
176
,
1001
,
/* 1180 */
50
,
1204
,
998
,
998
,
54
,
38
,
363
,
1040
,
240
,
367
,
/* 1180 */
171
,
49
,
50
,
1001
,
1207
,
38
,
370
,
1001
,
373
,
794
,
/* 1190 */
1028
,
370
,
373
,
180
,
998
,
361
,
998
,
796
,
376
,
998
,
/* 1190 */
54
,
376
,
771
,
1001
,
379
,
183
,
1001
,
364
,
799
,
1001
,
/* 1200 */
791
,
365
,
728
,
788
,
368
,
1027
,
785
,
998
,
798
,
371
,
/* 1200 */
1001
,
1001
,
368
,
731
,
791
,
371
,
1043
,
1001
,
788
,
723
,
/* 1210 */
420
,
720
,
797
,
779
,
998
,
998
,
998
,
727
,
782
,
998
,
/* 1210 */
1001
,
428
,
423
,
801
,
374
,
786
,
800
,
782
,
1001
,
1001
,
/* 1220 */
726
,
998
,
998
,
725
,
724
,
706
,
781
,
374
,
391
,
777
,
/* 1220 */
1001
,
730
,
377
,
729
,
728
,
709
,
780
,
727
,
380
,
394
,
/* 1230 */
7
23
,
722
,
721
,
377
,
719
,
1023
,
718
,
717
,
413
,
71
6
,
/* 1230 */
7
85
,
726
,
1031
,
725
,
724
,
417
,
722
,
721
,
1030
,
102
6
,
/* 1240 */
383
,
55
,
56
,
57
,
425
,
715
,
729
,
714
,
713
,
421
,
/* 1240 */
416
,
720
,
55
,
56
,
57
,
415
,
420
,
732
,
719
,
424
,
/* 1250 */
712
,
711
,
412
,
848
,
188
,
424
,
998
,
416
,
417
,
998
,
/* 1250 */
1001
,
851
,
718
,
717
,
716
,
386
,
715
,
784
,
191
,
783
,
/* 1260 */
998
,
414
,
998
,
998
,
998
,
780
,
/* 1260 */
714
,
419
,
427
,
};
};
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
,
...
@@ -423,49 +423,49 @@ static const YYCODETYPE yy_lookahead[] = {
...
@@ -423,49 +423,49 @@ static const YYCODETYPE yy_lookahead[] = {
/* 810 */
211
,
203
,
83
,
193
,
57
,
207
,
186
,
174
,
61
,
20
,
/* 810 */
211
,
203
,
83
,
193
,
57
,
207
,
186
,
174
,
61
,
20
,
/* 820 */
71
,
70
,
186
,
193
,
174
,
217
,
218
,
219
,
70
,
193
,
/* 820 */
71
,
70
,
186
,
193
,
174
,
217
,
218
,
219
,
70
,
193
,
/* 830 */
166
,
80
,
83
,
203
,
71
,
204
,
166
,
207
,
172
,
203
,
/* 830 */
166
,
80
,
83
,
203
,
71
,
204
,
166
,
207
,
172
,
203
,
/* 840 */
82
,
84
,
174
,
207
,
168
,
20
,
83
,
217
,
218
,
219
,
/* 840 */
82
,
84
,
174
,
207
,
168
,
174
,
83
,
217
,
218
,
219
,
/* 850 */
186
,
186
,
172
,
217
,
218
,
219
,
186
,
193
,
71
,
186
,
/* 850 */
186
,
20
,
172
,
217
,
218
,
219
,
186
,
193
,
71
,
186
,
/* 860 */
103
,
104
,
168
,
193
,
166
,
186
,
71
,
203
,
71
,
186
,
/* 860 */
103
,
104
,
168
,
193
,
166
,
186
,
71
,
203
,
71
,
186
,
/* 870 */
83
,
207
,
186
,
203
,
71
,
186
,
186
,
207
,
83
,
186
,
/* 870 */
83
,
207
,
186
,
203
,
71
,
186
,
186
,
207
,
83
,
186
,
/* 880 */
83
,
217
,
218
,
219
,
186
,
186
,
83
,
217
,
218
,
219
,
/* 880 */
83
,
217
,
218
,
219
,
186
,
186
,
83
,
217
,
218
,
219
,
/* 890 */
71
,
193
,
166
,
186
,
71
,
71
,
186
,
71
,
166
,
71
,
/* 890 */
71
,
193
,
166
,
186
,
71
,
71
,
186
,
71
,
166
,
71
,
/* 900 */
204
,
203
,
83
,
211
,
171
,
207
,
83
,
83
,
71
,
83
,
/* 900 */
204
,
203
,
83
,
186
,
171
,
207
,
83
,
83
,
71
,
83
,
/* 910 */
1
93
,
83
,
186
,
20
,
145
,
217
,
218
,
219
,
186
,
193
,
/* 910 */
1
71
,
83
,
186
,
211
,
193
,
217
,
218
,
219
,
186
,
193
,
/* 920 */
83
,
216
,
144
,
246
,
208
,
193
,
207
,
123
,
246
,
203
,
/* 920 */
83
,
20
,
145
,
246
,
216
,
193
,
144
,
208
,
123
,
203
,
/* 930 */
20
8
,
207
,
166
,
207
,
207
,
203
,
152
,
240
,
243
,
207
,
/* 930 */
20
7
,
246
,
166
,
207
,
207
,
203
,
152
,
242
,
208
,
207
,
/* 940 */
166
,
151
,
242
,
217
,
218
,
219
,
12
,
13
,
140
,
217
,
/* 940 */
166
,
207
,
151
,
217
,
218
,
219
,
12
,
13
,
243
,
217
,
/* 950 */
218
,
219
,
186
,
1
39
,
136
,
193
,
22
,
20
,
215
,
193
,
/* 950 */
218
,
219
,
186
,
1
40
,
139
,
239
,
22
,
136
,
193
,
193
,
/* 960 */
186
,
114
,
239
,
227
,
252
,
160
,
257
,
193
,
166
,
203
,
/* 960 */
186
,
20
,
240
,
215
,
114
,
227
,
160
,
193
,
166
,
203
,
/* 970 */
154
,
156
,
38
,
207
,
4
,
35
,
251
,
203
,
70
,
223
,
/* 970 */
257
,
154
,
38
,
207
,
4
,
35
,
156
,
203
,
70
,
223
,
/* 980 */
208
,
207
,
2
07
,
217
,
218
,
219
,
207
,
207
,
186
,
19
,
/* 980 */
208
,
207
,
2
51
,
217
,
218
,
219
,
207
,
252
,
186
,
19
,
/* 990 */
20
8
,
217
,
218
,
219
,
118
,
193
,
205
,
57
,
204
,
193
,
/* 990 */
20
7
,
217
,
218
,
219
,
118
,
193
,
208
,
57
,
205
,
207
,
/* 1000 */
1
71
,
61
,
68
,
33
,
182
,
203
,
36
,
172
,
70
,
207
,
/* 1000 */
1
93
,
61
,
68
,
33
,
204
,
203
,
36
,
171
,
70
,
207
,
/* 1010 */
1
93
,
41
,
171
,
73
,
44
,
75
,
76
,
168
,
78
,
217
,
/* 1010 */
1
71
,
41
,
182
,
73
,
44
,
75
,
76
,
172
,
78
,
217
,
/* 1020 */
218
,
219
,
1
89
,
180
,
84
,
180
,
173
,
164
,
94
,
0
,
/* 1020 */
218
,
219
,
1
93
,
189
,
84
,
171
,
168
,
180
,
94
,
18
0
,
/* 1030 */
82
,
0
,
0
,
114
,
0
,
0
,
0
,
0
,
0
,
69
,
/* 1030 */
173
,
164
,
0
,
82
,
0
,
0
,
114
,
0
,
0
,
69
,
/* 1040 */
0
,
22
,
72
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
/* 1040 */
0
,
0
,
72
,
0
,
0
,
22
,
0
,
0
,
0
,
0
,
/* 1050 */
43
,
0
,
48
,
0
,
0
,
38
,
122
,
123
,
36
,
43
,
/* 1050 */
0
,
0
,
0
,
43
,
0
,
48
,
122
,
123
,
0
,
0
,
/* 1060 */
0
,
0
,
0
,
0
,
79
,
77
,
38
,
0
,
38
,
0
,
/* 1060 */
38
,
36
,
43
,
0
,
0
,
0
,
0
,
79
,
77
,
38
,
/* 1070 */
0
,
38
,
22
,
0
,
0
,
0
,
0
,
38
,
22
,
38
,
/* 1070 */
0
,
38
,
0
,
0
,
38
,
22
,
0
,
38
,
0
,
22
,
/* 1080 */
38
,
22
,
0
,
121
,
0
,
70
,
22
,
116
,
22
,
83
,
/* 1080 */
38
,
0
,
22
,
38
,
22
,
0
,
0
,
121
,
0
,
116
,
/* 1090 */
38
,
20
,
83
,
38
,
22
,
141
,
39
,
71
,
71
,
14
1
,
/* 1090 */
22
,
22
,
83
,
38
,
38
,
20
,
70
,
83
,
141
,
7
1
,
/* 1100 */
82
,
43
,
82
,
38
,
83
,
141
,
83
,
83
,
135
,
4
,
/* 1100 */
39
,
83
,
141
,
83
,
83
,
38
,
82
,
135
,
141
,
82
,
/* 1110 */
2
,
119
,
126
,
0
,
116
,
258
,
258
,
258
,
258
,
258
,
/* 1110 */
4
,
2
,
83
,
83
,
43
,
126
,
119
,
0
,
116
,
258
,
/* 1120 */
258
,
96
,
258
,
258
,
258
,
258
,
258
,
258
,
38
,
3
8
,
/* 1120 */
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
258
,
25
8
,
/* 1130 */
38
,
38
,
38
,
38
,
22
,
258
,
258
,
258
,
70
,
258
,
/* 1130 */
38
,
38
,
38
,
38
,
38
,
38
,
22
,
258
,
258
,
258
,
/* 1140 */
258
,
43
,
258
,
258
,
258
,
258
,
258
,
70
,
258
,
71
,
/* 1140 */
258
,
258
,
258
,
43
,
258
,
71
,
258
,
70
,
258
,
70
,
/* 1150 */
70
,
258
,
71
,
70
,
258
,
22
,
71
,
71
,
258
,
71
,
/* 1150 */
258
,
71
,
70
,
258
,
71
,
71
,
258
,
70
,
258
,
258
,
/* 1160 */
258
,
258
,
83
,
258
,
258
,
258
,
258
,
258
,
71
,
82
,
/* 1160 */
71
,
258
,
71
,
258
,
258
,
258
,
258
,
258
,
258
,
38
,
/* 1170 */
7
0
,
70
,
83
,
71
,
71
,
258
,
70
,
70
,
82
,
70
,
/* 1170 */
7
1
,
70
,
82
,
70
,
38
,
71
,
71
,
70
,
70
,
258
,
/* 1180 */
70
,
82
,
258
,
258
,
80
,
70
,
38
,
0
,
38
,
38
,
/* 1180 */
82
,
70
,
70
,
258
,
82
,
70
,
38
,
258
,
38
,
71
,
/* 1190 */
0
,
38
,
38
,
82
,
258
,
81
,
258
,
22
,
38
,
258
,
/* 1190 */
80
,
38
,
22
,
258
,
38
,
82
,
258
,
81
,
22
,
258
,
/* 1200 */
71
,
70
,
22
,
71
,
70
,
0
,
71
,
258
,
38
,
70
,
/* 1200 */
258
,
258
,
70
,
22
,
71
,
70
,
0
,
258
,
71
,
22
,
/* 1210 */
22
,
22
,
38
,
71
,
258
,
258
,
258
,
38
,
96
,
258
,
/* 1210 */
258
,
20
,
22
,
38
,
70
,
96
,
38
,
71
,
258
,
258
,
/* 1220 */
38
,
258
,
258
,
38
,
38
,
48
,
96
,
70
,
47
,
71
,
/* 1220 */
258
,
38
,
70
,
38
,
38
,
48
,
71
,
38
,
70
,
47
,
/* 1230 */
38
,
38
,
38
,
70
,
38
,
0
,
38
,
38
,
36
,
38
,
/* 1230 */
96
,
38
,
0
,
38
,
38
,
43
,
38
,
38
,
0
,
0
,
/* 1240 */
84
,
70
,
70
,
70
,
20
,
38
,
68
,
3
8
,
38
,
21
,
/* 1240 */
36
,
38
,
70
,
70
,
70
,
38
,
37
,
6
8
,
38
,
21
,
/* 1250 */
38
,
38
,
38
,
22
,
22
,
21
,
258
,
38
,
37
,
258
,
/* 1250 */
258
,
22
,
38
,
38
,
38
,
84
,
38
,
96
,
22
,
96
,
/* 1260 */
258
,
43
,
258
,
258
,
258
,
96
,
258
,
258
,
258
,
258
,
/* 1260 */
38
,
38
,
21
,
258
,
258
,
258
,
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,11 +481,11 @@ static const YYCODETYPE yy_lookahead[] = {
...
@@ -481,11 +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
,
/* 1420 */
258
,
258
,
258
,
258
,
258
,
258
,
};
};
#define YY_SHIFT_COUNT (42
6
)
#define YY_SHIFT_COUNT (42
9
)
#define YY_SHIFT_MIN (0)
#define YY_SHIFT_MIN (0)
#define YY_SHIFT_MAX (12
35
)
#define YY_SHIFT_MAX (12
41
)
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
,
...
@@ -499,41 +499,41 @@ static const unsigned short int yy_shift_ofst[] = {
...
@@ -499,41 +499,41 @@ static const unsigned short int yy_shift_ofst[] = {
/* 90 */
307
,
307
,
307
,
136
,
343
,
319
,
17
,
17
,
17
,
306
,
/* 90 */
307
,
307
,
307
,
136
,
343
,
319
,
17
,
17
,
17
,
306
,
/* 100 */
56
,
56
,
56
,
56
,
56
,
68
,
503
,
534
,
90
,
215
,
/* 100 */
56
,
56
,
56
,
56
,
56
,
68
,
503
,
534
,
90
,
215
,
/* 110 */
335
,
331
,
478
,
525
,
417
,
525
,
493
,
248
,
591
,
706
,
/* 110 */
335
,
331
,
478
,
525
,
417
,
525
,
493
,
248
,
591
,
706
,
/* 120 */
657
,
661
,
661
,
706
,
786
,
66
,
343
,
799
,
66
,
70
6
,
/* 120 */
657
,
661
,
661
,
706
,
786
,
66
,
343
,
799
,
66
,
6
6
,
/* 130 */
66
,
825
,
17
,
17
,
17
,
17
,
17
,
17
,
17
,
17
,
/* 130 */
706
,
66
,
831
,
17
,
17
,
17
,
17
,
17
,
17
,
17
,
/* 140 */
17
,
17
,
17
,
706
,
825
,
786
,
278
,
343
,
799
,
893
,
/* 140 */
17
,
17
,
17
,
17
,
706
,
831
,
786
,
278
,
343
,
799
,
/* 150 */
769
,
778
,
804
,
769
,
778
,
804
,
804
,
784
,
790
,
808
,
/* 150 */
278
,
901
,
777
,
782
,
805
,
777
,
782
,
805
,
805
,
784
,
/* 160 */
814
,
818
,
343
,
937
,
847
,
805
,
815
,
816
,
908
,
17
,
/* 160 */
791
,
813
,
815
,
821
,
343
,
941
,
850
,
806
,
820
,
8
17
,
/* 170 */
778
,
804
,
804
,
778
,
804
,
876
,
343
,
799
,
306
,
278
,
/* 170 */
908
,
17
,
782
,
805
,
805
,
782
,
805
,
876
,
343
,
799
,
/* 180 */
343
,
938
,
706
,
278
,
825
,
1266
,
1266
,
1266
,
1266
,
0
,
/* 180 */
278
,
306
,
278
,
343
,
938
,
706
,
278
,
831
,
1263
,
1263
,
/* 190 */
545
,
577
,
46
,
970
,
16
,
89
,
728
,
406
,
757
,
301
,
/* 190 */
1263
,
1263
,
0
,
545
,
577
,
46
,
970
,
16
,
89
,
728
,
/* 200 */
301
,
301
,
301
,
301
,
301
,
301
,
115
,
288
,
196
,
7
,
/* 200 */
406
,
757
,
301
,
301
,
301
,
301
,
301
,
301
,
301
,
115
,
/* 210 */
7
,
7
,
7
,
374
,
605
,
610
,
701
,
453
,
580
,
632
,
/* 210 */
288
,
196
,
7
,
7
,
7
,
7
,
374
,
605
,
610
,
701
,
/* 220 */
506
,
541
,
714
,
715
,
718
,
647
,
590
,
451
,
729
,
74
,
/* 220 */
453
,
580
,
632
,
506
,
541
,
714
,
715
,
718
,
647
,
590
,
/* 230 */
749
,
758
,
763
,
787
,
795
,
797
,
803
,
639
,
653
,
819
,
/* 230 */
451
,
729
,
74
,
749
,
758
,
763
,
787
,
795
,
797
,
803
,
/* 240 */
823
,
824
,
826
,
828
,
837
,
751
,
1029
,
948
,
103
1
,
1032
,
/* 240 */
639
,
653
,
819
,
823
,
824
,
826
,
828
,
837
,
75
1
,
1032
,
/* 250 */
9
19
,
1034
,
1035
,
1036
,
1037
,
1038
,
1040
,
1019
,
1043
,
1044
,
/* 250 */
9
51
,
1034
,
1035
,
922
,
1037
,
1038
,
1040
,
1041
,
1043
,
1044
,
/* 260 */
10
45
,
1046
,
1047
,
1048
,
1049
,
1007
,
1051
,
1004
,
1053
,
1054
,
/* 260 */
10
23
,
1046
,
1047
,
1048
,
1049
,
1050
,
1051
,
1052
,
1010
,
1054
,
/* 270 */
10
17
,
1022
,
1016
,
1060
,
1061
,
1062
,
1063
,
985
,
988
,
1028
,
/* 270 */
10
07
,
1058
,
1059
,
1022
,
1025
,
1019
,
1063
,
1064
,
1065
,
1066
,
/* 280 */
1030
,
1050
,
1067
,
1033
,
1039
,
1041
,
1042
,
1052
,
1055
,
1069
,
/* 280 */
988
,
991
,
1031
,
1033
,
1053
,
1070
,
1036
,
1039
,
1042
,
1045
,
/* 290 */
105
6
,
1070
,
1059
,
1057
,
1073
,
1064
,
1065
,
1074
,
1066
,
1075
,
/* 290 */
105
5
,
1056
,
1072
,
1057
,
1073
,
1060
,
1061
,
1076
,
1062
,
1067
,
/* 300 */
107
2
,
1071
,
1076
,
1082
,
962
,
1084
,
1015
,
1058
,
971
,
100
6
,
/* 300 */
107
8
,
1068
,
1081
,
1069
,
1075
,
1085
,
1086
,
966
,
1088
,
102
6
,
/* 310 */
10
09
,
954
,
1026
,
1021
,
1027
,
1068
,
1077
,
1078
,
1080
,
1081
,
/* 310 */
10
71
,
973
,
1009
,
1014
,
957
,
1028
,
1018
,
1074
,
1077
,
1079
,
/* 320 */
10
23
,
1018
,
1083
,
1024
,
958
,
1085
,
1086
,
1020
,
973
,
107
9
,
/* 320 */
10
80
,
1082
,
1083
,
1020
,
1024
,
1087
,
1021
,
961
,
1084
,
108
9
,
/* 330 */
10
87
,
1088
,
1089
,
964
,
1105
,
1090
,
1091
,
1092
,
1093
,
1094
,
/* 330 */
10
27
,
972
,
1029
,
1090
,
1091
,
1030
,
967
,
1106
,
1092
,
1093
,
/* 340 */
109
5
,
1108
,
986
,
1096
,
1097
,
1100
,
1101
,
1102
,
1103
,
1106
,
/* 340 */
109
4
,
1095
,
1096
,
1097
,
1109
,
989
,
1098
,
1099
,
1101
,
1103
,
/* 350 */
110
7
,
992
,
1109
,
1113
,
1098
,
998
,
1110
,
1104
,
1099
,
1111
,
/* 350 */
110
4
,
1105
,
1107
,
1108
,
997
,
1111
,
1117
,
1100
,
1002
,
1112
,
/* 360 */
111
2
,
1115
,
1114
,
1129
,
1148
,
1150
,
1131
,
1132
,
1151
,
1134
,
/* 360 */
111
0
,
1102
,
1113
,
1114
,
1115
,
1116
,
1118
,
1131
,
1136
,
1132
,
/* 370 */
113
5
,
1153
,
1139
,
1142
,
1154
,
1157
,
1158
,
1160
,
1163
,
102
5
,
/* 370 */
113
3
,
1148
,
1135
,
1137
,
1150
,
1144
,
1146
,
1153
,
1152
,
115
5
,
/* 380 */
11
22
,
1130
,
1169
,
1133
,
1156
,
1171
,
1172
,
1173
,
1170
,
1174
,
/* 380 */
11
56
,
1158
,
1119
,
1134
,
1161
,
1163
,
1170
,
1171
,
1172
,
1173
,
/* 390 */
117
5
,
1177
,
1181
,
1178
,
1180
,
1179
,
1182
,
1185
,
1186
,
1192
,
/* 390 */
117
4
,
1175
,
1178
,
1176
,
1177
,
1182
,
1179
,
1181
,
1183
,
1185
,
/* 400 */
11
93
,
1194
,
1189
,
1196
,
1198
,
1199
,
1201
,
1207
,
1209
,
1210
,
/* 400 */
11
86
,
1189
,
1193
,
1195
,
1196
,
1187
,
1198
,
1199
,
1203
,
1210
,
/* 410 */
121
2
,
1213
,
1187
,
1214
,
1202
,
1218
,
1190
,
1219
,
1221
,
1205
,
/* 410 */
121
4
,
1215
,
1216
,
1218
,
1222
,
1206
,
1207
,
1204
,
1192
,
1232
,
/* 420 */
12
35
,
1188
,
1228
,
1231
,
1232
,
1234
,
1224
,
/* 420 */
12
23
,
1209
,
1238
,
1239
,
1190
,
1228
,
1229
,
1236
,
1241
,
1191
,
};
};
#define YY_REDUCE_COUNT (1
88
)
#define YY_REDUCE_COUNT (1
91
)
#define YY_REDUCE_MIN (-217)
#define YY_REDUCE_MIN (-217)
#define YY_REDUCE_MAX (86
3
)
#define YY_REDUCE_MAX (86
7
)
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
,
...
@@ -547,58 +547,59 @@ static const short yy_reduce_ofst[] = {
...
@@ -547,58 +547,59 @@ static const short yy_reduce_ofst[] = {
/* 90 */
110
,
185
,
327
,
578
,
27
,
54
,
217
,
287
,
311
,
-
10
,
/* 90 */
110
,
185
,
327
,
578
,
27
,
54
,
217
,
287
,
311
,
-
10
,
/* 100 */
-
178
,
-
140
,
204
,
312
,
345
,
268
,
412
,
347
,
381
,
446
,
/* 100 */
-
178
,
-
140
,
204
,
312
,
345
,
268
,
412
,
347
,
381
,
446
,
/* 110 */
415
,
495
,
519
,
471
,
471
,
471
,
476
,
504
,
533
,
575
,
/* 110 */
415
,
495
,
519
,
471
,
471
,
471
,
476
,
504
,
533
,
575
,
/* 120 */
589
,
592
,
593
,
623
,
599
,
643
,
620
,
631
,
650
,
666
,
/* 120 */
589
,
592
,
593
,
623
,
599
,
643
,
620
,
631
,
650
,
668
,
/* 130 */
668
,
676
,
665
,
673
,
679
,
683
,
686
,
689
,
690
,
693
,
/* 130 */
666
,
671
,
676
,
673
,
679
,
683
,
686
,
689
,
690
,
693
,
/* 140 */
699
,
707
,
710
,
680
,
694
,
692
,
733
,
717
,
696
,
705
,
/* 140 */
699
,
707
,
710
,
717
,
680
,
694
,
702
,
733
,
721
,
696
,
/* 150 */
677
,
716
,
719
,
682
,
722
,
724
,
727
,
695
,
700
,
697
,
/* 150 */
739
,
708
,
677
,
719
,
723
,
685
,
730
,
727
,
734
,
705
,
/* 160 */
723
,
471
,
762
,
743
,
736
,
709
,
712
,
725
,
756
,
476
,
/* 160 */
695
,
722
,
716
,
471
,
765
,
748
,
738
,
713
,
735
,
731
,
/* 170 */
772
,
775
,
779
,
782
,
780
,
791
,
806
,
794
,
822
,
829
,
/* 170 */
756
,
476
,
772
,
779
,
783
,
788
,
792
,
793
,
807
,
800
,
/* 180 */
817
,
833
,
835
,
841
,
849
,
843
,
845
,
853
,
863
,
/* 180 */
836
,
830
,
839
,
829
,
834
,
845
,
854
,
858
,
847
,
849
,
/* 190 */
857
,
867
,
};
};
static
const
YYACTIONTYPE
yy_default
[]
=
{
static
const
YYACTIONTYPE
yy_default
[]
=
{
/* 0 */
99
6
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 0 */
99
9
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
/* 10 */
99
6
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 10 */
99
9
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
/* 20 */
99
6
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 20 */
99
9
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
/* 30 */
99
6
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 30 */
99
9
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
/* 40 */
99
6
,
996
,
996
,
996
,
1049
,
996
,
996
,
996
,
996
,
996
,
/* 40 */
99
9
,
999
,
999
,
999
,
1052
,
999
,
999
,
999
,
999
,
999
,
/* 50 */
99
6
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 50 */
99
9
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
/* 60 */
10
47
,
996
,
1255
,
996
,
1161
,
996
,
996
,
996
,
996
,
996
,
/* 60 */
10
50
,
999
,
1258
,
999
,
1164
,
999
,
999
,
999
,
999
,
999
,
/* 70 */
99
6
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 70 */
99
9
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
/* 80 */
99
6
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
1049
,
/* 80 */
99
9
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
1052
,
/* 90 */
126
6
,
1266
,
1266
,
1047
,
996
,
996
,
996
,
996
,
996
,
1132
,
/* 90 */
126
9
,
1269
,
1269
,
1050
,
999
,
999
,
999
,
999
,
999
,
1135
,
/* 100 */
99
6
,
996
,
996
,
996
,
996
,
996
,
996
,
1330
,
996
,
1085
,
/* 100 */
99
9
,
999
,
999
,
999
,
999
,
999
,
999
,
1333
,
999
,
1088
,
/* 110 */
129
0
,
996
,
1282
,
1258
,
1272
,
1259
,
996
,
1315
,
1275
,
996
,
/* 110 */
129
3
,
999
,
1285
,
1261
,
1275
,
1262
,
999
,
1318
,
1278
,
999
,
/* 120 */
116
6
,
1163
,
1163
,
996
,
996
,
1049
,
996
,
996
,
1049
,
996
,
/* 120 */
116
9
,
1166
,
1166
,
999
,
999
,
1052
,
999
,
999
,
1052
,
1052
,
/* 130 */
1049
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 130 */
999
,
1052
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
/* 140 */
99
6
,
996
,
996
,
996
,
996
,
996
,
1047
,
996
,
996
,
996
,
/* 140 */
99
9
,
999
,
999
,
999
,
999
,
999
,
999
,
1050
,
999
,
999
,
/* 150 */
1
297
,
1295
,
996
,
1297
,
1295
,
996
,
996
,
1309
,
1305
,
1288
,
/* 150 */
1
050
,
999
,
1300
,
1298
,
999
,
1300
,
1298
,
999
,
999
,
1312
,
/* 160 */
1
286
,
1272
,
996
,
996
,
996
,
1333
,
1321
,
1317
,
996
,
996
,
/* 160 */
1
308
,
1291
,
1289
,
1275
,
999
,
999
,
999
,
1336
,
1324
,
1320
,
/* 170 */
1295
,
996
,
996
,
1295
,
996
,
1174
,
996
,
996
,
996
,
1047
,
/* 170 */
999
,
999
,
1298
,
999
,
999
,
1298
,
999
,
1177
,
999
,
999
,
/* 180 */
996
,
1101
,
996
,
1047
,
996
,
1135
,
1135
,
1050
,
1001
,
996
,
/* 180 */
1050
,
999
,
1050
,
999
,
1104
,
999
,
1050
,
999
,
1138
,
1138
,
/* 190 */
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
1227
,
/* 190 */
1053
,
1004
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
/* 200 */
1308
,
1307
,
1226
,
1232
,
1231
,
1230
,
996
,
996
,
996
,
1221
,
/* 200 */
999
,
999
,
1230
,
1311
,
1310
,
1229
,
1235
,
1234
,
1233
,
999
,
/* 210 */
1222
,
1220
,
1219
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 210 */
999
,
999
,
1224
,
1225
,
1223
,
1222
,
999
,
999
,
999
,
999
,
/* 220 */
99
6
,
996
,
996
,
996
,
1256
,
996
,
1318
,
1322
,
996
,
996
,
/* 220 */
99
9
,
999
,
999
,
999
,
999
,
999
,
999
,
1259
,
999
,
1321
,
/* 230 */
996
,
1206
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 230 */
1325
,
999
,
999
,
999
,
1209
,
999
,
999
,
999
,
999
,
999
,
/* 240 */
99
6
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 240 */
99
9
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
/* 250 */
99
6
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 250 */
99
9
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
/* 260 */
99
6
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 260 */
99
9
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
/* 270 */
99
6
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 270 */
99
9
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
/* 280 */
99
6
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 280 */
99
9
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
/* 290 */
99
6
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 290 */
99
9
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
/* 300 */
99
6
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
127
9
,
/* 300 */
99
9
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
99
9
,
/* 310 */
1289
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 310 */
999
,
999
,
1282
,
1292
,
999
,
999
,
999
,
999
,
999
,
999
,
/* 320 */
99
6
,
1206
,
996
,
1306
,
996
,
1265
,
1261
,
996
,
996
,
1257
,
/* 320 */
99
9
,
999
,
999
,
999
,
1209
,
999
,
1309
,
999
,
1268
,
1264
,
/* 330 */
99
6
,
996
,
1316
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 330 */
99
9
,
999
,
1260
,
999
,
999
,
1319
,
999
,
999
,
999
,
999
,
/* 340 */
99
6
,
1251
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 340 */
99
9
,
999
,
999
,
999
,
1254
,
999
,
999
,
999
,
999
,
999
,
/* 350 */
99
6
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
1205
,
996
,
/* 350 */
99
9
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
/* 360 */
99
6
,
996
,
996
,
996
,
996
,
996
,
1129
,
996
,
996
,
996
,
/* 360 */
99
9
,
1208
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
1132
,
/* 370 */
99
6
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
1114
,
/* 370 */
99
9
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
/* 380 */
1112
,
1111
,
1110
,
996
,
1107
,
996
,
996
,
996
,
996
,
996
,
/* 380 */
999
,
999
,
1117
,
1115
,
1114
,
1113
,
999
,
1110
,
999
,
999
,
/* 390 */
99
6
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 390 */
99
9
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
/* 400 */
99
6
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 400 */
99
9
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
/* 410 */
99
6
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 410 */
99
9
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
/* 420 */
99
6
,
996
,
996
,
996
,
996
,
996
,
996
,
/* 420 */
99
9
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
999
,
};
};
/********** End of lemon-generated parsing tables *****************************/
/********** End of lemon-generated parsing tables *****************************/
...
@@ -1142,9 +1143,9 @@ static const char *const yyRuleName[] = {
...
@@ -1142,9 +1143,9 @@ static const char *const yyRuleName[] = {
/* 169 */
"func_name_list ::= func_name"
,
/* 169 */
"func_name_list ::= func_name"
,
/* 170 */
"func_name_list ::= func_name_list NK_COMMA col_name"
,
/* 170 */
"func_name_list ::= func_name_list NK_COMMA col_name"
,
/* 171 */
"func_name ::= function_name"
,
/* 171 */
"func_name ::= function_name"
,
/* 172 */
"cmd ::= CREATE SMA INDEX index_name ON table_name index_options"
,
/* 172 */
"cmd ::= CREATE SMA INDEX
not_exists_opt
index_name ON table_name index_options"
,
/* 173 */
"cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP"
,
/* 173 */
"cmd ::= CREATE FULLTEXT INDEX
not_exists_opt
index_name ON table_name NK_LP col_name_list NK_RP"
,
/* 174 */
"cmd ::= DROP INDEX index_name ON table_name"
,
/* 174 */
"cmd ::= DROP INDEX
exists_opt
index_name ON table_name"
,
/* 175 */
"index_options ::="
,
/* 175 */
"index_options ::="
,
/* 176 */
"index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt"
,
/* 176 */
"index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt"
,
/* 177 */
"index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt"
,
/* 177 */
"index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt"
,
...
@@ -2042,9 +2043,9 @@ static const struct {
...
@@ -2042,9 +2043,9 @@ static const struct {
{
195
,
-
1
},
/* (169) func_name_list ::= func_name */
{
195
,
-
1
},
/* (169) func_name_list ::= func_name */
{
195
,
-
3
},
/* (170) func_name_list ::= func_name_list NK_COMMA col_name */
{
195
,
-
3
},
/* (170) func_name_list ::= func_name_list NK_COMMA col_name */
{
202
,
-
1
},
/* (171) func_name ::= function_name */
{
202
,
-
1
},
/* (171) func_name ::= function_name */
{
163
,
-
7
},
/* (172) cmd ::= CREATE SMA INDEX
index_name ON table_name index_options */
{
163
,
-
8
},
/* (172) cmd ::= CREATE SMA INDEX not_exists_opt
index_name ON table_name index_options */
{
163
,
-
9
},
/* (173) cmd ::= CREATE FULLTEXT INDEX
index_name ON table_name NK_LP col_name_list NK_RP */
{
163
,
-
10
},
/* (173) cmd ::= CREATE FULLTEXT INDEX not_exists_opt
index_name ON table_name NK_LP col_name_list NK_RP */
{
163
,
-
5
},
/* (174) cmd ::= DROP INDEX
index_name ON table_name */
{
163
,
-
6
},
/* (174) cmd ::= DROP INDEX exists_opt
index_name ON table_name */
{
205
,
0
},
/* (175) index_options ::= */
{
205
,
0
},
/* (175) index_options ::= */
{
205
,
-
9
},
/* (176) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */
{
205
,
-
9
},
/* (176) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */
{
205
,
-
11
},
/* (177) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */
{
205
,
-
11
},
/* (177) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */
...
@@ -2840,14 +2841,14 @@ static YYACTIONTYPE yy_reduce(
...
@@ -2840,14 +2841,14 @@ static YYACTIONTYPE yy_reduce(
{
yylhsminor
.
yy140
=
createFunctionNode
(
pCxt
,
&
yymsp
[
0
].
minor
.
yy149
,
NULL
);
}
{
yylhsminor
.
yy140
=
createFunctionNode
(
pCxt
,
&
yymsp
[
0
].
minor
.
yy149
,
NULL
);
}
yymsp
[
0
].
minor
.
yy140
=
yylhsminor
.
yy140
;
yymsp
[
0
].
minor
.
yy140
=
yylhsminor
.
yy140
;
break
;
break
;
case
172
:
/* cmd ::= CREATE SMA INDEX index_name ON table_name index_options */
case
172
:
/* cmd ::= CREATE SMA INDEX
not_exists_opt
index_name ON table_name index_options */
{
pCxt
->
pRootNode
=
createCreateIndexStmt
(
pCxt
,
INDEX_TYPE_SMA
,
&
yymsp
[
-
3
].
minor
.
yy149
,
&
yymsp
[
-
1
].
minor
.
yy149
,
NULL
,
yymsp
[
0
].
minor
.
yy140
);
}
{
pCxt
->
pRootNode
=
createCreateIndexStmt
(
pCxt
,
INDEX_TYPE_SMA
,
yymsp
[
-
4
].
minor
.
yy497
,
&
yymsp
[
-
3
].
minor
.
yy149
,
&
yymsp
[
-
1
].
minor
.
yy149
,
NULL
,
yymsp
[
0
].
minor
.
yy140
);
}
break
;
break
;
case
173
:
/* cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */
case
173
:
/* cmd ::= CREATE FULLTEXT INDEX
not_exists_opt
index_name ON table_name NK_LP col_name_list NK_RP */
{
pCxt
->
pRootNode
=
createCreateIndexStmt
(
pCxt
,
INDEX_TYPE_FULLTEXT
,
&
yymsp
[
-
5
].
minor
.
yy149
,
&
yymsp
[
-
3
].
minor
.
yy149
,
yymsp
[
-
1
].
minor
.
yy136
,
NULL
);
}
{
pCxt
->
pRootNode
=
createCreateIndexStmt
(
pCxt
,
INDEX_TYPE_FULLTEXT
,
yymsp
[
-
6
].
minor
.
yy497
,
&
yymsp
[
-
5
].
minor
.
yy149
,
&
yymsp
[
-
3
].
minor
.
yy149
,
yymsp
[
-
1
].
minor
.
yy136
,
NULL
);
}
break
;
break
;
case
174
:
/* cmd ::= DROP INDEX index_name ON table_name */
case
174
:
/* cmd ::= DROP INDEX
exists_opt
index_name ON table_name */
{
pCxt
->
pRootNode
=
createDropIndexStmt
(
pCxt
,
&
yymsp
[
-
2
].
minor
.
yy149
,
&
yymsp
[
0
].
minor
.
yy149
);
}
{
pCxt
->
pRootNode
=
createDropIndexStmt
(
pCxt
,
yymsp
[
-
3
].
minor
.
yy497
,
&
yymsp
[
-
2
].
minor
.
yy149
,
&
yymsp
[
0
].
minor
.
yy149
);
}
break
;
break
;
case
176
:
/* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */
case
176
:
/* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */
{
yymsp
[
-
8
].
minor
.
yy140
=
createIndexOption
(
pCxt
,
yymsp
[
-
6
].
minor
.
yy136
,
releaseRawExprNode
(
pCxt
,
yymsp
[
-
2
].
minor
.
yy140
),
NULL
,
yymsp
[
0
].
minor
.
yy140
);
}
{
yymsp
[
-
8
].
minor
.
yy140
=
createIndexOption
(
pCxt
,
yymsp
[
-
6
].
minor
.
yy136
,
releaseRawExprNode
(
pCxt
,
yymsp
[
-
2
].
minor
.
yy140
),
NULL
,
yymsp
[
0
].
minor
.
yy140
);
}
...
...
source/libs/parser/test/parserAstTest.cpp
浏览文件 @
bdbf365e
...
@@ -358,7 +358,6 @@ TEST_F(ParserTest, selectSemanticError) {
...
@@ -358,7 +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
,
showUsers
)
{
TEST_F
(
ParserTest
,
showUsers
)
{
setDatabase
(
"root"
,
"test"
);
setDatabase
(
"root"
,
"test"
);
...
@@ -366,8 +365,6 @@ TEST_F(ParserTest, showUsers) {
...
@@ -366,8 +365,6 @@ TEST_F(ParserTest, showUsers) {
ASSERT_TRUE
(
run
());
ASSERT_TRUE
(
run
());
}
}
TEST_F
(
ParserTest
,
createDnode
)
{
TEST_F
(
ParserTest
,
createDnode
)
{
setDatabase
(
"root"
,
"test"
);
setDatabase
(
"root"
,
"test"
);
...
...
source/libs/parser/test/parserInsertTest.cpp
浏览文件 @
bdbf365e
...
@@ -72,7 +72,7 @@ protected:
...
@@ -72,7 +72,7 @@ protected:
SSubmitBlk
*
blk
=
(
SSubmitBlk
*
)(
submit
+
1
);
SSubmitBlk
*
blk
=
(
SSubmitBlk
*
)(
submit
+
1
);
for
(
int32_t
i
=
0
;
i
<
numOfBlocks
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfBlocks
;
++
i
)
{
cout
<<
"Block:"
<<
i
<<
endl
;
cout
<<
"Block:"
<<
i
<<
endl
;
cout
<<
"
\t
uid:"
<<
be64toh
(
blk
->
uid
)
<<
", tid:"
<<
ntohl
(
blk
->
t
id
)
<<
", padding:"
<<
ntohl
(
blk
->
padding
)
<<
", sversion:"
<<
ntohl
(
blk
->
sversion
)
cout
<<
"
\t
uid:"
<<
be64toh
(
blk
->
uid
)
<<
", tid:"
<<
be64toh
(
blk
->
su
id
)
<<
", padding:"
<<
ntohl
(
blk
->
padding
)
<<
", sversion:"
<<
ntohl
(
blk
->
sversion
)
<<
", dataLen:"
<<
ntohl
(
blk
->
dataLen
)
<<
", schemaLen:"
<<
ntohl
(
blk
->
schemaLen
)
<<
", numOfRows:"
<<
ntohs
(
blk
->
numOfRows
)
<<
endl
;
<<
", dataLen:"
<<
ntohl
(
blk
->
dataLen
)
<<
", schemaLen:"
<<
ntohl
(
blk
->
schemaLen
)
<<
", numOfRows:"
<<
ntohs
(
blk
->
numOfRows
)
<<
endl
;
blk
=
(
SSubmitBlk
*
)(
blk
->
data
+
ntohl
(
blk
->
dataLen
));
blk
=
(
SSubmitBlk
*
)(
blk
->
data
+
ntohl
(
blk
->
dataLen
));
}
}
...
...
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
bdbf365e
...
@@ -213,6 +213,33 @@ static SNodeptr createPrimaryKeyCol(SPhysiPlanContext* pCxt, uint64_t tableId) {
...
@@ -213,6 +213,33 @@ static SNodeptr createPrimaryKeyCol(SPhysiPlanContext* pCxt, uint64_t tableId) {
return
pCol
;
return
pCol
;
}
}
static
int32_t
colIdCompare
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
SColumnNode
*
pLeftCol
=
*
(
SColumnNode
**
)
pLeft
;
SColumnNode
*
pRightCol
=
*
(
SColumnNode
**
)
pRight
;
return
pLeftCol
->
colId
>
pRightCol
->
colId
?
1
:
-
1
;
}
static
int32_t
sortScanCols
(
SNodeList
*
pScanCols
)
{
SArray
*
pArray
=
taosArrayInit
(
LIST_LENGTH
(
pScanCols
),
POINTER_BYTES
);
if
(
NULL
==
pArray
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
SNode
*
pCol
=
NULL
;
FOREACH
(
pCol
,
pScanCols
)
{
taosArrayPush
(
pArray
,
&
pCol
);
}
taosArraySort
(
pArray
,
colIdCompare
);
int32_t
index
=
0
;
FOREACH
(
pCol
,
pScanCols
)
{
REPLACE_NODE
(
taosArrayGetP
(
pArray
,
index
++
));
}
taosArrayDestroy
(
pArray
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
createScanCols
(
SPhysiPlanContext
*
pCxt
,
SScanPhysiNode
*
pScanPhysiNode
,
SNodeList
*
pScanCols
)
{
static
int32_t
createScanCols
(
SPhysiPlanContext
*
pCxt
,
SScanPhysiNode
*
pScanPhysiNode
,
SNodeList
*
pScanCols
)
{
if
(
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
==
nodeType
(
pScanPhysiNode
)
if
(
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
==
nodeType
(
pScanPhysiNode
)
||
QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN
==
nodeType
(
pScanPhysiNode
))
{
||
QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN
==
nodeType
(
pScanPhysiNode
))
{
...
@@ -235,6 +262,7 @@ static int32_t createScanCols(SPhysiPlanContext* pCxt, SScanPhysiNode* pScanPhys
...
@@ -235,6 +262,7 @@ static int32_t createScanCols(SPhysiPlanContext* pCxt, SScanPhysiNode* pScanPhys
CHECK_ALLOC
(
pScanPhysiNode
->
pScanCols
,
TSDB_CODE_OUT_OF_MEMORY
);
CHECK_ALLOC
(
pScanPhysiNode
->
pScanCols
,
TSDB_CODE_OUT_OF_MEMORY
);
}
}
// return sortScanCols(pScanPhysiNode->pScanCols);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
...
source/libs/planner/test/plannerTest.cpp
浏览文件 @
bdbf365e
...
@@ -52,7 +52,11 @@ protected:
...
@@ -52,7 +52,11 @@ protected:
const
string
syntaxTreeStr
=
toString
(
query_
->
pRoot
,
false
);
const
string
syntaxTreeStr
=
toString
(
query_
->
pRoot
,
false
);
SLogicNode
*
pLogicNode
=
nullptr
;
SLogicNode
*
pLogicNode
=
nullptr
;
SPlanContext
cxt
=
{
.
queryId
=
1
,
.
acctId
=
0
,
.
streamQuery
=
streamQuery
};
SPlanContext
cxt
=
{
0
};
cxt
.
queryId
=
1
;
cxt
.
acctId
=
0
;
cxt
.
streamQuery
=
streamQuery
;
setPlanContext
(
query_
,
&
cxt
);
setPlanContext
(
query_
,
&
cxt
);
code
=
createLogicPlan
(
&
cxt
,
&
pLogicNode
);
code
=
createLogicPlan
(
&
cxt
,
&
pLogicNode
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
@@ -108,6 +112,11 @@ private:
...
@@ -108,6 +112,11 @@ private:
if
(
QUERY_NODE_CREATE_TOPIC_STMT
==
nodeType
(
pQuery
->
pRoot
))
{
if
(
QUERY_NODE_CREATE_TOPIC_STMT
==
nodeType
(
pQuery
->
pRoot
))
{
pCxt
->
pAstRoot
=
((
SCreateTopicStmt
*
)
pQuery
->
pRoot
)
->
pQuery
;
pCxt
->
pAstRoot
=
((
SCreateTopicStmt
*
)
pQuery
->
pRoot
)
->
pQuery
;
pCxt
->
topicQuery
=
true
;
pCxt
->
topicQuery
=
true
;
}
else
if
(
QUERY_NODE_CREATE_INDEX_STMT
==
nodeType
(
pQuery
->
pRoot
))
{
SMCreateSmaReq
req
=
{
0
};
tDeserializeSMCreateSmaReq
(
pQuery
->
pCmdMsg
->
pMsg
,
pQuery
->
pCmdMsg
->
msgLen
,
&
req
);
nodesStringToNode
(
req
.
ast
,
&
pCxt
->
pAstRoot
);
pCxt
->
streamQuery
=
true
;
}
else
{
}
else
{
pCxt
->
pAstRoot
=
pQuery
->
pRoot
;
pCxt
->
pAstRoot
=
pQuery
->
pRoot
;
}
}
...
@@ -211,3 +220,10 @@ TEST_F(PlannerTest, stream) {
...
@@ -211,3 +220,10 @@ TEST_F(PlannerTest, stream) {
bind
(
"SELECT sum(c1) FROM st1"
);
bind
(
"SELECT sum(c1) FROM st1"
);
ASSERT_TRUE
(
run
(
true
));
ASSERT_TRUE
(
run
(
true
));
}
}
TEST_F
(
PlannerTest
,
createSmaIndex
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"create sma index index1 on t1 function(max(c1), min(c3 + 10), sum(c4)) INTERVAL(10s)"
);
ASSERT_TRUE
(
run
());
}
source/libs/sync/inc/syncRaftEntry.h
浏览文件 @
bdbf365e
...
@@ -27,6 +27,12 @@ extern "C" {
...
@@ -27,6 +27,12 @@ extern "C" {
#include "syncMessage.h"
#include "syncMessage.h"
#include "taosdef.h"
#include "taosdef.h"
typedef
enum
EntryType
{
SYNC_RAFT_ENTRY_NOOP
=
0
,
SYNC_RAFT_ENTRY_DATA
=
1
,
SYNC_RAFT_ENTRY_CONFIG
=
2
,
}
EntryType
;
typedef
struct
SSyncRaftEntry
{
typedef
struct
SSyncRaftEntry
{
uint32_t
bytes
;
uint32_t
bytes
;
uint32_t
msgType
;
uint32_t
msgType
;
...
@@ -35,12 +41,15 @@ typedef struct SSyncRaftEntry {
...
@@ -35,12 +41,15 @@ typedef struct SSyncRaftEntry {
bool
isWeak
;
bool
isWeak
;
SyncTerm
term
;
SyncTerm
term
;
SyncIndex
index
;
SyncIndex
index
;
EntryType
entryType
;
uint32_t
dataLen
;
uint32_t
dataLen
;
char
data
[];
char
data
[];
}
SSyncRaftEntry
;
}
SSyncRaftEntry
;
SSyncRaftEntry
*
syncEntryBuild
(
uint32_t
dataLen
);
SSyncRaftEntry
*
syncEntryBuild
(
uint32_t
dataLen
);
SSyncRaftEntry
*
syncEntryBuild2
(
SyncClientRequest
*
pMsg
,
SyncTerm
term
,
SyncIndex
index
);
// step 4
SSyncRaftEntry
*
syncEntryBuild2
(
SyncClientRequest
*
pMsg
,
SyncTerm
term
,
SyncIndex
index
);
// step 4
SSyncRaftEntry
*
syncEntryBuild3
(
SyncClientRequest
*
pMsg
,
SyncTerm
term
,
SyncIndex
index
,
EntryType
entryType
);
SSyncRaftEntry
*
syncEntryBuildNoop
(
SyncTerm
term
,
SyncIndex
index
);
void
syncEntryDestory
(
SSyncRaftEntry
*
pEntry
);
void
syncEntryDestory
(
SSyncRaftEntry
*
pEntry
);
char
*
syncEntrySerialize
(
const
SSyncRaftEntry
*
pEntry
,
uint32_t
*
len
);
// step 5
char
*
syncEntrySerialize
(
const
SSyncRaftEntry
*
pEntry
,
uint32_t
*
len
);
// step 5
SSyncRaftEntry
*
syncEntryDeserialize
(
const
char
*
buf
,
uint32_t
len
);
// step 6
SSyncRaftEntry
*
syncEntryDeserialize
(
const
char
*
buf
,
uint32_t
len
);
// step 6
...
...
source/libs/sync/src/syncAppendEntries.c
浏览文件 @
bdbf365e
...
@@ -199,6 +199,9 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
...
@@ -199,6 +199,9 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
SSyncRaftEntry
*
pRollBackEntry
=
logStoreGetEntry
(
ths
->
pLogStore
,
index
);
SSyncRaftEntry
*
pRollBackEntry
=
logStoreGetEntry
(
ths
->
pLogStore
,
index
);
assert
(
pRollBackEntry
!=
NULL
);
assert
(
pRollBackEntry
!=
NULL
);
// maybe is a NOOP ENTRY
// assert(pRollBackEntry->entryType == SYNC_RAFT_ENTRY_DATA);
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
;
syncEntry2OriginalRpc
(
pRollBackEntry
,
&
rpcMsg
);
syncEntry2OriginalRpc
(
pRollBackEntry
,
&
rpcMsg
);
ths
->
pFsm
->
FpRollBackCb
(
ths
->
pFsm
,
&
rpcMsg
,
pRollBackEntry
->
index
,
pRollBackEntry
->
isWeak
,
0
,
ths
->
state
);
ths
->
pFsm
->
FpRollBackCb
(
ths
->
pFsm
,
&
rpcMsg
,
pRollBackEntry
->
index
,
pRollBackEntry
->
isWeak
,
0
,
ths
->
state
);
...
@@ -217,7 +220,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
...
@@ -217,7 +220,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
;
syncEntry2OriginalRpc
(
pAppendEntry
,
&
rpcMsg
);
syncEntry2OriginalRpc
(
pAppendEntry
,
&
rpcMsg
);
if
(
ths
->
pFsm
!=
NULL
)
{
if
(
ths
->
pFsm
!=
NULL
)
{
if
(
ths
->
pFsm
->
FpPreCommitCb
!=
NULL
)
{
if
(
ths
->
pFsm
->
FpPreCommitCb
!=
NULL
&&
pAppendEntry
->
entryType
==
SYNC_RAFT_ENTRY_DATA
)
{
ths
->
pFsm
->
FpPreCommitCb
(
ths
->
pFsm
,
&
rpcMsg
,
pAppendEntry
->
index
,
pAppendEntry
->
isWeak
,
2
,
ths
->
state
);
ths
->
pFsm
->
FpPreCommitCb
(
ths
->
pFsm
,
&
rpcMsg
,
pAppendEntry
->
index
,
pAppendEntry
->
isWeak
,
2
,
ths
->
state
);
}
}
}
}
...
@@ -242,7 +245,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
...
@@ -242,7 +245,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
;
syncEntry2OriginalRpc
(
pAppendEntry
,
&
rpcMsg
);
syncEntry2OriginalRpc
(
pAppendEntry
,
&
rpcMsg
);
if
(
ths
->
pFsm
!=
NULL
)
{
if
(
ths
->
pFsm
!=
NULL
)
{
if
(
ths
->
pFsm
->
FpPreCommitCb
!=
NULL
)
{
if
(
ths
->
pFsm
->
FpPreCommitCb
!=
NULL
&&
pAppendEntry
->
entryType
==
SYNC_RAFT_ENTRY_DATA
)
{
ths
->
pFsm
->
FpPreCommitCb
(
ths
->
pFsm
,
&
rpcMsg
,
pAppendEntry
->
index
,
pAppendEntry
->
isWeak
,
3
,
ths
->
state
);
ths
->
pFsm
->
FpPreCommitCb
(
ths
->
pFsm
,
&
rpcMsg
,
pAppendEntry
->
index
,
pAppendEntry
->
isWeak
,
3
,
ths
->
state
);
}
}
}
}
...
@@ -298,7 +301,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
...
@@ -298,7 +301,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) {
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
;
syncEntry2OriginalRpc
(
pEntry
,
&
rpcMsg
);
syncEntry2OriginalRpc
(
pEntry
,
&
rpcMsg
);
if
(
ths
->
pFsm
->
FpCommitCb
!=
NULL
)
{
if
(
ths
->
pFsm
->
FpCommitCb
!=
NULL
&&
pEntry
->
entryType
==
SYNC_RAFT_ENTRY_DATA
)
{
ths
->
pFsm
->
FpCommitCb
(
ths
->
pFsm
,
&
rpcMsg
,
pEntry
->
index
,
pEntry
->
isWeak
,
0
,
ths
->
state
);
ths
->
pFsm
->
FpCommitCb
(
ths
->
pFsm
,
&
rpcMsg
,
pEntry
->
index
,
pEntry
->
isWeak
,
0
,
ths
->
state
);
}
}
...
...
source/libs/sync/src/syncCommit.c
浏览文件 @
bdbf365e
...
@@ -97,7 +97,7 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) {
...
@@ -97,7 +97,7 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) {
SRpcMsg
rpcMsg
;
SRpcMsg
rpcMsg
;
syncEntry2OriginalRpc
(
pEntry
,
&
rpcMsg
);
syncEntry2OriginalRpc
(
pEntry
,
&
rpcMsg
);
if
(
pSyncNode
->
pFsm
->
FpCommitCb
!=
NULL
)
{
if
(
pSyncNode
->
pFsm
->
FpCommitCb
!=
NULL
&&
pEntry
->
entryType
==
SYNC_RAFT_ENTRY_DATA
)
{
pSyncNode
->
pFsm
->
FpCommitCb
(
pSyncNode
->
pFsm
,
&
rpcMsg
,
pEntry
->
index
,
pEntry
->
isWeak
,
0
,
pSyncNode
->
state
);
pSyncNode
->
pFsm
->
FpCommitCb
(
pSyncNode
->
pFsm
,
&
rpcMsg
,
pEntry
->
index
,
pEntry
->
isWeak
,
0
,
pSyncNode
->
state
);
}
}
...
...
source/libs/sync/src/syncIO.c
浏览文件 @
bdbf365e
...
@@ -29,7 +29,7 @@ static int32_t syncIODestroy(SSyncIO *io);
...
@@ -29,7 +29,7 @@ static int32_t syncIODestroy(SSyncIO *io);
static
int32_t
syncIOStartInternal
(
SSyncIO
*
io
);
static
int32_t
syncIOStartInternal
(
SSyncIO
*
io
);
static
int32_t
syncIOStopInternal
(
SSyncIO
*
io
);
static
int32_t
syncIOStopInternal
(
SSyncIO
*
io
);
static
void
*
syncIOConsumerFunc
(
void
*
param
);
static
void
*
syncIOConsumerFunc
(
void
*
param
);
static
void
syncIOProcessRequest
(
void
*
pParent
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
);
static
void
syncIOProcessRequest
(
void
*
pParent
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
);
static
void
syncIOProcessReply
(
void
*
pParent
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
);
static
void
syncIOProcessReply
(
void
*
pParent
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
);
static
int32_t
syncIOAuth
(
void
*
parent
,
char
*
meterId
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
);
static
int32_t
syncIOAuth
(
void
*
parent
,
char
*
meterId
,
char
*
spi
,
char
*
encrypt
,
char
*
secret
,
char
*
ckey
);
...
@@ -75,6 +75,7 @@ int32_t syncIOSendMsg(void *clientRpc, const SEpSet *pEpSet, SRpcMsg *pMsg) {
...
@@ -75,6 +75,7 @@ int32_t syncIOSendMsg(void *clientRpc, const SEpSet *pEpSet, SRpcMsg *pMsg) {
syncRpcMsgPrint2
(
logBuf
,
pMsg
);
syncRpcMsgPrint2
(
logBuf
,
pMsg
);
pMsg
->
handle
=
NULL
;
pMsg
->
handle
=
NULL
;
pMsg
->
noResp
=
1
;
rpcSendRequest
(
clientRpc
,
pEpSet
,
pMsg
,
NULL
);
rpcSendRequest
(
clientRpc
,
pEpSet
,
pMsg
,
NULL
);
return
ret
;
return
ret
;
}
}
...
@@ -234,9 +235,9 @@ static int32_t syncIOStopInternal(SSyncIO *io) {
...
@@ -234,9 +235,9 @@ static int32_t syncIOStopInternal(SSyncIO *io) {
}
}
static
void
*
syncIOConsumerFunc
(
void
*
param
)
{
static
void
*
syncIOConsumerFunc
(
void
*
param
)
{
SSyncIO
*
io
=
param
;
SSyncIO
*
io
=
param
;
STaosQall
*
qall
;
STaosQall
*
qall
;
SRpcMsg
*
pRpcMsg
,
rpcMsg
;
SRpcMsg
*
pRpcMsg
,
rpcMsg
;
qall
=
taosAllocateQall
();
qall
=
taosAllocateQall
();
while
(
1
)
{
while
(
1
)
{
...
@@ -324,6 +325,7 @@ static void *syncIOConsumerFunc(void *param) {
...
@@ -324,6 +325,7 @@ static void *syncIOConsumerFunc(void *param) {
taosGetQitem
(
qall
,
(
void
**
)
&
pRpcMsg
);
taosGetQitem
(
qall
,
(
void
**
)
&
pRpcMsg
);
rpcFreeCont
(
pRpcMsg
->
pCont
);
rpcFreeCont
(
pRpcMsg
->
pCont
);
/*
if (pRpcMsg->handle != NULL) {
if (pRpcMsg->handle != NULL) {
int msgSize = 32;
int msgSize = 32;
memset(&rpcMsg, 0, sizeof(rpcMsg));
memset(&rpcMsg, 0, sizeof(rpcMsg));
...
@@ -337,6 +339,7 @@ static void *syncIOConsumerFunc(void *param) {
...
@@ -337,6 +339,7 @@ static void *syncIOConsumerFunc(void *param) {
syncRpcMsgPrint2((char *)"syncIOConsumerFunc rpcSendResponse --> ", &rpcMsg);
syncRpcMsgPrint2((char *)"syncIOConsumerFunc rpcSendResponse --> ", &rpcMsg);
rpcSendResponse(&rpcMsg);
rpcSendResponse(&rpcMsg);
}
}
*/
taosFreeQitem
(
pRpcMsg
);
taosFreeQitem
(
pRpcMsg
);
}
}
...
...
source/libs/sync/src/syncMain.c
浏览文件 @
bdbf365e
...
@@ -40,8 +40,10 @@ static int32_t tsNodeRefId = -1;
...
@@ -40,8 +40,10 @@ static int32_t tsNodeRefId = -1;
static
void
syncNodeEqPingTimer
(
void
*
param
,
void
*
tmrId
);
static
void
syncNodeEqPingTimer
(
void
*
param
,
void
*
tmrId
);
static
void
syncNodeEqElectTimer
(
void
*
param
,
void
*
tmrId
);
static
void
syncNodeEqElectTimer
(
void
*
param
,
void
*
tmrId
);
static
void
syncNodeEqHeartbeatTimer
(
void
*
param
,
void
*
tmrId
);
static
void
syncNodeEqHeartbeatTimer
(
void
*
param
,
void
*
tmrId
);
static
int32_t
syncNodeEqNoop
(
SSyncNode
*
ths
);
static
int32_t
syncNodeAppendNoop
(
SSyncNode
*
ths
);
//
on
message ----
//
process
message ----
static
int32_t
syncNodeOnPingCb
(
SSyncNode
*
ths
,
SyncPing
*
pMsg
);
static
int32_t
syncNodeOnPingCb
(
SSyncNode
*
ths
,
SyncPing
*
pMsg
);
static
int32_t
syncNodeOnPingReplyCb
(
SSyncNode
*
ths
,
SyncPingReply
*
pMsg
);
static
int32_t
syncNodeOnPingReplyCb
(
SSyncNode
*
ths
,
SyncPingReply
*
pMsg
);
static
int32_t
syncNodeOnClientRequestCb
(
SSyncNode
*
ths
,
SyncClientRequest
*
pMsg
);
static
int32_t
syncNodeOnClientRequestCb
(
SSyncNode
*
ths
,
SyncClientRequest
*
pMsg
);
...
@@ -669,6 +671,10 @@ void syncNodeCandidate2Leader(SSyncNode* pSyncNode) {
...
@@ -669,6 +671,10 @@ void syncNodeCandidate2Leader(SSyncNode* pSyncNode) {
assert
(
pSyncNode
->
state
==
TAOS_SYNC_STATE_CANDIDATE
);
assert
(
pSyncNode
->
state
==
TAOS_SYNC_STATE_CANDIDATE
);
assert
(
voteGrantedMajority
(
pSyncNode
->
pVotesGranted
));
assert
(
voteGrantedMajority
(
pSyncNode
->
pVotesGranted
));
syncNodeBecomeLeader
(
pSyncNode
);
syncNodeBecomeLeader
(
pSyncNode
);
// Raft 3.6.2 Committing entries from previous terms
syncNodeAppendNoop
(
pSyncNode
);
// syncNodeEqNoop(pSyncNode);
}
}
void
syncNodeFollower2Candidate
(
SSyncNode
*
pSyncNode
)
{
void
syncNodeFollower2Candidate
(
SSyncNode
*
pSyncNode
)
{
...
@@ -803,6 +809,47 @@ static void syncNodeEqHeartbeatTimer(void* param, void* tmrId) {
...
@@ -803,6 +809,47 @@ static void syncNodeEqHeartbeatTimer(void* param, void* tmrId) {
}
}
}
}
static
int32_t
syncNodeEqNoop
(
SSyncNode
*
ths
)
{
int32_t
ret
=
0
;
assert
(
ths
->
state
==
TAOS_SYNC_STATE_LEADER
);
SyncIndex
index
=
ths
->
pLogStore
->
getLastIndex
(
ths
->
pLogStore
)
+
1
;
SyncTerm
term
=
ths
->
pRaftStore
->
currentTerm
;
SSyncRaftEntry
*
pEntry
=
syncEntryBuildNoop
(
term
,
index
);
assert
(
pEntry
!=
NULL
);
uint32_t
entryLen
;
char
*
serialized
=
syncEntrySerialize
(
pEntry
,
&
entryLen
);
SyncClientRequest
*
pSyncMsg
=
syncClientRequestBuild
(
entryLen
);
assert
(
pSyncMsg
->
dataLen
==
entryLen
);
memcpy
(
pSyncMsg
->
data
,
serialized
,
entryLen
);
SRpcMsg
rpcMsg
;
syncClientRequest2RpcMsg
(
pSyncMsg
,
&
rpcMsg
);
ths
->
FpEqMsg
(
ths
->
queue
,
&
rpcMsg
);
free
(
serialized
);
syncClientRequestDestroy
(
pSyncMsg
);
return
ret
;
}
static
int32_t
syncNodeAppendNoop
(
SSyncNode
*
ths
)
{
int32_t
ret
=
0
;
SyncIndex
index
=
ths
->
pLogStore
->
getLastIndex
(
ths
->
pLogStore
)
+
1
;
SyncTerm
term
=
ths
->
pRaftStore
->
currentTerm
;
SSyncRaftEntry
*
pEntry
=
syncEntryBuildNoop
(
term
,
index
);
assert
(
pEntry
!=
NULL
);
if
(
ths
->
state
==
TAOS_SYNC_STATE_LEADER
)
{
ths
->
pLogStore
->
appendEntry
(
ths
->
pLogStore
,
pEntry
);
syncNodeReplicate
(
ths
);
}
return
ret
;
}
// on message ----
// on message ----
static
int32_t
syncNodeOnPingCb
(
SSyncNode
*
ths
,
SyncPing
*
pMsg
)
{
static
int32_t
syncNodeOnPingCb
(
SSyncNode
*
ths
,
SyncPing
*
pMsg
)
{
int32_t
ret
=
0
;
int32_t
ret
=
0
;
...
@@ -851,7 +898,7 @@ static int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg
...
@@ -851,7 +898,7 @@ static int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg
syncEntry2OriginalRpc
(
pEntry
,
&
rpcMsg
);
syncEntry2OriginalRpc
(
pEntry
,
&
rpcMsg
);
if
(
ths
->
pFsm
!=
NULL
)
{
if
(
ths
->
pFsm
!=
NULL
)
{
if
(
ths
->
pFsm
->
FpPreCommitCb
!=
NULL
)
{
if
(
ths
->
pFsm
->
FpPreCommitCb
!=
NULL
&&
pEntry
->
entryType
==
SYNC_RAFT_ENTRY_DATA
)
{
ths
->
pFsm
->
FpPreCommitCb
(
ths
->
pFsm
,
&
rpcMsg
,
pEntry
->
index
,
pEntry
->
isWeak
,
0
,
ths
->
state
);
ths
->
pFsm
->
FpPreCommitCb
(
ths
->
pFsm
,
&
rpcMsg
,
pEntry
->
index
,
pEntry
->
isWeak
,
0
,
ths
->
state
);
}
}
}
}
...
@@ -866,7 +913,7 @@ static int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg
...
@@ -866,7 +913,7 @@ static int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg
syncEntry2OriginalRpc
(
pEntry
,
&
rpcMsg
);
syncEntry2OriginalRpc
(
pEntry
,
&
rpcMsg
);
if
(
ths
->
pFsm
!=
NULL
)
{
if
(
ths
->
pFsm
!=
NULL
)
{
if
(
ths
->
pFsm
->
FpPreCommitCb
!=
NULL
)
{
if
(
ths
->
pFsm
->
FpPreCommitCb
!=
NULL
&&
pEntry
->
entryType
==
SYNC_RAFT_ENTRY_DATA
)
{
ths
->
pFsm
->
FpPreCommitCb
(
ths
->
pFsm
,
&
rpcMsg
,
pEntry
->
index
,
pEntry
->
isWeak
,
1
,
ths
->
state
);
ths
->
pFsm
->
FpPreCommitCb
(
ths
->
pFsm
,
&
rpcMsg
,
pEntry
->
index
,
pEntry
->
isWeak
,
1
,
ths
->
state
);
}
}
}
}
...
...
source/libs/sync/src/syncRaftEntry.c
浏览文件 @
bdbf365e
...
@@ -28,6 +28,13 @@ SSyncRaftEntry* syncEntryBuild(uint32_t dataLen) {
...
@@ -28,6 +28,13 @@ SSyncRaftEntry* syncEntryBuild(uint32_t dataLen) {
// step 4. SyncClientRequest => SSyncRaftEntry, add term, index
// step 4. SyncClientRequest => SSyncRaftEntry, add term, index
SSyncRaftEntry
*
syncEntryBuild2
(
SyncClientRequest
*
pMsg
,
SyncTerm
term
,
SyncIndex
index
)
{
SSyncRaftEntry
*
syncEntryBuild2
(
SyncClientRequest
*
pMsg
,
SyncTerm
term
,
SyncIndex
index
)
{
SSyncRaftEntry
*
pEntry
=
syncEntryBuild3
(
pMsg
,
term
,
index
,
SYNC_RAFT_ENTRY_DATA
);
assert
(
pEntry
!=
NULL
);
return
pEntry
;
}
SSyncRaftEntry
*
syncEntryBuild3
(
SyncClientRequest
*
pMsg
,
SyncTerm
term
,
SyncIndex
index
,
EntryType
entryType
)
{
SSyncRaftEntry
*
pEntry
=
syncEntryBuild
(
pMsg
->
dataLen
);
SSyncRaftEntry
*
pEntry
=
syncEntryBuild
(
pMsg
->
dataLen
);
assert
(
pEntry
!=
NULL
);
assert
(
pEntry
!=
NULL
);
...
@@ -37,12 +44,23 @@ SSyncRaftEntry* syncEntryBuild2(SyncClientRequest* pMsg, SyncTerm term, SyncInde
...
@@ -37,12 +44,23 @@ SSyncRaftEntry* syncEntryBuild2(SyncClientRequest* pMsg, SyncTerm term, SyncInde
pEntry
->
isWeak
=
pMsg
->
isWeak
;
pEntry
->
isWeak
=
pMsg
->
isWeak
;
pEntry
->
term
=
term
;
pEntry
->
term
=
term
;
pEntry
->
index
=
index
;
pEntry
->
index
=
index
;
pEntry
->
entryType
=
entryType
;
pEntry
->
dataLen
=
pMsg
->
dataLen
;
pEntry
->
dataLen
=
pMsg
->
dataLen
;
memcpy
(
pEntry
->
data
,
pMsg
->
data
,
pMsg
->
dataLen
);
memcpy
(
pEntry
->
data
,
pMsg
->
data
,
pMsg
->
dataLen
);
return
pEntry
;
return
pEntry
;
}
}
SSyncRaftEntry
*
syncEntryBuildNoop
(
SyncTerm
term
,
SyncIndex
index
)
{
SSyncRaftEntry
*
pEntry
=
syncEntryBuild
(
0
);
assert
(
pEntry
!=
NULL
);
pEntry
->
term
=
term
;
pEntry
->
index
=
index
;
pEntry
->
entryType
=
SYNC_RAFT_ENTRY_NOOP
;
return
pEntry
;
}
void
syncEntryDestory
(
SSyncRaftEntry
*
pEntry
)
{
void
syncEntryDestory
(
SSyncRaftEntry
*
pEntry
)
{
if
(
pEntry
!=
NULL
)
{
if
(
pEntry
!=
NULL
)
{
free
(
pEntry
);
free
(
pEntry
);
...
@@ -85,6 +103,7 @@ cJSON* syncEntry2Json(const SSyncRaftEntry* pEntry) {
...
@@ -85,6 +103,7 @@ cJSON* syncEntry2Json(const SSyncRaftEntry* pEntry) {
cJSON_AddStringToObject
(
pRoot
,
"term"
,
u64buf
);
cJSON_AddStringToObject
(
pRoot
,
"term"
,
u64buf
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
pEntry
->
index
);
snprintf
(
u64buf
,
sizeof
(
u64buf
),
"%lu"
,
pEntry
->
index
);
cJSON_AddStringToObject
(
pRoot
,
"index"
,
u64buf
);
cJSON_AddStringToObject
(
pRoot
,
"index"
,
u64buf
);
cJSON_AddNumberToObject
(
pRoot
,
"entryType"
,
pEntry
->
entryType
);
cJSON_AddNumberToObject
(
pRoot
,
"dataLen"
,
pEntry
->
dataLen
);
cJSON_AddNumberToObject
(
pRoot
,
"dataLen"
,
pEntry
->
dataLen
);
char
*
s
;
char
*
s
;
...
...
source/libs/sync/src/syncRaftLog.c
浏览文件 @
bdbf365e
...
@@ -34,7 +34,7 @@ SSyncLogStore* logStoreCreate(SSyncNode* pSyncNode) {
...
@@ -34,7 +34,7 @@ SSyncLogStore* logStoreCreate(SSyncNode* pSyncNode) {
pLogStore
->
getLastTerm
=
logStoreLastTerm
;
pLogStore
->
getLastTerm
=
logStoreLastTerm
;
pLogStore
->
updateCommitIndex
=
logStoreUpdateCommitIndex
;
pLogStore
->
updateCommitIndex
=
logStoreUpdateCommitIndex
;
pLogStore
->
getCommitIndex
=
logStoreGetCommitIndex
;
pLogStore
->
getCommitIndex
=
logStoreGetCommitIndex
;
return
pLogStore
;
// to avoid compiler error
return
pLogStore
;
}
}
void
logStoreDestory
(
SSyncLogStore
*
pLogStore
)
{
void
logStoreDestory
(
SSyncLogStore
*
pLogStore
)
{
...
@@ -48,18 +48,22 @@ int32_t logStoreAppendEntry(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry) {
...
@@ -48,18 +48,22 @@ int32_t logStoreAppendEntry(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry) {
SSyncLogStoreData
*
pData
=
pLogStore
->
data
;
SSyncLogStoreData
*
pData
=
pLogStore
->
data
;
SWal
*
pWal
=
pData
->
pWal
;
SWal
*
pWal
=
pData
->
pWal
;
assert
(
pEntry
->
index
==
logStoreLastIndex
(
pLogStore
)
+
1
);
SyncIndex
lastIndex
=
logStoreLastIndex
(
pLogStore
);
assert
(
pEntry
->
index
==
lastIndex
+
1
);
uint32_t
len
;
uint32_t
len
;
char
*
serialized
=
syncEntrySerialize
(
pEntry
,
&
len
);
char
*
serialized
=
syncEntrySerialize
(
pEntry
,
&
len
);
assert
(
serialized
!=
NULL
);
assert
(
serialized
!=
NULL
);
int
code
;
int
code
=
0
;
code
=
walWrite
(
pWal
,
pEntry
->
index
,
pEntry
->
msgType
,
serialized
,
len
);
/*
code = walWrite(pWal, pEntry->index, pEntry->entryType, serialized, len);
assert(code == 0);
assert(code == 0);
*/
assert
(
walWrite
(
pWal
,
pEntry
->
index
,
pEntry
->
entryType
,
serialized
,
len
)
==
0
);
walFsync
(
pWal
,
true
);
walFsync
(
pWal
,
true
);
free
(
serialized
);
free
(
serialized
);
return
code
;
// to avoid compiler error
return
code
;
}
}
SSyncRaftEntry
*
logStoreGetEntry
(
SSyncLogStore
*
pLogStore
,
SyncIndex
index
)
{
SSyncRaftEntry
*
logStoreGetEntry
(
SSyncLogStore
*
pLogStore
,
SyncIndex
index
)
{
...
@@ -69,7 +73,7 @@ SSyncRaftEntry* logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index) {
...
@@ -69,7 +73,7 @@ SSyncRaftEntry* logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index) {
if
(
index
>=
SYNC_INDEX_BEGIN
&&
index
<=
logStoreLastIndex
(
pLogStore
))
{
if
(
index
>=
SYNC_INDEX_BEGIN
&&
index
<=
logStoreLastIndex
(
pLogStore
))
{
SWalReadHandle
*
pWalHandle
=
walOpenReadHandle
(
pWal
);
SWalReadHandle
*
pWalHandle
=
walOpenReadHandle
(
pWal
);
walReadWithHandle
(
pWalHandle
,
index
);
assert
(
walReadWithHandle
(
pWalHandle
,
index
)
==
0
);
pEntry
=
syncEntryDeserialize
(
pWalHandle
->
pHead
->
head
.
body
,
pWalHandle
->
pHead
->
head
.
len
);
pEntry
=
syncEntryDeserialize
(
pWalHandle
->
pHead
->
head
.
body
,
pWalHandle
->
pHead
->
head
.
len
);
assert
(
pEntry
!=
NULL
);
assert
(
pEntry
!=
NULL
);
...
@@ -83,7 +87,7 @@ SSyncRaftEntry* logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index) {
...
@@ -83,7 +87,7 @@ SSyncRaftEntry* logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index) {
int32_t
logStoreTruncate
(
SSyncLogStore
*
pLogStore
,
SyncIndex
fromIndex
)
{
int32_t
logStoreTruncate
(
SSyncLogStore
*
pLogStore
,
SyncIndex
fromIndex
)
{
SSyncLogStoreData
*
pData
=
pLogStore
->
data
;
SSyncLogStoreData
*
pData
=
pLogStore
->
data
;
SWal
*
pWal
=
pData
->
pWal
;
SWal
*
pWal
=
pData
->
pWal
;
walRollback
(
pWal
,
fromIndex
);
assert
(
walRollback
(
pWal
,
fromIndex
)
==
0
);
return
0
;
// to avoid compiler error
return
0
;
// to avoid compiler error
}
}
...
@@ -107,7 +111,7 @@ SyncTerm logStoreLastTerm(SSyncLogStore* pLogStore) {
...
@@ -107,7 +111,7 @@ SyncTerm logStoreLastTerm(SSyncLogStore* pLogStore) {
int32_t
logStoreUpdateCommitIndex
(
SSyncLogStore
*
pLogStore
,
SyncIndex
index
)
{
int32_t
logStoreUpdateCommitIndex
(
SSyncLogStore
*
pLogStore
,
SyncIndex
index
)
{
SSyncLogStoreData
*
pData
=
pLogStore
->
data
;
SSyncLogStoreData
*
pData
=
pLogStore
->
data
;
SWal
*
pWal
=
pData
->
pWal
;
SWal
*
pWal
=
pData
->
pWal
;
walCommit
(
pWal
,
index
);
assert
(
walCommit
(
pWal
,
index
)
==
0
);
return
0
;
// to avoid compiler error
return
0
;
// to avoid compiler error
}
}
...
...
source/libs/sync/test/CMakeLists.txt
浏览文件 @
bdbf365e
...
@@ -34,6 +34,7 @@ add_executable(syncEncodeTest "")
...
@@ -34,6 +34,7 @@ add_executable(syncEncodeTest "")
add_executable
(
syncWriteTest
""
)
add_executable
(
syncWriteTest
""
)
add_executable
(
syncReplicateTest
""
)
add_executable
(
syncReplicateTest
""
)
add_executable
(
syncReplicateTest2
""
)
add_executable
(
syncReplicateTest2
""
)
add_executable
(
syncReplicateTest3
""
)
add_executable
(
syncReplicateLoadTest
""
)
add_executable
(
syncReplicateLoadTest
""
)
add_executable
(
syncRefTest
""
)
add_executable
(
syncRefTest
""
)
add_executable
(
syncLogStoreCheck
""
)
add_executable
(
syncLogStoreCheck
""
)
...
@@ -183,6 +184,10 @@ target_sources(syncReplicateTest2
...
@@ -183,6 +184,10 @@ target_sources(syncReplicateTest2
PRIVATE
PRIVATE
"syncReplicateTest2.cpp"
"syncReplicateTest2.cpp"
)
)
target_sources
(
syncReplicateTest3
PRIVATE
"syncReplicateTest3.cpp"
)
target_sources
(
syncReplicateLoadTest
target_sources
(
syncReplicateLoadTest
PRIVATE
PRIVATE
"syncReplicateLoadTest.cpp"
"syncReplicateLoadTest.cpp"
...
@@ -377,6 +382,11 @@ target_include_directories(syncReplicateTest2
...
@@ -377,6 +382,11 @@ target_include_directories(syncReplicateTest2
"
${
CMAKE_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
syncReplicateTest3
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
target_include_directories
(
syncReplicateLoadTest
target_include_directories
(
syncReplicateLoadTest
PUBLIC
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/sync"
"
${
CMAKE_SOURCE_DIR
}
/include/libs/sync"
...
@@ -538,6 +548,10 @@ target_link_libraries(syncReplicateTest2
...
@@ -538,6 +548,10 @@ target_link_libraries(syncReplicateTest2
sync
sync
gtest_main
gtest_main
)
)
target_link_libraries
(
syncReplicateTest3
sync
gtest_main
)
target_link_libraries
(
syncReplicateLoadTest
target_link_libraries
(
syncReplicateLoadTest
sync
sync
gtest_main
gtest_main
...
...
source/libs/sync/test/syncEntryTest.cpp
浏览文件 @
bdbf365e
...
@@ -46,6 +46,20 @@ void test2() {
...
@@ -46,6 +46,20 @@ void test2() {
}
}
void
test3
()
{
void
test3
()
{
SyncClientRequest
*
pSyncMsg
=
syncClientRequestBuild
(
10
);
pSyncMsg
->
originalRpcType
=
33
;
pSyncMsg
->
seqNum
=
11
;
pSyncMsg
->
isWeak
=
1
;
strcpy
(
pSyncMsg
->
data
,
"test3"
);
SSyncRaftEntry
*
pEntry
=
syncEntryBuild3
(
pSyncMsg
,
100
,
200
,
SYNC_RAFT_ENTRY_NOOP
);
syncEntryPrint
(
pEntry
);
syncClientRequestDestroy
(
pSyncMsg
);
syncEntryDestory
(
pEntry
);
}
void
test4
()
{
SSyncRaftEntry
*
pEntry
=
syncEntryBuild
(
10
);
SSyncRaftEntry
*
pEntry
=
syncEntryBuild
(
10
);
assert
(
pEntry
!=
NULL
);
assert
(
pEntry
!=
NULL
);
pEntry
->
msgType
=
11
;
pEntry
->
msgType
=
11
;
...
@@ -54,7 +68,8 @@ void test3() {
...
@@ -54,7 +68,8 @@ void test3() {
pEntry
->
isWeak
=
true
;
pEntry
->
isWeak
=
true
;
pEntry
->
term
=
44
;
pEntry
->
term
=
44
;
pEntry
->
index
=
55
;
pEntry
->
index
=
55
;
strcpy
(
pEntry
->
data
,
"test3"
);
pEntry
->
entryType
=
SYNC_RAFT_ENTRY_CONFIG
;
strcpy
(
pEntry
->
data
,
"test4"
);
syncEntryPrint
(
pEntry
);
syncEntryPrint
(
pEntry
);
uint32_t
len
;
uint32_t
len
;
...
@@ -76,6 +91,7 @@ int main(int argc, char** argv) {
...
@@ -76,6 +91,7 @@ int main(int argc, char** argv) {
test1
();
test1
();
test2
();
test2
();
test3
();
test3
();
test4
();
return
0
;
return
0
;
}
}
source/libs/sync/test/syncReplicateLoadTest.cpp
浏览文件 @
bdbf365e
...
@@ -178,9 +178,10 @@ int main(int argc, char **argv) {
...
@@ -178,9 +178,10 @@ int main(int argc, char **argv) {
while
(
1
)
{
while
(
1
)
{
sTrace
(
sTrace
(
"replicate sleep, state: %d, %s, term:%lu electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, "
"replicate sleep, state: %d, %s, term:%lu electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, "
"electTimerMS:%d"
,
"electTimerMS:%d
, commitIndex:%ld
"
,
pSyncNode
->
state
,
syncUtilState2String
(
pSyncNode
->
state
),
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
state
,
syncUtilState2String
(
pSyncNode
->
state
),
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
electTimerLogicClock
,
pSyncNode
->
electTimerLogicClockUser
,
pSyncNode
->
electTimerMS
);
pSyncNode
->
electTimerLogicClock
,
pSyncNode
->
electTimerLogicClockUser
,
pSyncNode
->
electTimerMS
,
pSyncNode
->
commitIndex
);
taosMsleep
(
1000
);
taosMsleep
(
1000
);
}
}
...
...
source/libs/sync/test/syncReplicateTest.cpp
浏览文件 @
bdbf365e
...
@@ -183,18 +183,20 @@ int main(int argc, char **argv) {
...
@@ -183,18 +183,20 @@ int main(int argc, char **argv) {
taosMsleep
(
1000
);
taosMsleep
(
1000
);
sTrace
(
sTrace
(
"
replicat
e sleep, state: %d, %s, term:%lu electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, "
"
syncPropos
e sleep, state: %d, %s, term:%lu electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, "
"electTimerMS:%d"
,
"electTimerMS:%d
, commitIndex:%ld
"
,
gSyncNode
->
state
,
syncUtilState2String
(
gSyncNode
->
state
),
gSyncNode
->
pRaftStore
->
currentTerm
,
gSyncNode
->
state
,
syncUtilState2String
(
gSyncNode
->
state
),
gSyncNode
->
pRaftStore
->
currentTerm
,
gSyncNode
->
electTimerLogicClock
,
gSyncNode
->
electTimerLogicClockUser
,
gSyncNode
->
electTimerMS
);
gSyncNode
->
electTimerLogicClock
,
gSyncNode
->
electTimerLogicClockUser
,
gSyncNode
->
electTimerMS
,
gSyncNode
->
commitIndex
);
}
}
while
(
1
)
{
while
(
1
)
{
sTrace
(
sTrace
(
"replicate sleep, state: %d, %s, term:%lu electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, "
"replicate sleep, state: %d, %s, term:%lu electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, "
"electTimerMS:%d"
,
"electTimerMS:%d
, commitIndex:%ld
"
,
gSyncNode
->
state
,
syncUtilState2String
(
gSyncNode
->
state
),
gSyncNode
->
pRaftStore
->
currentTerm
,
gSyncNode
->
state
,
syncUtilState2String
(
gSyncNode
->
state
),
gSyncNode
->
pRaftStore
->
currentTerm
,
gSyncNode
->
electTimerLogicClock
,
gSyncNode
->
electTimerLogicClockUser
,
gSyncNode
->
electTimerMS
);
gSyncNode
->
electTimerLogicClock
,
gSyncNode
->
electTimerLogicClockUser
,
gSyncNode
->
electTimerMS
,
gSyncNode
->
commitIndex
);
taosMsleep
(
1000
);
taosMsleep
(
1000
);
}
}
...
...
source/libs/sync/test/syncReplicateTest2.cpp
浏览文件 @
bdbf365e
...
@@ -185,17 +185,19 @@ int main(int argc, char **argv) {
...
@@ -185,17 +185,19 @@ int main(int argc, char **argv) {
sTrace
(
sTrace
(
"syncPropose sleep, state: %d, %s, term:%lu electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, "
"syncPropose sleep, state: %d, %s, term:%lu electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, "
"electTimerMS:%d"
,
"electTimerMS:%d
, commitIndex:%ld
"
,
pSyncNode
->
state
,
syncUtilState2String
(
pSyncNode
->
state
),
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
state
,
syncUtilState2String
(
pSyncNode
->
state
),
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
electTimerLogicClock
,
pSyncNode
->
electTimerLogicClockUser
,
pSyncNode
->
electTimerMS
);
pSyncNode
->
electTimerLogicClock
,
pSyncNode
->
electTimerLogicClockUser
,
pSyncNode
->
electTimerMS
,
pSyncNode
->
commitIndex
);
}
}
while
(
1
)
{
while
(
1
)
{
sTrace
(
sTrace
(
"replicate sleep, state: %d, %s, term:%lu electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, "
"replicate sleep, state: %d, %s, term:%lu electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, "
"electTimerMS:%d"
,
"electTimerMS:%d
, commitIndex:%ld
"
,
pSyncNode
->
state
,
syncUtilState2String
(
pSyncNode
->
state
),
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
state
,
syncUtilState2String
(
pSyncNode
->
state
),
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
electTimerLogicClock
,
pSyncNode
->
electTimerLogicClockUser
,
pSyncNode
->
electTimerMS
);
pSyncNode
->
electTimerLogicClock
,
pSyncNode
->
electTimerLogicClockUser
,
pSyncNode
->
electTimerMS
,
pSyncNode
->
commitIndex
);
taosMsleep
(
1000
);
taosMsleep
(
1000
);
}
}
...
...
source/libs/sync/test/syncReplicateTest3.cpp
0 → 100644
浏览文件 @
bdbf365e
#define ALLOW_FORBID_FUNC
#include <gtest/gtest.h>
#include <stdio.h>
#include "syncEnv.h"
#include "syncIO.h"
#include "syncInt.h"
#include "syncMessage.h"
#include "syncRaftEntry.h"
#include "syncRaftLog.h"
#include "syncRaftStore.h"
#include "syncUtil.h"
void
logTest
()
{
sTrace
(
"--- sync log test: trace"
);
sDebug
(
"--- sync log test: debug"
);
sInfo
(
"--- sync log test: info"
);
sWarn
(
"--- sync log test: warn"
);
sError
(
"--- sync log test: error"
);
sFatal
(
"--- sync log test: fatal"
);
}
uint16_t
ports
[]
=
{
7010
,
7110
,
7210
,
7310
,
7410
};
int32_t
replicaNum
=
3
;
int32_t
myIndex
=
0
;
SRaftId
ids
[
TSDB_MAX_REPLICA
];
SSyncInfo
syncInfo
;
SSyncFSM
*
pFsm
;
SWal
*
pWal
;
void
CommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SyncIndex
index
,
bool
isWeak
,
int32_t
code
,
ESyncState
state
)
{
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==CommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
index
,
isWeak
,
code
,
state
,
syncUtilState2String
(
state
));
syncRpcMsgPrint2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
void
PreCommitCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SyncIndex
index
,
bool
isWeak
,
int32_t
code
,
ESyncState
state
)
{
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==PreCommitCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
index
,
isWeak
,
code
,
state
,
syncUtilState2String
(
state
));
syncRpcMsgPrint2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
void
RollBackCb
(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SyncIndex
index
,
bool
isWeak
,
int32_t
code
,
ESyncState
state
)
{
char
logBuf
[
256
];
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==callback== ==RollBackCb== pFsm:%p, index:%ld, isWeak:%d, code:%d, state:%d %s
\n
"
,
pFsm
,
index
,
isWeak
,
code
,
state
,
syncUtilState2String
(
state
));
syncRpcMsgPrint2
(
logBuf
,
(
SRpcMsg
*
)
pMsg
);
}
void
initFsm
()
{
pFsm
=
(
SSyncFSM
*
)
malloc
(
sizeof
(
SSyncFSM
));
pFsm
->
FpCommitCb
=
CommitCb
;
pFsm
->
FpPreCommitCb
=
PreCommitCb
;
pFsm
->
FpRollBackCb
=
RollBackCb
;
}
int64_t
syncNodeInit
()
{
syncInfo
.
vgId
=
1234
;
syncInfo
.
rpcClient
=
gSyncIO
->
clientRpc
;
syncInfo
.
FpSendMsg
=
syncIOSendMsg
;
syncInfo
.
queue
=
gSyncIO
->
pMsgQ
;
syncInfo
.
FpEqMsg
=
syncIOEqMsg
;
syncInfo
.
pFsm
=
pFsm
;
snprintf
(
syncInfo
.
path
,
sizeof
(
syncInfo
.
path
),
"./replicate2_test_%d"
,
myIndex
);
int
code
=
walInit
();
assert
(
code
==
0
);
SWalCfg
walCfg
;
memset
(
&
walCfg
,
0
,
sizeof
(
SWalCfg
));
walCfg
.
vgId
=
syncInfo
.
vgId
;
walCfg
.
fsyncPeriod
=
1000
;
walCfg
.
retentionPeriod
=
1000
;
walCfg
.
rollPeriod
=
1000
;
walCfg
.
retentionSize
=
1000
;
walCfg
.
segSize
=
1000
;
walCfg
.
level
=
TAOS_WAL_FSYNC
;
char
tmpdir
[
128
];
snprintf
(
tmpdir
,
sizeof
(
tmpdir
),
"./replicate2_test_wal_%d"
,
myIndex
);
pWal
=
walOpen
(
tmpdir
,
&
walCfg
);
assert
(
pWal
!=
NULL
);
syncInfo
.
pWal
=
pWal
;
SSyncCfg
*
pCfg
=
&
syncInfo
.
syncCfg
;
pCfg
->
myIndex
=
myIndex
;
pCfg
->
replicaNum
=
replicaNum
;
for
(
int
i
=
0
;
i
<
replicaNum
;
++
i
)
{
pCfg
->
nodeInfo
[
i
].
nodePort
=
ports
[
i
];
snprintf
(
pCfg
->
nodeInfo
[
i
].
nodeFqdn
,
sizeof
(
pCfg
->
nodeInfo
[
i
].
nodeFqdn
),
"%s"
,
"127.0.0.1"
);
// taosGetFqdn(pCfg->nodeInfo[0].nodeFqdn);
}
int64_t
rid
=
syncStart
(
&
syncInfo
);
assert
(
rid
>
0
);
SSyncNode
*
pSyncNode
=
(
SSyncNode
*
)
syncNodeAcquire
(
rid
);
assert
(
pSyncNode
!=
NULL
);
// pSyncNode->hbBaseLine = 500;
// pSyncNode->electBaseLine = 1500;
gSyncIO
->
FpOnSyncPing
=
pSyncNode
->
FpOnPing
;
gSyncIO
->
FpOnSyncPingReply
=
pSyncNode
->
FpOnPingReply
;
gSyncIO
->
FpOnSyncRequestVote
=
pSyncNode
->
FpOnRequestVote
;
gSyncIO
->
FpOnSyncRequestVoteReply
=
pSyncNode
->
FpOnRequestVoteReply
;
gSyncIO
->
FpOnSyncAppendEntries
=
pSyncNode
->
FpOnAppendEntries
;
gSyncIO
->
FpOnSyncAppendEntriesReply
=
pSyncNode
->
FpOnAppendEntriesReply
;
gSyncIO
->
FpOnSyncTimeout
=
pSyncNode
->
FpOnTimeout
;
gSyncIO
->
FpOnSyncClientRequest
=
pSyncNode
->
FpOnClientRequest
;
gSyncIO
->
pSyncNode
=
pSyncNode
;
syncNodeRelease
(
pSyncNode
);
return
rid
;
}
void
initRaftId
(
SSyncNode
*
pSyncNode
)
{
for
(
int
i
=
0
;
i
<
replicaNum
;
++
i
)
{
ids
[
i
]
=
pSyncNode
->
replicasId
[
i
];
char
*
s
=
syncUtilRaftId2Str
(
&
ids
[
i
]);
printf
(
"raftId[%d] : %s
\n
"
,
i
,
s
);
free
(
s
);
}
}
SRpcMsg
*
step0
(
int
i
)
{
SRpcMsg
*
pMsg
=
(
SRpcMsg
*
)
malloc
(
sizeof
(
SRpcMsg
));
memset
(
pMsg
,
0
,
sizeof
(
SRpcMsg
));
pMsg
->
msgType
=
9999
;
pMsg
->
contLen
=
128
;
pMsg
->
pCont
=
malloc
(
pMsg
->
contLen
);
snprintf
((
char
*
)(
pMsg
->
pCont
),
pMsg
->
contLen
,
"value-%u-%d"
,
ports
[
myIndex
],
i
);
return
pMsg
;
}
SyncClientRequest
*
step1
(
const
SRpcMsg
*
pMsg
)
{
SyncClientRequest
*
pRetMsg
=
syncClientRequestBuild2
(
pMsg
,
123
,
true
);
return
pRetMsg
;
}
int
main
(
int
argc
,
char
**
argv
)
{
// taosInitLog((char *)"syncTest.log", 100000, 10);
tsAsyncLog
=
0
;
sDebugFlag
=
143
+
64
;
void
logTest
();
myIndex
=
0
;
if
(
argc
>=
2
)
{
myIndex
=
atoi
(
argv
[
1
]);
}
int
recordCount
=
100
;
if
(
argc
>=
3
)
{
recordCount
=
atoi
(
argv
[
2
]);
}
int
sleepMS
=
10
;
if
(
argc
>=
4
)
{
sleepMS
=
atoi
(
argv
[
3
]);
}
int32_t
ret
=
syncIOStart
((
char
*
)
"127.0.0.1"
,
ports
[
myIndex
]);
assert
(
ret
==
0
);
initFsm
();
ret
=
syncInit
();
assert
(
ret
==
0
);
int64_t
rid
=
syncNodeInit
();
assert
(
rid
>
0
);
SSyncNode
*
pSyncNode
=
(
SSyncNode
*
)
syncNodeAcquire
(
rid
);
assert
(
pSyncNode
!=
NULL
);
syncNodePrint2
((
char
*
)
""
,
pSyncNode
);
initRaftId
(
pSyncNode
);
for
(
int
i
=
0
;
i
<
recordCount
;
++
i
)
{
// step0
SRpcMsg
*
pMsg0
=
step0
(
i
);
syncRpcMsgPrint2
((
char
*
)
"==step0=="
,
pMsg0
);
syncPropose
(
rid
,
pMsg0
,
true
);
taosMsleep
(
sleepMS
);
free
(
pMsg0
);
sTrace
(
"syncPropose sleep, state: %d, %s, term:%lu electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, "
"electTimerMS:%d, commitIndex:%ld"
,
pSyncNode
->
state
,
syncUtilState2String
(
pSyncNode
->
state
),
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
electTimerLogicClock
,
pSyncNode
->
electTimerLogicClockUser
,
pSyncNode
->
electTimerMS
,
pSyncNode
->
commitIndex
);
}
while
(
1
)
{
sTrace
(
"replicate sleep, state: %d, %s, term:%lu electTimerLogicClock:%lu, electTimerLogicClockUser:%lu, "
"electTimerMS:%d, commitIndex:%ld"
,
pSyncNode
->
state
,
syncUtilState2String
(
pSyncNode
->
state
),
pSyncNode
->
pRaftStore
->
currentTerm
,
pSyncNode
->
electTimerLogicClock
,
pSyncNode
->
electTimerLogicClockUser
,
pSyncNode
->
electTimerMS
,
pSyncNode
->
commitIndex
);
taosMsleep
(
1000
);
}
return
0
;
}
tests/script/jenkins/basic.txt
浏览文件 @
bdbf365e
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
# ---- query
# ---- query
./test.sh -f tsim/query/interval.sim
./test.sh -f tsim/query/interval.sim
#
./test.sh -f tsim/query/interval-offset.sim
./test.sh -f tsim/query/interval-offset.sim
# ---- show
# ---- show
./test.sh -f tsim/show/basic.sim
./test.sh -f tsim/show/basic.sim
...
...
tests/script/tsim/insert/backquote.sim
浏览文件 @
bdbf365e
...
@@ -37,8 +37,8 @@ while $dbCnt < 2
...
@@ -37,8 +37,8 @@ while $dbCnt < 2
print =============== create super table, include all type
print =============== create super table, include all type
print notes: after nchar show ok, modify binary to nchar
print notes: after nchar show ok, modify binary to nchar
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(16), `nchar`
nchar
(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 create table `Stable` (`timestamp` timestamp, `int` int, `Binary` binary(32), `Nchar`
nchar
(32)) tags (`float` float, `binary` binary(16), `nchar` nchar(16))
sql show stables
sql show stables
print rows: $rows
print rows: $rows
...
@@ -96,6 +96,7 @@ while $dbCnt < 2
...
@@ -96,6 +96,7 @@ while $dbCnt < 2
return -1
return -1
endi
endi
if $data03 != table then
if $data03 != table then
print expect table, actual $data03
return -1
return -1
endi
endi
...
...
tests/script/tsim/insert/basic0.sim
浏览文件 @
bdbf365e
...
@@ -109,7 +109,26 @@ endi
...
@@ -109,7 +109,26 @@ endi
#print =============== select first(*)/first(column) from child table
#print =============== select first(*)/first(column) from child table
#sql select first(*) from ct1
#sql select first(*) from ct1
#sql select first(ts), first(c1), first(c2), first(c3) from ct1
#print ====> select first(*) from ct1
#print rows: $rows
#print $data00 $data01 $data02 $data03
sql select first(ts), first(c1), first(c2), first(c3) from ct1
print ====> select first(ts), first(c1), first(c2), first(c3) from ct1
print rows: $rows
print $data00 $data01 $data02 $data03
if $rows != 1 then
return -1
endi
if $data01 != 10 then
return -1
endi
if $data02 != 2.00000 then
return -1
endi
if $data03 != 3.000000000 then
return -1
endi
print =============== select min(column) from child table
print =============== select min(column) from child table
sql select min(c1), min(c2), min(c3) from ct1
sql select min(c1), min(c2), min(c3) from ct1
...
@@ -216,10 +235,42 @@ endi
...
@@ -216,10 +235,42 @@ endi
# return -1
# return -1
#endi
#endi
print =============== select count(column) from supter table
sql select ts, c1, c2, c3 from stb
print rows: $rows
print $data00 $data01 $data02 $data03
print $data10 $data11 $data12 $data13
print $data20 $data21 $data22 $data23
print $data30 $data31 $data32 $data33
print $data40 $data41 $data42 $data43
print $data50 $data51 $data52 $data53
print $data60 $data61 $data62 $data63
print $data70 $data71 $data72 $data73
print $data80 $data81 $data82 $data83
if $rows != 9 then
return -1
endi
# The order of data from different sub tables in the super table is random,
# so this detection may fail randomly
if $data01 != 10 then
return -1
endi
if $data02 != 2.00000 then
return -1
endi
if $data03 != 3.000000000 then
return -1
endi
#print =============== select count(column) from supter table
#print =============== select count(column) from supter table
#sql select count(ts), count(c1), count(c2), count(c3) from stb
#sql select count(ts), count(c1), count(c2), count(c3) from stb
#print rows: $rows
#print $data00 $data01 $data02 $data03
#print $data00 $data01 $data02 $data03
#if $data00 != 8 then
#print $data10 $data11 $data12 $data13
#print $data20 $data21 $data22 $data23
#print $data30 $data31 $data32 $data33
#if $data00 != 9 then
# return -1
# return -1
#endi
#endi
#if $data01 != 8 then
#if $data01 != 8 then
...
@@ -232,7 +283,6 @@ endi
...
@@ -232,7 +283,6 @@ endi
# return -1
# return -1
#endi
#endi
#===================================================================
#===================================================================
#===================================================================
#===================================================================
...
@@ -317,7 +367,26 @@ endi
...
@@ -317,7 +367,26 @@ endi
#print =============== select first(*)/first(column) from child table
#print =============== select first(*)/first(column) from child table
#sql select first(*) from ct1
#sql select first(*) from ct1
#sql select first(ts), first(c1), first(c2), first(c3) from ct1
#print ====> select first(*) from ct1
#print rows: $rows
#print $data00 $data01 $data02 $data03
sql select first(ts), first(c1), first(c2), first(c3) from ct1
print ====> select first(ts), first(c1), first(c2), first(c3) from ct1
print rows: $rows
print $data00 $data01 $data02 $data03
if $rows != 1 then
return -1
endi
if $data01 != 10 then
return -1
endi
if $data02 != 2.00000 then
return -1
endi
if $data03 != 3.000000000 then
return -1
endi
print =============== select min(column) from child table
print =============== select min(column) from child table
sql select min(c1), min(c2), min(c3) from ct1
sql select min(c1), min(c2), min(c3) from ct1
...
@@ -424,6 +493,33 @@ endi
...
@@ -424,6 +493,33 @@ endi
# return -1
# return -1
#endi
#endi
print =============== select count(column) from supter table
sql select ts, c1, c2, c3 from stb
print rows: $rows
print $data00 $data01 $data02 $data03
print $data10 $data11 $data12 $data13
print $data20 $data21 $data22 $data23
print $data30 $data31 $data32 $data33
print $data40 $data41 $data42 $data43
print $data50 $data51 $data52 $data53
print $data60 $data61 $data62 $data63
print $data70 $data71 $data72 $data73
print $data80 $data81 $data82 $data83
if $rows != 9 then
return -1
endi
# The order of data from different sub tables in the super table is random,
# so this detection may fail randomly
if $data01 != 10 then
return -1
endi
if $data02 != 2.00000 then
return -1
endi
if $data03 != 3.000000000 then
return -1
endi
#print =============== select count(column) from supter table
#print =============== select count(column) from supter table
#sql select count(ts), count(c1), count(c2), count(c3) from stb
#sql select count(ts), count(c1), count(c2), count(c3) from stb
#print $data00 $data01 $data02 $data03
#print $data00 $data01 $data02 $data03
...
...
tests/script/tsim/query/interval-offset.sim
浏览文件 @
bdbf365e
...
@@ -5,8 +5,6 @@ sleep 500
...
@@ -5,8 +5,6 @@ sleep 500
sql connect
sql connect
print =============== create database
print =============== create database
sql drop database d0 -x step1
step1:
sql create database d0
sql create database d0
sql show databases
sql show databases
if $rows != 2 then
if $rows != 2 then
...
@@ -25,9 +23,11 @@ endi
...
@@ -25,9 +23,11 @@ endi
sql create table ct1 using stb tags ( 1 )
sql create table ct1 using stb tags ( 1 )
sql create table ct2 using stb tags ( 2 )
sql create table ct2 using stb tags ( 2 )
sql create table ct3 using stb tags ( 3 )
sql create table ct4 using stb tags ( 4 )
sql show tables
sql show tables
print $rows $data00 $data10 $data20
print $rows $data00 $data10 $data20
if $rows !=
2
then
if $rows !=
4
then
return -1
return -1
endi
endi
...
@@ -88,13 +88,17 @@ print ===> rows4: $data40 $data41 $data42 $data43 $data44
...
@@ -88,13 +88,17 @@ print ===> rows4: $data40 $data41 $data42 $data43 $data44
print ===> rows5: $data50 $data51 $data52 $data53 $data54
print ===> rows5: $data50 $data51 $data52 $data53 $data54
print ===> rows6: $data60 $data61 $data62 $data63 $data64
print ===> rows6: $data60 $data61 $data62 $data63 $data64
print ===> rows7: $data70 $data71 $data72 $data73 $data74
print ===> rows7: $data70 $data71 $data72 $data73 $data74
if $rows != 8 then
print ===> rows8: $data80 $data81 $data82 $data83 $data84
if $rows != 9 then
return -1
endi
if $data00 != 1 then
return -1
return -1
endi
endi
if $data
0
0 != 2 then
if $data
7
0 != 2 then
return -1
return -1
endi
endi
if $data
7
0 != 1 then
if $data
8
0 != 1 then
return -1
return -1
endi
endi
...
@@ -128,238 +132,193 @@ endi
...
@@ -128,238 +132,193 @@ endi
sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct2 interval(1d, 2h) sliding(12h)
sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct2 interval(1d, 2h) sliding(12h)
print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct2 interval(1d, 2h) sliding(12h)
print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct2 interval(1d, 2h) sliding(12h)
print ===> rows: $rows
print ===> rows: $rows
print ===> rows0: $data00 $data01 $data02 $data03 $data04 $data05
print ===> rows1: $data10 $data11 $data12 $data13 $data14 $data15
print ===> rows2: $data20 $data21 $data22 $data23 $data24 $data25
print ===> rows3: $data30 $data31 $data32 $data33 $data34 $data35
print ===> rows4: $data40 $data41 $data42 $data43 $data44 $data45
print ===> rows5: $data50 $data51 $data52 $data53 $data54 $data55
print ===> rows6: $data60 $data61 $data62 $data63 $data64 $data65
print ===> rows7: $data70 $data71 $data72 $data73 $data74 $data75
#if $rows != 8 then
# return -1
#endi
#if $data00 != 1 then
# return -1
#endi
#if $data10 != 2 then
# return -1
#endi
#if $data20 != 2 then
# return -1
#endi
#if $data30 != 2 then
# return -1
#endi
#if $data40 != 2 then
# return -1
#endi
#if $data50 != 2 then
# return -1
#endi
#if $data60 != 2 then
# return -1
#endi
#if $data70 != 1 then
# return -1
#endi
print =============== insert data into child table ct3 (n)
sql insert into ct3 values ( '2021-12-21 01:01:01.000', NULL );
sql insert into ct3 values ( '2021-12-31 01:01:01.000', 1 );
sql insert into ct3 values ( '2022-01-01 01:01:06.000', 2 );
sql insert into ct3 values ( '2022-01-07 01:01:10.000', 3 );
sql insert into ct3 values ( '2022-01-31 01:01:16.000', 4 );
sql insert into ct3 values ( '2022-02-01 01:01:20.000', 5 );
sql insert into ct3 values ( '2022-02-28 01:01:26.000', 6 );
sql insert into ct3 values ( '2022-03-01 01:01:30.000', 7 );
sql insert into ct3 values ( '2022-03-08 01:01:36.000', 8 );
sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct3 interval(1n, 1w)
print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct3 interval(1n, 1w)
print ===> rows: $rows
print ===> rows0: $data00 $data01 $data02 $data03 $data04
print ===> rows0: $data00 $data01 $data02 $data03 $data04
print ===> rows1: $data10 $data11 $data12 $data13 $data14
print ===> rows1: $data10 $data11 $data12 $data13 $data14
print ===> rows2: $data20 $data21 $data22 $data23 $data24
print ===> rows2: $data20 $data21 $data22 $data23 $data24
print ===> rows3: $data30 $data31 $data32 $data33 $data34
print ===> rows3: $data30 $data31 $data32 $data33 $data34
print ===> rows4: $data40 $data41 $data42 $data43 $data44
print ===> rows4: $data40 $data41 $data42 $data43 $data44
print ===> rows5: $data50 $data51 $data52 $data53 $data54
print ===> rows6: $data60 $data61 $data62 $data63 $data64
print ===> rows7: $data70 $data71 $data72 $data73 $data74
if $rows != 7 then
return -1
endi
if $data00 != 2 then
return -1
endi
if $data60 != 1 then
return -1
endi
return
sql select count(*) from car interval(1n, 10d) order by ts desc
# tdSql.checkData(0, 1, 1)
# tdSql.checkData(1, 1, 2)
# tdSql.checkData(2, 1, 3)
# tdSql.checkData(3, 1, 3)
# tdSql.checkData(4, 1, 6)
# tdSql.checkData(5, 1, 1)
# tdSql.checkData(6, 1, 1)
#
sql select count(*) from car interval(2n, 5d)
# tdSql.checkData(0, 1, 1)
# tdSql.checkData(1, 1, 1)
# tdSql.checkData(2, 1, 6)
# tdSql.checkData(3, 1, 6)
# tdSql.checkData(4, 1, 3)
sql select count(*) from car interval(2n) order by ts desc
# tdSql.checkData(0, 1, 3)
# tdSql.checkData(1, 1, 6)
# tdSql.checkData(2, 1, 6)
# tdSql.checkData(3, 1, 1)
# tdSql.checkData(4, 1, 1)
#
sql select count(*) from car interval(1y, 1n)
# tdSql.checkData(0, 1, 1)
# tdSql.checkData(1, 1, 8)
# tdSql.checkData(2, 1, 8)
#
sql select count(*) from car interval(1y, 2n)
# tdSql.checkData(0, 1, 1)
# tdSql.checkData(1, 1, 11)
# tdSql.checkData(2, 1, 5)
sql select count(*) from car where ts > '2019-05-14 00:00:00' interval(1y, 5d)
# tdSql.checkData(0, 1, 6)
# tdSql.checkData(1, 1, 9)
sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int)
print ====== start create child tables and insert data
$i = 0
while $i < $tbNum
$tb = $tbPrefix . $i
sql create table $tb using $mt tags( $i )
$x = 0
while $x < $rowNum
$cc = $x * 60000
$ms = 1601481600000 + $cc
sql insert into $tb values ($ms , $x )
$x = $x + 1
endw
$i = $i + 1
endw
print =============== step2
$i = 1
$tb = $tbPrefix . $i
sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb interval(1m)
print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb interval(1m)
print ===> $rows $data01 $data05
if $rows != $rowNum then
return -1
endi
if $data00 != 1 then
return -1
endi
if $data04 != 1 then
return -1
endi
#print =============== step3
#$cc = 4 * 60000
#$ms = 1601481600000 + $cc
#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms interval(1m)
#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms interval(1m)
#print ===> $rows $data01 $data05
#if $rows != 5 then
#if $rows != 5 then
# return -1
# return -1
#endi
#endi
#if $data00 != 1 then
#if $data00 != 1 then
# return -1
# return -1
#endi
#endi
#if $data
04 != 1 then
#if $data
40 != 1 then
# return -1
# return -1
#endi
#endi
#print =============== step4
sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct3 interval(1n, 1w) sliding(2w)
#$cc = 40 * 60000
print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct3 interval(1n, 1w) sliding(2w)
#$ms = 1601481600000 + $cc
print ===> rows: $rows
print ===> rows0: $data00 $data01 $data02 $data03 $data04
#$cc = 1 * 60000
print ===> rows1: $data10 $data11 $data12 $data13 $data14
#$ms2 = 1601481600000 - $cc
print ===> rows2: $data20 $data21 $data22 $data23 $data24
print ===> rows3: $data30 $data31 $data32 $data33 $data34
#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m)
print ===> rows4: $data40 $data41 $data42 $data43 $data44
#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m)
#if $rows != 5 then
#print ===> $rows $data01 $data05
#if $rows != 20 then
# return -1
# return -1
#endi
#endi
#if $data00 != 1 then
#if $data00 != 1 then
# return -1
# return -1
#endi
#endi
#if $data
04 != 1 then
#if $data
40 != 1 then
# return -1
# return -1
#endi
#endi
#print =============== step5
sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct3 interval(1n, 1w) sliding(4w)
#$cc = 40 * 60000
print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct3 interval(1n, 1w) sliding(4w)
#$ms = 1601481600000 + $cc
print ===> rows: $rows
print ===> rows0: $data00 $data01 $data02 $data03 $data04
#$cc = 1 * 60000
print ===> rows1: $data10 $data11 $data12 $data13 $data14
#$ms2 = 1601481600000 - $cc
print ===> rows2: $data20 $data21 $data22 $data23 $data24
print ===> rows3: $data30 $data31 $data32 $data33 $data34
#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) fill(value,0)
print ===> rows4: $data40 $data41 $data42 $data43 $data44
#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) fill(value,0)
print ===> rows5: $data50 $data51 $data52 $data53 $data54
#print ===> $rows $data21 $data25
print ===> rows6: $data60 $data61 $data62 $data63 $data64
#if $rows != 42 then
print ===> rows7: $data70 $data71 $data72 $data73 $data74
#if $rows != 8 then
# return -1
# return -1
#endi
#endi
#if $data
20 != 1 then
#if $data
00 != 2 then
# return -1
# return -1
#endi
#endi
#if $data
24 != 1 then
#if $data
70 != 1 then
# return -1
# return -1
#endi
#endi
#print =============== step6
#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt interval(1m)
print =============== insert data into child table ct4 (y)
#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt interval(1m)
sql insert into ct4 values ( '2020-10-21 01:01:01.000', 1 )
#print ===> $rows $data11
sql insert into ct4 values ( '2020-12-31 01:01:01.000', 2 )
#if $rows != 20 then
sql insert into ct4 values ( '2021-01-01 01:01:06.000', 3 )
sql insert into ct4 values ( '2021-05-07 01:01:10.000', 4 )
sql insert into ct4 values ( '2021-09-30 01:01:16.000', 5 )
sql insert into ct4 values ( '2022-02-01 01:01:20.000', 6 )
sql insert into ct4 values ( '2022-10-28 01:01:26.000', 7 )
sql insert into ct4 values ( '2022-12-01 01:01:30.000', 8 )
sql insert into ct4 values ( '2022-12-31 01:01:36.000', 9 )
sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n)
print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n)
print ===> rows: $rows
print ===> rows0: $data00 $data01 $data02 $data03 $data04
print ===> rows1: $data10 $data11 $data12 $data13 $data14
print ===> rows2: $data20 $data21 $data22 $data23 $data24
print ===> rows3: $data30 $data31 $data32 $data33 $data34
print ===> rows4: $data40 $data41 $data42 $data43 $data44
#if $rows != 5 then
# return -1
# return -1
#endi
#endi
#if $data11 != 10 then
#if $data00 != 1 then
# return -1
#endi
#if $data40 != 1 then
# return -1
# return -1
#endi
#endi
#print =============== step7
sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) sliding(6n)
#$cc = 4 * 60000
print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) sliding(6n)
#$ms = 1601481600000 + $cc
print ===> rows: $rows
#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms interval(1m)
print ===> rows0: $data00 $data01 $data02 $data03 $data04
#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms interval(1m)
print ===> rows1: $data10 $data11 $data12 $data13 $data14
#print ===> $rows $data11
print ===> rows2: $data20 $data21 $data22 $data23 $data24
print ===> rows3: $data30 $data31 $data32 $data33 $data34
print ===> rows4: $data40 $data41 $data42 $data43 $data44
#if $rows != 5 then
#if $rows != 5 then
# return -1
# return -1
#endi
#endi
#if $data
11 != 10 then
#if $data
00 != 1 then
# return -1
# return -1
#endi
#endi
#if $data40 != 1 then
#print =============== step8
#$cc = 40 * 60000
#$ms1 = 1601481600000 + $cc
#
#$cc = 1 * 60000
#$ms2 = 1601481600000 - $cc
#
#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m)
#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m)
#print ===> $rows $data11
#if $rows != 20 then
# return -1
# return -1
#endi
#endi
#if $data11 != 10 then
sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) sliding(12n)
print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) sliding(12n)
print ===> rows: $rows
print ===> rows0: $data00 $data01 $data02 $data03 $data04
print ===> rows1: $data10 $data11 $data12 $data13 $data14
print ===> rows2: $data20 $data21 $data22 $data23 $data24
print ===> rows3: $data30 $data31 $data32 $data33 $data34
print ===> rows4: $data40 $data41 $data42 $data43 $data44
print ===> rows5: $data50 $data51 $data52 $data53 $data54
print ===> rows6: $data60 $data61 $data62 $data63 $data64
print ===> rows7: $data70 $data71 $data72 $data73 $data74
#if $rows != 8 then
# return -1
# return -1
#endi
#endi
#
#if $data00 != 2 then
#print =============== step9
#$cc = 40 * 60000
#$ms1 = 1601481600000 + $cc
#
#$cc = 1 * 60000
#$ms2 = 1601481600000 - $cc
#
#sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) fill(value, 0)
#print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) fill(value, 0)
#print ===> $rows $data11
#if $rows != 42 then
# return -1
# return -1
#endi
#endi
#if $data
11 != 10 then
#if $data
70 != 1 then
# return -1
# return -1
#endi
#endi
print =============== clear
#sql drop database $db
#sql show databases
#if $rows != 0 then
#sql select count(*) from car interval(1n, 10d) order by ts desc
# return -1
#sql select count(*) from car interval(2n, 5d)
#endi
#sql select count(*) from car interval(2n) order by ts desc
#sql select count(*) from car interval(1y, 1n)
#sql select count(*) from car interval(1y, 2n)
#sql select count(*) from car where ts > '2019-05-14 00:00:00' interval(1y, 5d)
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
#system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
tests/script/tsim/table/basic1.sim
浏览文件 @
bdbf365e
...
@@ -231,6 +231,10 @@ endi
...
@@ -231,6 +231,10 @@ endi
print =============== query data
print =============== query data
sql select * from c1
sql select * from c1
print rows: $rows
print $data00 $data01
print $data10 $data11
print $data20 $data21
if $rows != 3 then
if $rows != 3 then
print $rows
print $rows
return -1
return -1
...
...
tools/shell/src/shellMain.c
浏览文件 @
bdbf365e
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
#include "os.h"
#include "os.h"
#include "shell.h"
#include "shell.h"
#include "tglobal.h"
#include "tglobal.h"
#include "tconfig.h"
#include "shellCommand.h"
#include "shellCommand.h"
#include "tbase64.h"
#include "tbase64.h"
#include "tlog.h"
#include "tlog.h"
...
@@ -619,20 +620,17 @@ int main(int argc, char *argv[]) {
...
@@ -619,20 +620,17 @@ int main(int argc, char *argv[]) {
shellParseArgument
(
argc
,
argv
,
&
args
);
shellParseArgument
(
argc
,
argv
,
&
args
);
#if 0
if
(
args
.
dump_config
)
{
if
(
args
.
dump_config
)
{
taosInitGlobalCfg();
taosInitCfg
(
configDir
,
NULL
,
NULL
,
NULL
,
1
);
taosReadGlobalLogCfg();
if (taosReadGlobalCfg() ! =0) {
SConfig
*
pCfg
=
taosGetCfg
();
printf("TDengine read global config failed");
if
(
NULL
==
pCfg
)
{
printf
(
"TDengine read global config failed!
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
cfgDumpCfg
(
pCfg
,
0
,
1
);
taosDumpGlobalCfg();
exit
(
0
);
exit
(
0
);
}
}
#endif
if
(
args
.
netTestRole
&&
args
.
netTestRole
[
0
]
!=
0
)
{
if
(
args
.
netTestRole
&&
args
.
netTestRole
[
0
]
!=
0
)
{
TAOS
*
con
=
NULL
;
TAOS
*
con
=
NULL
;
...
...
taos-tools
@
f36b07f7
比较
8145dd17
...
f36b07f7
Subproject commit
8145dd1713ab9e7652ea621ca7e6895fd0b21d65
Subproject commit
f36b07f710d661dca88fdd70e73b5e3e16a960e0
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录