Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
21af31f4
T
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1191
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看板
提交
21af31f4
编写于
3月 05, 2022
作者:
D
dapan
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/3.0_query_integrate' into feature/scheduler
上级
9b4bda4f
b0a4cc81
变更
109
展开全部
隐藏空白更改
内联
并排
Showing
109 changed file
with
5504 addition
and
2720 deletion
+5504
-2720
include/client/taos.h
include/client/taos.h
+1
-0
include/common/tmsg.h
include/common/tmsg.h
+5
-1
include/common/ttokendef.h
include/common/ttokendef.h
+78
-55
include/libs/index/index.h
include/libs/index/index.h
+102
-12
include/libs/monitor/monitor.h
include/libs/monitor/monitor.h
+26
-20
include/libs/nodes/cmdnodes.h
include/libs/nodes/cmdnodes.h
+8
-3
include/libs/nodes/nodes.h
include/libs/nodes/nodes.h
+7
-1
include/libs/nodes/plannodes.h
include/libs/nodes/plannodes.h
+19
-9
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+2
-0
include/libs/parser/parser.h
include/libs/parser/parser.h
+6
-2
include/libs/planner/planner.h
include/libs/planner/planner.h
+1
-1
include/libs/sync/sync.h
include/libs/sync/sync.h
+1
-3
include/libs/tfs/tfs.h
include/libs/tfs/tfs.h
+9
-0
include/os/osDir.h
include/os/osDir.h
+1
-1
include/os/osEnv.h
include/os/osEnv.h
+3
-3
include/os/osFile.h
include/os/osFile.h
+17
-7
include/os/osSysinfo.h
include/os/osSysinfo.h
+12
-12
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+14
-13
source/common/src/tglobal.c
source/common/src/tglobal.c
+3
-7
source/common/test/commonTests.cpp
source/common/test/commonTests.cpp
+2
-2
source/common/test/tmsgTest.cpp
source/common/test/tmsgTest.cpp
+1
-1
source/dnode/mgmt/impl/inc/dndEnv.h
source/dnode/mgmt/impl/inc/dndEnv.h
+3
-1
source/dnode/mgmt/impl/inc/dndMnode.h
source/dnode/mgmt/impl/inc/dndMnode.h
+1
-0
source/dnode/mgmt/impl/src/dndEnv.c
source/dnode/mgmt/impl/src/dndEnv.c
+9
-0
source/dnode/mgmt/impl/src/dndMgmt.c
source/dnode/mgmt/impl/src/dndMgmt.c
+47
-5
source/dnode/mgmt/impl/src/dndMnode.c
source/dnode/mgmt/impl/src/dndMnode.c
+7
-0
source/dnode/mnode/impl/src/mndTelem.c
source/dnode/mnode/impl/src/mndTelem.c
+6
-9
source/dnode/vnode/src/tq/tqMetaStore.c
source/dnode/vnode/src/tq/tqMetaStore.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+2
-2
source/dnode/vnode/src/tsdb/tsdbFS.c
source/dnode/vnode/src/tsdb/tsdbFS.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbFile.c
source/dnode/vnode/src/tsdb/tsdbFile.c
+7
-8
source/libs/CMakeLists.txt
source/libs/CMakeLists.txt
+0
-1
source/libs/catalog/test/catalogTests.cpp
source/libs/catalog/test/catalogTests.cpp
+3
-3
source/libs/executor/src/dataDispatcher.c
source/libs/executor/src/dataDispatcher.c
+8
-8
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+30
-15
source/libs/executor/test/executorTests.cpp
source/libs/executor/test/executorTests.cpp
+660
-530
source/libs/executor/test/sortTests.cpp
source/libs/executor/test/sortTests.cpp
+1
-1
source/libs/index/inc/indexInt.h
source/libs/index/inc/indexInt.h
+42
-19
source/libs/index/inc/index_comm.h
source/libs/index/inc/index_comm.h
+32
-0
source/libs/index/src/index.c
source/libs/index/src/index.c
+19
-7
source/libs/index/src/index_cache.c
source/libs/index/src/index_cache.c
+22
-12
source/libs/index/src/index_comm.c
source/libs/index/src/index_comm.c
+48
-0
source/libs/index/src/index_fst_counting_writer.c
source/libs/index/src/index_fst_counting_writer.c
+10
-8
source/libs/index/src/index_json.c
source/libs/index/src/index_json.c
+44
-0
source/libs/index/src/index_tfile.c
source/libs/index/src/index_tfile.c
+23
-6
source/libs/index/test/CMakeLists.txt
source/libs/index/test/CMakeLists.txt
+18
-0
source/libs/index/test/fstTest.cc
source/libs/index/test/fstTest.cc
+15
-10
source/libs/index/test/fstUT.cc
source/libs/index/test/fstUT.cc
+21
-5
source/libs/index/test/jsonUT.cc
source/libs/index/test/jsonUT.cc
+135
-0
source/libs/monitor/src/monitor.c
source/libs/monitor/src/monitor.c
+235
-16
source/libs/monitor/test/monTest.cpp
source/libs/monitor/test/monTest.cpp
+247
-6
source/libs/nodes/src/nodesCloneFuncs.c
source/libs/nodes/src/nodesCloneFuncs.c
+32
-0
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+164
-87
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+46
-8
source/libs/parser/inc/astCreateFuncs.h
source/libs/parser/inc/astCreateFuncs.h
+6
-0
source/libs/parser/inc/new_sql.y
source/libs/parser/inc/new_sql.y
+12
-6
source/libs/parser/src/astCreateFuncs.c
source/libs/parser/src/astCreateFuncs.c
+42
-19
source/libs/parser/src/astParse.c
source/libs/parser/src/astParse.c
+18
-13
source/libs/parser/src/astTranslate.c
source/libs/parser/src/astTranslate.c
+226
-7
source/libs/parser/src/insertParser.c
source/libs/parser/src/insertParser.c
+9
-5
source/libs/parser/src/new_sql.c
source/libs/parser/src/new_sql.c
+1350
-1067
source/libs/parser/src/ttokenizer.c
source/libs/parser/src/ttokenizer.c
+17
-17
source/libs/parser/test/mockCatalog.cpp
source/libs/parser/test/mockCatalog.cpp
+8
-4
source/libs/parser/test/mockCatalogService.cpp
source/libs/parser/test/mockCatalogService.cpp
+17
-0
source/libs/parser/test/mockCatalogService.h
source/libs/parser/test/mockCatalogService.h
+1
-0
source/libs/parser/test/parserTest.cpp
source/libs/parser/test/parserTest.cpp
+20
-0
source/libs/planner/inc/plannerInt.h
source/libs/planner/inc/plannerInt.h
+10
-1
source/libs/planner/src/logicPlan.c
source/libs/planner/src/logicPlan.c
+12
-1
source/libs/planner/src/physicalPlan.c
source/libs/planner/src/physicalPlan.c
+209
-75
source/libs/planner/src/planner.c
source/libs/planner/src/planner.c
+9
-2
source/libs/planner/test/plannerTest.cpp
source/libs/planner/test/plannerTest.cpp
+9
-1
source/libs/qworker/test/qworkerTests.cpp
source/libs/qworker/test/qworkerTests.cpp
+2
-2
source/libs/scalar/test/filter/filterTests.cpp
source/libs/scalar/test/filter/filterTests.cpp
+2
-2
source/libs/scalar/test/scalar/scalarTests.cpp
source/libs/scalar/test/scalar/scalarTests.cpp
+23
-15
source/libs/scheduler/test/schedulerTests.cpp
source/libs/scheduler/test/schedulerTests.cpp
+13
-11
source/libs/sync/inc/syncInt.h
source/libs/sync/inc/syncInt.h
+46
-26
source/libs/sync/inc/syncMessage.h
source/libs/sync/inc/syncMessage.h
+107
-75
source/libs/sync/inc/syncVoteMgr.h
source/libs/sync/inc/syncVoteMgr.h
+6
-0
source/libs/sync/src/syncIO.c
source/libs/sync/src/syncIO.c
+4
-10
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+1
-11
source/libs/sync/src/syncMessage.c
source/libs/sync/src/syncMessage.c
+337
-56
source/libs/sync/test/syncEncodeTest.cpp
source/libs/sync/test/syncEncodeTest.cpp
+348
-23
source/libs/sync/test/syncIOSendMsgClientTest.cpp
source/libs/sync/test/syncIOSendMsgClientTest.cpp
+1
-1
source/libs/sync/test/syncIOSendMsgServerTest.cpp
source/libs/sync/test/syncIOSendMsgServerTest.cpp
+1
-1
source/libs/sync/test/syncIOSendMsgTest.cpp
source/libs/sync/test/syncIOSendMsgTest.cpp
+1
-1
source/libs/sync/test/syncIOTickPingTest.cpp
source/libs/sync/test/syncIOTickPingTest.cpp
+1
-1
source/libs/sync/test/syncIOTickQTest.cpp
source/libs/sync/test/syncIOTickQTest.cpp
+1
-1
source/libs/sync/test/syncPingTest.cpp
source/libs/sync/test/syncPingTest.cpp
+19
-12
source/libs/sync/test/syncRaftStoreTest.cpp
source/libs/sync/test/syncRaftStoreTest.cpp
+2
-2
source/libs/sync/test/syncTest.cpp
source/libs/sync/test/syncTest.cpp
+1
-1
source/libs/tdb/src/db/tdb.c
source/libs/tdb/src/db/tdb.c
+1
-1
source/libs/tdb/src/db/tdbUtil.c
source/libs/tdb/src/db/tdbUtil.c
+21
-22
source/libs/tdb/src/inc/tdbUtil.h
source/libs/tdb/src/inc/tdbUtil.h
+4
-4
source/libs/tdb/test/tdbTest.cpp
source/libs/tdb/test/tdbTest.cpp
+1
-1
source/libs/tfs/CMakeLists.txt
source/libs/tfs/CMakeLists.txt
+1
-1
source/libs/tfs/src/tfs.c
source/libs/tfs/src/tfs.c
+23
-9
source/libs/tfs/test/tfsTest.cpp
source/libs/tfs/test/tfsTest.cpp
+49
-49
source/libs/transport/src/transSrv.c
source/libs/transport/src/transSrv.c
+12
-10
source/libs/wal/src/walMeta.c
source/libs/wal/src/walMeta.c
+11
-11
source/os/src/osDir.c
source/os/src/osDir.c
+1
-1
source/os/src/osEnv.c
source/os/src/osEnv.c
+8
-3
source/os/src/osFile.c
source/os/src/osFile.c
+39
-0
source/os/src/osSysinfo.c
source/os/src/osSysinfo.c
+170
-199
source/util/src/tjson.c
source/util/src/tjson.c
+7
-8
source/util/test/cacheTest.cpp
source/util/test/cacheTest.cpp
+1
-1
source/util/test/encodeTest.cpp
source/util/test/encodeTest.cpp
+1
-1
source/util/test/freelistTest.cpp
source/util/test/freelistTest.cpp
+1
-1
source/util/test/hashTest.cpp
source/util/test/hashTest.cpp
+2
-2
tools/shell/src/backup/shellImport.c
tools/shell/src/backup/shellImport.c
+3
-5
未找到文件。
include/client/taos.h
浏览文件 @
21af31f4
...
@@ -51,6 +51,7 @@ typedef void **TAOS_ROW;
...
@@ -51,6 +51,7 @@ typedef void **TAOS_ROW;
#define TSDB_DATA_TYPE_JSON 17 // json
#define TSDB_DATA_TYPE_JSON 17 // json
#define TSDB_DATA_TYPE_DECIMAL 18 // decimal
#define TSDB_DATA_TYPE_DECIMAL 18 // decimal
#define TSDB_DATA_TYPE_BLOB 19 // binary
#define TSDB_DATA_TYPE_BLOB 19 // binary
#define TSDB_DATA_TYPE_MEDIUMBLOB 20
typedef
enum
{
typedef
enum
{
TSDB_OPTION_LOCALE
,
TSDB_OPTION_LOCALE
,
...
...
include/common/tmsg.h
浏览文件 @
21af31f4
...
@@ -419,7 +419,11 @@ typedef struct {
...
@@ -419,7 +419,11 @@ typedef struct {
* But for data in vnode side, we need all the following information.
* But for data in vnode side, we need all the following information.
*/
*/
typedef
struct
{
typedef
struct
{
int16_t
colId
;
union
{
int16_t
colId
;
int16_t
slotId
;
};
int16_t
type
;
int16_t
type
;
int16_t
bytes
;
int16_t
bytes
;
SColumnFilterList
flist
;
SColumnFilterList
flist
;
...
...
include/common/ttokendef.h
浏览文件 @
21af31f4
...
@@ -57,63 +57,86 @@
...
@@ -57,63 +57,86 @@
#define TK_VGROUPS 39
#define TK_VGROUPS 39
#define TK_SINGLESTABLE 40
#define TK_SINGLESTABLE 40
#define TK_STREAMMODE 41
#define TK_STREAMMODE 41
#define TK_NK_FLOAT 42
#define TK_USE 42
#define TK_NK_BOOL 43
#define TK_TABLE 43
#define TK_TIMESTAMP 44
#define TK_NK_LP 44
#define TK_NK_VARIABLE 45
#define TK_NK_RP 45
#define TK_NK_COMMA 46
#define TK_NK_ID 46
#define TK_NK_ID 47
#define TK_NK_DOT 47
#define TK_NK_LP 48
#define TK_NK_COMMA 48
#define TK_NK_RP 49
#define TK_COMMENT 49
#define TK_NK_DOT 50
#define TK_BOOL 50
#define TK_BETWEEN 51
#define TK_TINYINT 51
#define TK_IS 52
#define TK_SMALLINT 52
#define TK_NULL 53
#define TK_INT 53
#define TK_NK_LT 54
#define TK_INTEGER 54
#define TK_NK_GT 55
#define TK_BIGINT 55
#define TK_NK_LE 56
#define TK_FLOAT 56
#define TK_NK_GE 57
#define TK_DOUBLE 57
#define TK_NK_NE 58
#define TK_BINARY 58
#define TK_NK_EQ 59
#define TK_TIMESTAMP 59
#define TK_LIKE 60
#define TK_NCHAR 60
#define TK_MATCH 61
#define TK_UNSIGNED 61
#define TK_NMATCH 62
#define TK_JSON 62
#define TK_IN 63
#define TK_VARCHAR 63
#define TK_FROM 64
#define TK_MEDIUMBLOB 64
#define TK_AS 65
#define TK_BLOB 65
#define TK_JOIN 66
#define TK_VARBINARY 66
#define TK_ON 67
#define TK_DECIMAL 67
#define TK_INNER 68
#define TK_SHOW 68
#define TK_SELECT 69
#define TK_DATABASES 69
#define TK_DISTINCT 70
#define TK_TABLES 70
#define TK_WHERE 71
#define TK_NK_FLOAT 71
#define TK_PARTITION 72
#define TK_NK_BOOL 72
#define TK_BY 73
#define TK_NK_VARIABLE 73
#define TK_SESSION 74
#define TK_BETWEEN 74
#define TK_STATE_WINDOW 75
#define TK_IS 75
#define TK_INTERVAL 76
#define TK_NULL 76
#define TK_SLIDING 77
#define TK_NK_LT 77
#define TK_FILL 78
#define TK_NK_GT 78
#define TK_VALUE 79
#define TK_NK_LE 79
#define TK_NONE 80
#define TK_NK_GE 80
#define TK_PREV 81
#define TK_NK_NE 81
#define TK_LINEAR 82
#define TK_NK_EQ 82
#define TK_NEXT 83
#define TK_LIKE 83
#define TK_GROUP 84
#define TK_MATCH 84
#define TK_HAVING 85
#define TK_NMATCH 85
#define TK_ORDER 86
#define TK_IN 86
#define TK_SLIMIT 87
#define TK_FROM 87
#define TK_SOFFSET 88
#define TK_AS 88
#define TK_LIMIT 89
#define TK_JOIN 89
#define TK_OFFSET 90
#define TK_ON 90
#define TK_ASC 91
#define TK_INNER 91
#define TK_DESC 92
#define TK_SELECT 92
#define TK_NULLS 93
#define TK_DISTINCT 93
#define TK_FIRST 94
#define TK_WHERE 94
#define TK_LAST 95
#define TK_PARTITION 95
#define TK_BY 96
#define TK_SESSION 97
#define TK_STATE_WINDOW 98
#define TK_INTERVAL 99
#define TK_SLIDING 100
#define TK_FILL 101
#define TK_VALUE 102
#define TK_NONE 103
#define TK_PREV 104
#define TK_LINEAR 105
#define TK_NEXT 106
#define TK_GROUP 107
#define TK_HAVING 108
#define TK_ORDER 109
#define TK_SLIMIT 110
#define TK_SOFFSET 111
#define TK_LIMIT 112
#define TK_OFFSET 113
#define TK_ASC 114
#define TK_DESC 115
#define TK_NULLS 116
#define TK_FIRST 117
#define TK_LAST 118
#define TK_SPACE 300
#define TK_SPACE 300
#define TK_COMMENT 301
#define TK_
NK_
COMMENT 301
#define TK_ILLEGAL 302
#define TK_ILLEGAL 302
#define TK_HEX 303 // hex number 0x123
#define TK_HEX 303 // hex number 0x123
#define TK_OCT 304 // oct number
#define TK_OCT 304 // oct number
...
...
include/libs/index/index.h
浏览文件 @
21af31f4
...
@@ -29,6 +29,12 @@ typedef struct SIndexOpts SIndexOpts;
...
@@ -29,6 +29,12 @@ typedef struct SIndexOpts SIndexOpts;
typedef
struct
SIndexMultiTermQuery
SIndexMultiTermQuery
;
typedef
struct
SIndexMultiTermQuery
SIndexMultiTermQuery
;
typedef
struct
SArray
SIndexMultiTerm
;
typedef
struct
SArray
SIndexMultiTerm
;
typedef
struct
SIndex
SIndexJson
;
typedef
struct
SIndexTerm
SIndexJsonTerm
;
typedef
struct
SIndexOpts
SIndexJsonOpts
;
typedef
struct
SIndexMultiTermQuery
SIndexJsonMultiTermQuery
;
typedef
struct
SArray
SIndexJsonMultiTerm
;
typedef
enum
{
typedef
enum
{
ADD_VALUE
,
// add index colume value
ADD_VALUE
,
// add index colume value
DEL_VALUE
,
// delete index column value
DEL_VALUE
,
// delete index column value
...
@@ -39,24 +45,108 @@ typedef enum {
...
@@ -39,24 +45,108 @@ typedef enum {
}
SIndexOperOnColumn
;
}
SIndexOperOnColumn
;
typedef
enum
{
MUST
=
0
,
SHOULD
=
1
,
NOT
=
2
}
EIndexOperatorType
;
typedef
enum
{
MUST
=
0
,
SHOULD
=
1
,
NOT
=
2
}
EIndexOperatorType
;
typedef
enum
{
QUERY_TERM
=
0
,
QUERY_PREFIX
=
1
,
QUERY_SUFFIX
=
2
,
QUERY_REGEX
=
3
}
EIndexQueryType
;
typedef
enum
{
QUERY_TERM
=
0
,
QUERY_PREFIX
=
1
,
QUERY_SUFFIX
=
2
,
QUERY_REGEX
=
3
,
QUERY_RANGE
=
4
}
EIndexQueryType
;
/*
/*
*
@param: oper
*
create multi query
*
*
@param oper (input, relation between querys)
*/
*/
SIndexMultiTermQuery
*
indexMultiTermQueryCreate
(
EIndexOperatorType
oper
);
SIndexMultiTermQuery
*
indexMultiTermQueryCreate
(
EIndexOperatorType
oper
);
void
indexMultiTermQueryDestroy
(
SIndexMultiTermQuery
*
pQuery
);
int
indexMultiTermQueryAdd
(
SIndexMultiTermQuery
*
pQuery
,
SIndexTerm
*
term
,
EIndexQueryType
type
);
/*
/*
* @param:
* destroy multi query
* @param:
* @param pQuery (input, multi-query-object to be destory)
*/
void
indexMultiTermQueryDestroy
(
SIndexMultiTermQuery
*
pQuery
);
/*
* add query to multi query
* @param pQuery (input, multi-query-object)
* @param term (input, single query term)
* @param type (input, single query type)
* @return error code
*/
int
indexMultiTermQueryAdd
(
SIndexMultiTermQuery
*
pQuery
,
SIndexTerm
*
term
,
EIndexQueryType
type
);
/*
* open index
* @param opt (input, index opt)
* @param path (input, index path)
* @param index (output, index object)
* @return error code
*/
int
indexOpen
(
SIndexOpts
*
opt
,
const
char
*
path
,
SIndex
**
index
);
/*
* close index
* @param index (input, index to be closed)
* @return error code
*/
*/
int
indexOpen
(
SIndexOpts
*
opt
,
const
char
*
path
,
SIndex
**
index
);
void
indexClose
(
SIndex
*
index
);
void
indexClose
(
SIndex
*
index
);
int
indexPut
(
SIndex
*
index
,
SIndexMultiTerm
*
terms
,
uint64_t
uid
);
int
indexDelete
(
SIndex
*
index
,
SIndexMultiTermQuery
*
query
);
/*
int
indexSearch
(
SIndex
*
index
,
SIndexMultiTermQuery
*
query
,
SArray
*
result
);
* insert terms into index
int
indexRebuild
(
SIndex
*
index
,
SIndexOpts
*
opt
);
* @param index (input, index object)
* @param term (input, terms inserted into index)
* @param uid (input, uid of terms)
* @return error code
*/
int
indexPut
(
SIndex
*
index
,
SIndexMultiTerm
*
terms
,
uint64_t
uid
);
/*
* delete terms that meet query condition
* @param index (input, index object)
* @param query (input, condition query to deleted)
* @return error code
*/
int
indexDelete
(
SIndex
*
index
,
SIndexMultiTermQuery
*
query
);
/*
* search index
* @param index (input, index object)
* @param query (input, multi query condition)
* @param result(output, query result)
* @return error code
*/
int
indexSearch
(
SIndex
*
index
,
SIndexMultiTermQuery
*
query
,
SArray
*
result
);
/*
* rebuild index
* @param index (input, index object)
* @parma opt (input, rebuild index opts)
* @return error code
*/
int
indexRebuild
(
SIndex
*
index
,
SIndexOpts
*
opt
);
/*
* open index
* @param opt (input,index json opt)
* @param path (input, index json path)
* @param index (output, index json object)
* @return error code
*/
int
tIndexJsonOpen
(
SIndexJsonOpts
*
opts
,
const
char
*
path
,
SIndexJson
**
index
);
/*
* close index
* @param index (input, index to be closed)
* @return void
*/
void
tIndexJsonClose
(
SIndexJson
*
index
);
/*
* insert terms into index
* @param index (input, index object)
* @param term (input, terms inserted into index)
* @param uid (input, uid of terms)
* @return error code
*/
int
tIndexJsonPut
(
SIndexJson
*
index
,
SIndexJsonMultiTerm
*
terms
,
uint64_t
uid
);
/*
* search index
* @param index (input, index object)
* @param query (input, multi query condition)
* @param result(output, query result)
* @return error code
*/
int
tIndexJsonSearch
(
SIndexJson
*
index
,
SIndexJsonMultiTermQuery
*
query
,
SArray
*
result
);
/*
/*
* @param
* @param
* @param
* @param
...
...
include/libs/monitor/monitor.h
浏览文件 @
21af31f4
...
@@ -23,6 +23,11 @@
...
@@ -23,6 +23,11 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
#define MON_STATUS_LEN 8
#define MON_ROLE_LEN 9
#define MON_VER_LEN 12
#define MON_LOG_LEN 1024
typedef
struct
{
typedef
struct
{
int32_t
dnode_id
;
int32_t
dnode_id
;
char
dnode_ep
[
TSDB_EP_LEN
];
char
dnode_ep
[
TSDB_EP_LEN
];
...
@@ -31,19 +36,19 @@ typedef struct {
...
@@ -31,19 +36,19 @@ typedef struct {
typedef
struct
{
typedef
struct
{
int32_t
dnode_id
;
int32_t
dnode_id
;
char
dnode_ep
[
TSDB_EP_LEN
];
char
dnode_ep
[
TSDB_EP_LEN
];
char
status
[
8
];
char
status
[
MON_STATUS_LEN
];
}
SMonDnodeDesc
;
}
SMonDnodeDesc
;
typedef
struct
{
typedef
struct
{
int32_t
mnode_id
;
int32_t
mnode_id
;
char
mnode_ep
[
TSDB_EP_LEN
];
char
mnode_ep
[
TSDB_EP_LEN
];
char
role
[
8
];
char
role
[
MON_ROLE_LEN
];
}
SMonMnodeDesc
;
}
SMonMnodeDesc
;
typedef
struct
{
typedef
struct
{
char
first_ep
[
TSDB_EP_LEN
];
char
first_ep
[
TSDB_EP_LEN
];
int32_t
first_ep_dnode_id
;
int32_t
first_ep_dnode_id
;
char
version
[
12
];
char
version
[
MON_VER_LEN
];
float
master_uptime
;
// day
float
master_uptime
;
// day
int32_t
monitor_interval
;
// sec
int32_t
monitor_interval
;
// sec
int32_t
vgroups_total
;
int32_t
vgroups_total
;
...
@@ -57,19 +62,18 @@ typedef struct {
...
@@ -57,19 +62,18 @@ typedef struct {
typedef
struct
{
typedef
struct
{
int32_t
dnode_id
;
int32_t
dnode_id
;
int8_t
vnode_online
;
char
vnode_role
[
MON_ROLE_LEN
];
char
vnode_role
[
8
];
}
SMonVnodeDesc
;
}
SMonVnodeDesc
;
typedef
struct
{
typedef
struct
{
int32_t
vgroup_id
;
int32_t
vgroup_id
;
char
database_name
[
TSDB_DB_NAME_LEN
];
int32_t
tables_num
;
char
status
[
MON_STATUS_LEN
];
SMonVnodeDesc
vnodes
[
TSDB_MAX_REPLICA
];
SMonVnodeDesc
vnodes
[
TSDB_MAX_REPLICA
];
}
SMonVgroupDesc
;
}
SMonVgroupDesc
;
typedef
struct
{
typedef
struct
{
char
database_name
[
TSDB_DB_NAME_LEN
];
int32_t
tables_num
;
int8_t
status
;
SArray
*
vgroups
;
// array of SMonVgroupDesc
SArray
*
vgroups
;
// array of SMonVgroupDesc
}
SMonVgroupInfo
;
}
SMonVgroupInfo
;
...
@@ -84,18 +88,18 @@ typedef struct {
...
@@ -84,18 +88,18 @@ typedef struct {
float
cpu_engine
;
float
cpu_engine
;
float
cpu_system
;
float
cpu_system
;
float
cpu_cores
;
float
cpu_cores
;
float
mem_engine
;
// M
B
int64_t
mem_engine
;
// K
B
float
mem_system
;
// M
B
int64_t
mem_system
;
// K
B
float
mem_total
;
// M
B
int64_t
mem_total
;
// K
B
float
disk_engine
;
// GB
float
disk_engine
;
// GB
float
disk_used
;
// GB
float
disk_used
;
// GB
float
disk_total
;
// GB
float
disk_total
;
// GB
float
net_in
;
// Kb/s
int64_t
net_in
;
float
net_out
;
// Kb/s
int64_t
net_out
;
float
io_read
;
// Mb/s
float
io_read
;
float
io_write
;
// Mb/s
float
io_write
;
float
io_read_disk
;
// Mb/s
float
io_read_disk
;
float
io_write_disk
;
// Mb/s
float
io_write_disk
;
int32_t
req_select
;
int32_t
req_select
;
float
req_select_rate
;
float
req_select_rate
;
int32_t
req_insert
;
int32_t
req_insert
;
...
@@ -107,7 +111,7 @@ typedef struct {
...
@@ -107,7 +111,7 @@ typedef struct {
int32_t
errors
;
int32_t
errors
;
int32_t
vnodes_num
;
int32_t
vnodes_num
;
int32_t
masters
;
int32_t
masters
;
int
32_t
has_mnode
;
int
8_t
has_mnode
;
}
SMonDnodeInfo
;
}
SMonDnodeInfo
;
typedef
struct
{
typedef
struct
{
...
@@ -117,13 +121,15 @@ typedef struct {
...
@@ -117,13 +121,15 @@ typedef struct {
}
SMonDiskDesc
;
}
SMonDiskDesc
;
typedef
struct
{
typedef
struct
{
SArray
*
disks
;
// array of SMonDiskDesc
SArray
*
datadirs
;
// array of SMonDiskDesc
SMonDiskDesc
logdir
;
SMonDiskDesc
tempdir
;
}
SMonDiskInfo
;
}
SMonDiskInfo
;
typedef
struct
{
typedef
struct
{
int64_t
ts
;
int64_t
ts
;
int8_t
level
;
int8_t
level
;
char
content
[
1024
];
char
content
[
MON_LOG_LEN
];
}
SMonLogItem
;
}
SMonLogItem
;
typedef
struct
SMonInfo
SMonInfo
;
typedef
struct
SMonInfo
SMonInfo
;
...
...
include/libs/nodes/cmdnodes.h
浏览文件 @
21af31f4
...
@@ -13,8 +13,8 @@
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#ifndef _TD_
PLANN
_NODES_H_
#ifndef _TD_
CMD
_NODES_H_
#define _TD_
PLANN
_NODES_H_
#define _TD_
CMD
_NODES_H_
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
...
@@ -49,6 +49,11 @@ typedef struct SCreateDatabaseStmt {
...
@@ -49,6 +49,11 @@ typedef struct SCreateDatabaseStmt {
SDatabaseOptions
options
;
SDatabaseOptions
options
;
}
SCreateDatabaseStmt
;
}
SCreateDatabaseStmt
;
typedef
struct
SUseDatabaseStmt
{
ENodeType
type
;
char
dbName
[
TSDB_DB_NAME_LEN
];
}
SUseDatabaseStmt
;
typedef
struct
STableOptions
{
typedef
struct
STableOptions
{
int32_t
keep
;
int32_t
keep
;
int32_t
ttl
;
int32_t
ttl
;
...
@@ -77,4 +82,4 @@ typedef struct SCreateTableStmt {
...
@@ -77,4 +82,4 @@ typedef struct SCreateTableStmt {
}
}
#endif
#endif
#endif
/*_TD_
PLANN
_NODES_H_*/
#endif
/*_TD_
CMD
_NODES_H_*/
include/libs/nodes/nodes.h
浏览文件 @
21af31f4
...
@@ -70,16 +70,19 @@ typedef enum ENodeType {
...
@@ -70,16 +70,19 @@ typedef enum ENodeType {
// Statement nodes are used in parser and planner module.
// Statement nodes are used in parser and planner module.
QUERY_NODE_SET_OPERATOR
,
QUERY_NODE_SET_OPERATOR
,
QUERY_NODE_SELECT_STMT
,
QUERY_NODE_SELECT_STMT
,
QUERY_NODE_SHOW_STMT
,
QUERY_NODE_VNODE_MODIF_STMT
,
QUERY_NODE_VNODE_MODIF_STMT
,
QUERY_NODE_CREATE_DATABASE_STMT
,
QUERY_NODE_CREATE_DATABASE_STMT
,
QUERY_NODE_CREATE_TABLE_STMT
,
QUERY_NODE_CREATE_TABLE_STMT
,
QUERY_NODE_USE_DATABASE_STMT
,
QUERY_NODE_SHOW_DATABASES_STMT
,
// temp
QUERY_NODE_SHOW_TABLES_STMT
,
// temp
// logic plan node
// logic plan node
QUERY_NODE_LOGIC_PLAN_SCAN
,
QUERY_NODE_LOGIC_PLAN_SCAN
,
QUERY_NODE_LOGIC_PLAN_JOIN
,
QUERY_NODE_LOGIC_PLAN_JOIN
,
QUERY_NODE_LOGIC_PLAN_AGG
,
QUERY_NODE_LOGIC_PLAN_AGG
,
QUERY_NODE_LOGIC_PLAN_PROJECT
,
QUERY_NODE_LOGIC_PLAN_PROJECT
,
QUERY_NODE_LOGIC_PLAN_VNODE_MODIF
,
QUERY_NODE_LOGIC_SUBPLAN
,
QUERY_NODE_LOGIC_SUBPLAN
,
QUERY_NODE_LOGIC_PLAN
,
QUERY_NODE_LOGIC_PLAN
,
...
@@ -94,6 +97,7 @@ typedef enum ENodeType {
...
@@ -94,6 +97,7 @@ typedef enum ENodeType {
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
,
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
,
QUERY_NODE_PHYSICAL_PLAN_SORT
,
QUERY_NODE_PHYSICAL_PLAN_SORT
,
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
,
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
,
QUERY_NODE_PHYSICAL_PLAN_INSERT
,
QUERY_NODE_PHYSICAL_SUBPLAN
,
QUERY_NODE_PHYSICAL_SUBPLAN
,
QUERY_NODE_PHYSICAL_PLAN
QUERY_NODE_PHYSICAL_PLAN
}
ENodeType
;
}
ENodeType
;
...
@@ -125,6 +129,7 @@ void nodesDestroyNode(SNodeptr pNode);
...
@@ -125,6 +129,7 @@ void nodesDestroyNode(SNodeptr pNode);
SNodeList
*
nodesMakeList
();
SNodeList
*
nodesMakeList
();
int32_t
nodesListAppend
(
SNodeList
*
pList
,
SNodeptr
pNode
);
int32_t
nodesListAppend
(
SNodeList
*
pList
,
SNodeptr
pNode
);
int32_t
nodesListStrictAppend
(
SNodeList
*
pList
,
SNodeptr
pNode
);
int32_t
nodesListAppendList
(
SNodeList
*
pTarget
,
SNodeList
*
pSrc
);
int32_t
nodesListAppendList
(
SNodeList
*
pTarget
,
SNodeList
*
pSrc
);
SListCell
*
nodesListErase
(
SNodeList
*
pList
,
SListCell
*
pCell
);
SListCell
*
nodesListErase
(
SNodeList
*
pList
,
SListCell
*
pCell
);
SNodeptr
nodesListGetNode
(
SNodeList
*
pList
,
int32_t
index
);
SNodeptr
nodesListGetNode
(
SNodeList
*
pList
,
int32_t
index
);
...
@@ -153,6 +158,7 @@ bool nodesEqualNode(const SNodeptr a, const SNodeptr b);
...
@@ -153,6 +158,7 @@ bool nodesEqualNode(const SNodeptr a, const SNodeptr b);
SNodeptr
nodesCloneNode
(
const
SNodeptr
pNode
);
SNodeptr
nodesCloneNode
(
const
SNodeptr
pNode
);
SNodeList
*
nodesCloneList
(
const
SNodeList
*
pList
);
SNodeList
*
nodesCloneList
(
const
SNodeList
*
pList
);
const
char
*
nodesNodeName
(
ENodeType
type
);
int32_t
nodesNodeToString
(
const
SNodeptr
pNode
,
bool
format
,
char
**
pStr
,
int32_t
*
pLen
);
int32_t
nodesNodeToString
(
const
SNodeptr
pNode
,
bool
format
,
char
**
pStr
,
int32_t
*
pLen
);
int32_t
nodesStringToNode
(
const
char
*
pStr
,
SNode
**
pNode
);
int32_t
nodesStringToNode
(
const
char
*
pStr
,
SNode
**
pNode
);
...
...
include/libs/nodes/plannodes.h
浏览文件 @
21af31f4
...
@@ -43,6 +43,7 @@ typedef struct SScanLogicNode {
...
@@ -43,6 +43,7 @@ typedef struct SScanLogicNode {
SLogicNode
node
;
SLogicNode
node
;
SNodeList
*
pScanCols
;
SNodeList
*
pScanCols
;
struct
STableMeta
*
pMeta
;
struct
STableMeta
*
pMeta
;
SVgroupsInfo
*
pVgroupList
;
EScanType
scanType
;
EScanType
scanType
;
uint8_t
scanFlag
;
// denotes reversed scan of data or not
uint8_t
scanFlag
;
// denotes reversed scan of data or not
STimeWindow
scanRange
;
STimeWindow
scanRange
;
...
@@ -65,11 +66,27 @@ typedef struct SProjectLogicNode {
...
@@ -65,11 +66,27 @@ typedef struct SProjectLogicNode {
SNodeList
*
pProjections
;
SNodeList
*
pProjections
;
}
SProjectLogicNode
;
}
SProjectLogicNode
;
typedef
struct
SVnodeModifLogicNode
{
ENodeType
type
;;
int32_t
msgType
;
SArray
*
pDataBlocks
;
SVgDataBlocks
*
pVgDataBlocks
;
}
SVnodeModifLogicNode
;
typedef
enum
ESubplanType
{
SUBPLAN_TYPE_MERGE
=
1
,
SUBPLAN_TYPE_PARTIAL
,
SUBPLAN_TYPE_SCAN
,
SUBPLAN_TYPE_MODIFY
}
ESubplanType
;
typedef
struct
SSubLogicPlan
{
typedef
struct
SSubLogicPlan
{
ENodeType
type
;
ENodeType
type
;
SNodeList
*
pChildren
;
SNodeList
*
pChildren
;
SNodeList
*
pParents
;
SNodeList
*
pParents
;
SLogicNode
*
pNode
;
SLogicNode
*
pNode
;
ESubplanType
subplanType
;
int32_t
level
;
}
SSubLogicPlan
;
}
SSubLogicPlan
;
typedef
struct
SQueryLogicPlan
{
typedef
struct
SQueryLogicPlan
{
...
@@ -96,7 +113,7 @@ typedef struct SDataBlockDescNode {
...
@@ -96,7 +113,7 @@ typedef struct SDataBlockDescNode {
typedef
struct
SPhysiNode
{
typedef
struct
SPhysiNode
{
ENodeType
type
;
ENodeType
type
;
SDataBlockDescNode
o
utputDataBlockDesc
;
SDataBlockDescNode
*
pO
utputDataBlockDesc
;
SNode
*
pConditions
;
SNode
*
pConditions
;
SNodeList
*
pChildren
;
SNodeList
*
pChildren
;
struct
SPhysiNode
*
pParent
;
struct
SPhysiNode
*
pParent
;
...
@@ -158,7 +175,7 @@ typedef struct SExchangePhysiNode {
...
@@ -158,7 +175,7 @@ typedef struct SExchangePhysiNode {
typedef
struct
SDataSinkNode
{
typedef
struct
SDataSinkNode
{
ENodeType
type
;;
ENodeType
type
;;
SDataBlockDescNode
i
nputDataBlockDesc
;
SDataBlockDescNode
*
pI
nputDataBlockDesc
;
}
SDataSinkNode
;
}
SDataSinkNode
;
typedef
struct
SDataDispatcherNode
{
typedef
struct
SDataDispatcherNode
{
...
@@ -178,13 +195,6 @@ typedef struct SSubplanId {
...
@@ -178,13 +195,6 @@ typedef struct SSubplanId {
int32_t
subplanId
;
int32_t
subplanId
;
}
SSubplanId
;
}
SSubplanId
;
typedef
enum
ESubplanType
{
SUBPLAN_TYPE_MERGE
=
1
,
SUBPLAN_TYPE_PARTIAL
,
SUBPLAN_TYPE_SCAN
,
SUBPLAN_TYPE_MODIFY
}
ESubplanType
;
typedef
struct
SSubplan
{
typedef
struct
SSubplan
{
ENodeType
type
;
ENodeType
type
;
SSubplanId
id
;
// unique id of the subplan
SSubplanId
id
;
// unique id of the subplan
...
...
include/libs/nodes/querynodes.h
浏览文件 @
21af31f4
...
@@ -123,6 +123,7 @@ struct STableMeta;
...
@@ -123,6 +123,7 @@ struct STableMeta;
typedef
struct
SRealTableNode
{
typedef
struct
SRealTableNode
{
STableNode
table
;
// QUERY_NODE_REAL_TABLE
STableNode
table
;
// QUERY_NODE_REAL_TABLE
struct
STableMeta
*
pMeta
;
struct
STableMeta
*
pMeta
;
SVgroupsInfo
*
pVgroupList
;
}
SRealTableNode
;
}
SRealTableNode
;
typedef
struct
STempTableNode
{
typedef
struct
STempTableNode
{
...
@@ -264,6 +265,7 @@ typedef struct SVgDataBlocks {
...
@@ -264,6 +265,7 @@ typedef struct SVgDataBlocks {
typedef
struct
SVnodeModifOpStmt
{
typedef
struct
SVnodeModifOpStmt
{
ENodeType
nodeType
;
ENodeType
nodeType
;
ENodeType
sqlNodeType
;
SArray
*
pDataBlocks
;
// data block for each vgroup, SArray<SVgDataBlocks*>.
SArray
*
pDataBlocks
;
// data block for each vgroup, SArray<SVgDataBlocks*>.
int8_t
schemaAttache
;
// denote if submit block is built with table schema or not
int8_t
schemaAttache
;
// denote if submit block is built with table schema or not
uint8_t
payloadType
;
// EPayloadType. 0: K-V payload for non-prepare insert, 1: rawPayload for prepare insert
uint8_t
payloadType
;
// EPayloadType. 0: K-V payload for non-prepare insert, 1: rawPayload for prepare insert
...
...
include/libs/parser/parser.h
浏览文件 @
21af31f4
...
@@ -38,16 +38,20 @@ typedef struct SParseContext {
...
@@ -38,16 +38,20 @@ typedef struct SParseContext {
typedef
struct
SCmdMsgInfo
{
typedef
struct
SCmdMsgInfo
{
int16_t
msgType
;
int16_t
msgType
;
SEpSet
epSet
;
SEpSet
epSet
;
char
*
pMsg
;
void
*
pMsg
;
int32_t
msgLen
;
int32_t
msgLen
;
void
*
pExtension
;
// todo remove it soon
}
SCmdMsgInfo
;
}
SCmdMsgInfo
;
typedef
struct
SQuery
{
typedef
struct
SQuery
{
bool
isCmd
;
bool
directRpc
;
bool
haveResultSet
;
ENodeType
sqlNodeType
;
SNode
*
pRoot
;
SNode
*
pRoot
;
int32_t
numOfResCols
;
int32_t
numOfResCols
;
SSchema
*
pResSchema
;
SSchema
*
pResSchema
;
SCmdMsgInfo
*
pCmdMsg
;
SCmdMsgInfo
*
pCmdMsg
;
int32_t
msgType
;
}
SQuery
;
}
SQuery
;
int32_t
qParseQuerySql
(
SParseContext
*
pCxt
,
SQuery
**
pQuery
);
int32_t
qParseQuerySql
(
SParseContext
*
pCxt
,
SQuery
**
pQuery
);
...
...
include/libs/planner/planner.h
浏览文件 @
21af31f4
...
@@ -28,7 +28,7 @@ typedef struct SPlanContext {
...
@@ -28,7 +28,7 @@ typedef struct SPlanContext {
}
SPlanContext
;
}
SPlanContext
;
// Create the physical plan for the query, according to the AST.
// Create the physical plan for the query, according to the AST.
int32_t
qCreateQueryPlan
(
SPlanContext
*
pCxt
,
SQueryPlan
**
pPlan
);
int32_t
qCreateQueryPlan
(
SPlanContext
*
pCxt
,
SQueryPlan
**
pPlan
,
SArray
*
pExecNodeList
);
// Set datasource of this subplan, multiple calls may be made to a subplan.
// Set datasource of this subplan, multiple calls may be made to a subplan.
// @subplan subplan to be schedule
// @subplan subplan to be schedule
...
...
include/libs/sync/sync.h
浏览文件 @
21af31f4
...
@@ -34,9 +34,7 @@ typedef enum {
...
@@ -34,9 +34,7 @@ typedef enum {
TAOS_SYNC_STATE_FOLLOWER
=
0
,
TAOS_SYNC_STATE_FOLLOWER
=
0
,
TAOS_SYNC_STATE_CANDIDATE
=
1
,
TAOS_SYNC_STATE_CANDIDATE
=
1
,
TAOS_SYNC_STATE_LEADER
=
2
,
TAOS_SYNC_STATE_LEADER
=
2
,
}
ESyncRole
;
}
ESyncState
;
typedef
ESyncRole
ESyncState
;
typedef
struct
SSyncBuffer
{
typedef
struct
SSyncBuffer
{
void
*
data
;
void
*
data
;
...
...
include/libs/tfs/tfs.h
浏览文件 @
21af31f4
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
#define _TD_TFS_H_
#define _TD_TFS_H_
#include "tdef.h"
#include "tdef.h"
#include "monitor.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
...
@@ -237,6 +238,14 @@ const STfsFile *tfsReaddir(STfsDir *pDir);
...
@@ -237,6 +238,14 @@ const STfsFile *tfsReaddir(STfsDir *pDir);
*/
*/
void
tfsClosedir
(
STfsDir
*
pDir
);
void
tfsClosedir
(
STfsDir
*
pDir
);
/**
* @brief Get disk info of tfs.
*
* @param pTfs The fs object.
* @param pInfo The info object.
*/
int32_t
tfsGetMonitorInfo
(
STfs
*
pTfs
,
SMonDiskInfo
*
pInfo
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
include/os/osDir.h
浏览文件 @
21af31f4
...
@@ -21,7 +21,7 @@ extern "C" {
...
@@ -21,7 +21,7 @@ extern "C" {
#endif
#endif
void
taosRemoveDir
(
const
char
*
dirname
);
void
taosRemoveDir
(
const
char
*
dirname
);
int32_t
taosDirExist
(
char
*
dirname
);
bool
taosDirExist
(
char
*
dirname
);
int32_t
taosMkDir
(
const
char
*
dirname
);
int32_t
taosMkDir
(
const
char
*
dirname
);
void
taosRemoveOldFiles
(
const
char
*
dirname
,
int32_t
keepDays
);
void
taosRemoveOldFiles
(
const
char
*
dirname
,
int32_t
keepDays
);
int32_t
taosExpandDir
(
const
char
*
dirname
,
char
*
outname
,
int32_t
maxlen
);
int32_t
taosExpandDir
(
const
char
*
dirname
,
char
*
outname
,
int32_t
maxlen
);
...
...
include/os/osEnv.h
浏览文件 @
21af31f4
...
@@ -28,11 +28,11 @@ extern char tsCharset[];
...
@@ -28,11 +28,11 @@ extern char tsCharset[];
extern
char
tsLocale
[];
extern
char
tsLocale
[];
extern
int8_t
tsDaylight
;
extern
int8_t
tsDaylight
;
extern
bool
tsEnableCoreFile
;
extern
bool
tsEnableCoreFile
;
extern
int64_t
tsPageSize
;
extern
int64_t
tsPageSize
KB
;
extern
int64_t
tsOpenMax
;
extern
int64_t
tsOpenMax
;
extern
int64_t
tsStreamMax
;
extern
int64_t
tsStreamMax
;
extern
int32_t
tsNumOfCores
;
extern
float
tsNumOfCores
;
extern
int
32_t
tsTotalMemoryM
B
;
extern
int
64_t
tsTotalMemoryK
B
;
extern
char
configDir
[];
extern
char
configDir
[];
extern
char
tsDataDir
[];
extern
char
tsDataDir
[];
...
...
include/os/osFile.h
浏览文件 @
21af31f4
...
@@ -25,8 +25,12 @@ extern "C" {
...
@@ -25,8 +25,12 @@ extern "C" {
#ifndef ALLOW_FORBID_FUNC
#ifndef ALLOW_FORBID_FUNC
#define open OPEN_FUNC_TAOS_FORBID
#define open OPEN_FUNC_TAOS_FORBID
#define fopen FOPEN_FUNC_TAOS_FORBID
#define fopen FOPEN_FUNC_TAOS_FORBID
// #define close CLOSE_FUNC_TAOS_FORBID
#define access ACCESS_FUNC_TAOS_FORBID
// #define fclose FCLOSE_FUNC_TAOS_FORBID
#define stat STAT_FUNC_TAOS_FORBID
#define lstat LSTAT_FUNC_TAOS_FORBID
#define fstat FSTAT_FUNC_TAOS_FORBID
#define close CLOSE_FUNC_TAOS_FORBID
#define fclose FCLOSE_FUNC_TAOS_FORBID
#endif
#endif
#ifndef PATH_MAX
#ifndef PATH_MAX
...
@@ -44,6 +48,12 @@ typedef struct TdFile *TdFilePtr;
...
@@ -44,6 +48,12 @@ typedef struct TdFile *TdFilePtr;
#define TD_FILE_AUTO_DEL 0x0040
#define TD_FILE_AUTO_DEL 0x0040
#define TD_FILE_EXCL 0x0080
#define TD_FILE_EXCL 0x0080
#define TD_FILE_STREAM 0x0100 // Only support taosFprintfFile, taosGetLineFile, taosGetLineFile, taosEOFFile
#define TD_FILE_STREAM 0x0100 // Only support taosFprintfFile, taosGetLineFile, taosGetLineFile, taosEOFFile
TdFilePtr
taosOpenFile
(
const
char
*
path
,
int32_t
tdFileOptions
);
#define TD_FILE_ACCESS_EXIST_OK 0x1
#define TD_FILE_ACCESS_READ_OK 0x2
#define TD_FILE_ACCESS_WRITE_OK 0x4
bool
taosCheckAccessFile
(
const
char
*
pathname
,
int
mode
);
int32_t
taosLockFile
(
TdFilePtr
pFile
);
int32_t
taosLockFile
(
TdFilePtr
pFile
);
int32_t
taosUnLockFile
(
TdFilePtr
pFile
);
int32_t
taosUnLockFile
(
TdFilePtr
pFile
);
...
@@ -51,9 +61,9 @@ int32_t taosUnLockFile(TdFilePtr pFile);
...
@@ -51,9 +61,9 @@ int32_t taosUnLockFile(TdFilePtr pFile);
int32_t
taosUmaskFile
(
int32_t
maskVal
);
int32_t
taosUmaskFile
(
int32_t
maskVal
);
int32_t
taosStatFile
(
const
char
*
path
,
int64_t
*
size
,
int32_t
*
mtime
);
int32_t
taosStatFile
(
const
char
*
path
,
int64_t
*
size
,
int32_t
*
mtime
);
int32_t
taosDevInoFile
(
const
char
*
path
,
int64_t
*
stDev
,
int64_t
*
stIno
);
int32_t
taosFStatFile
(
TdFilePtr
pFile
,
int64_t
*
size
,
int32_t
*
mtime
);
int32_t
taosFStatFile
(
TdFilePtr
pFile
,
int64_t
*
size
,
int32_t
*
mtime
);
bool
taosCheckExistFile
(
const
char
*
pathname
);
TdFilePtr
taosOpenFile
(
const
char
*
path
,
int32_t
tdFileOptions
);
int64_t
taosLSeekFile
(
TdFilePtr
pFile
,
int64_t
offset
,
int32_t
whence
);
int64_t
taosLSeekFile
(
TdFilePtr
pFile
,
int64_t
offset
,
int32_t
whence
);
int32_t
taosFtruncateFile
(
TdFilePtr
pFile
,
int64_t
length
);
int32_t
taosFtruncateFile
(
TdFilePtr
pFile
,
int64_t
length
);
...
@@ -62,7 +72,7 @@ int32_t taosFsyncFile(TdFilePtr pFile);
...
@@ -62,7 +72,7 @@ int32_t taosFsyncFile(TdFilePtr pFile);
int64_t
taosReadFile
(
TdFilePtr
pFile
,
void
*
buf
,
int64_t
count
);
int64_t
taosReadFile
(
TdFilePtr
pFile
,
void
*
buf
,
int64_t
count
);
int64_t
taosPReadFile
(
TdFilePtr
pFile
,
void
*
buf
,
int64_t
count
,
int64_t
offset
);
int64_t
taosPReadFile
(
TdFilePtr
pFile
,
void
*
buf
,
int64_t
count
,
int64_t
offset
);
int64_t
taosWriteFile
(
TdFilePtr
pFile
,
const
void
*
buf
,
int64_t
count
);
int64_t
taosWriteFile
(
TdFilePtr
pFile
,
const
void
*
buf
,
int64_t
count
);
void
taosFprintfFile
(
TdFilePtr
pFile
,
const
char
*
format
,
...);
void
taosFprintfFile
(
TdFilePtr
pFile
,
const
char
*
format
,
...);
int64_t
taosGetLineFile
(
TdFilePtr
pFile
,
char
**
__restrict__
ptrBuf
);
int64_t
taosGetLineFile
(
TdFilePtr
pFile
,
char
**
__restrict__
ptrBuf
);
int32_t
taosEOFFile
(
TdFilePtr
pFile
);
int32_t
taosEOFFile
(
TdFilePtr
pFile
);
...
@@ -71,7 +81,7 @@ int64_t taosCloseFile(TdFilePtr *ppFile);
...
@@ -71,7 +81,7 @@ int64_t taosCloseFile(TdFilePtr *ppFile);
int32_t
taosRenameFile
(
const
char
*
oldName
,
const
char
*
newName
);
int32_t
taosRenameFile
(
const
char
*
oldName
,
const
char
*
newName
);
int64_t
taosCopyFile
(
const
char
*
from
,
const
char
*
to
);
int64_t
taosCopyFile
(
const
char
*
from
,
const
char
*
to
);
void
taosGetTmpfilePath
(
const
char
*
inputTmpDir
,
const
char
*
fileNamePrefix
,
char
*
dstPath
);
void
taosGetTmpfilePath
(
const
char
*
inputTmpDir
,
const
char
*
fileNamePrefix
,
char
*
dstPath
);
int64_t
taosSendFile
(
SocketFd
fdDst
,
TdFilePtr
pFileSrc
,
int64_t
*
offset
,
int64_t
size
);
int64_t
taosSendFile
(
SocketFd
fdDst
,
TdFilePtr
pFileSrc
,
int64_t
*
offset
,
int64_t
size
);
int64_t
taosFSendFile
(
TdFilePtr
pFileOut
,
TdFilePtr
pFileIn
,
int64_t
*
offset
,
int64_t
size
);
int64_t
taosFSendFile
(
TdFilePtr
pFileOut
,
TdFilePtr
pFileIn
,
int64_t
*
offset
,
int64_t
size
);
...
@@ -79,7 +89,7 @@ int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, in
...
@@ -79,7 +89,7 @@ int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, in
void
*
taosMmapReadOnlyFile
(
TdFilePtr
pFile
,
int64_t
length
);
void
*
taosMmapReadOnlyFile
(
TdFilePtr
pFile
,
int64_t
length
);
bool
taosValidFile
(
TdFilePtr
pFile
);
bool
taosValidFile
(
TdFilePtr
pFile
);
int
taosGetErrorFile
(
TdFilePtr
pFile
);
int
32_t
taosGetErrorFile
(
TdFilePtr
pFile
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
include/os/osSysinfo.h
浏览文件 @
21af31f4
...
@@ -34,19 +34,19 @@ typedef struct {
...
@@ -34,19 +34,19 @@ typedef struct {
}
SDiskSpace
;
}
SDiskSpace
;
void
taosGetSystemInfo
();
void
taosGetSystemInfo
();
bool
taosGetEmail
(
char
*
email
,
int32_t
maxLen
);
int32_t
taosGetEmail
(
char
*
email
,
int32_t
maxLen
);
bool
taosGetOsReleaseName
(
char
*
releaseName
,
int32_t
maxLen
);
int32_t
taosGetOsReleaseName
(
char
*
releaseName
,
int32_t
maxLen
);
bool
taosGetCpuInfo
(
char
*
cpuModel
,
int32_t
maxLen
,
int32_
t
*
numOfCores
);
int32_t
taosGetCpuInfo
(
char
*
cpuModel
,
int32_t
maxLen
,
floa
t
*
numOfCores
);
int32_t
taosGetCpuCores
();
int32_t
taosGetCpuCores
(
float
*
numOfCores
);
bool
taosGetCpuUsage
(
float
*
sysCpuUsage
,
float
*
procCpuUsag
e
);
int32_t
taosGetCpuUsage
(
float
*
cpu_system
,
float
*
cpu_engin
e
);
bool
taosGetTotalSysMemoryKB
(
uint64_t
*
kb
);
int32_t
taosGetTotalMemory
(
int64_t
*
totalKB
);
bool
taosGetProcMemory
(
float
*
memoryUsedMB
);
//
int32_t
taosGetProcMemory
(
int64_t
*
usedKB
);
bool
taosGetSysMemory
(
float
*
memoryUsedMB
);
//
int32_t
taosGetSysMemory
(
int64_t
*
usedKB
);
int32_t
taosGetDiskSize
(
char
*
dataDir
,
SDiskSize
*
diskSize
);
int32_t
taosGetDiskSize
(
char
*
dataDir
,
SDiskSize
*
diskSize
);
bool
taosReadProcIO
(
int64_t
*
rchars
,
int64_t
*
wchars
);
int32_t
taosReadProcIO
(
int64_t
*
rchars
,
int64_t
*
wchars
);
bool
taosGetProcIO
(
float
*
readKB
,
float
*
writeKB
);
int32_t
taosGetProcIO
(
float
*
readKB
,
float
*
writeKB
);
bool
taosGetCardInfo
(
int64_t
*
bytes
,
int64_t
*
rbytes
,
int64_t
*
tbytes
);
int32_t
taosGetCardInfo
(
int64_t
*
bytes
,
int64_t
*
rbytes
,
int64_t
*
tbytes
);
bool
taosGetBandSpeed
(
float
*
bandSpeedKb
);
int32_t
taosGetBandSpeed
(
float
*
bandSpeedKb
);
int32_t
taosSystem
(
const
char
*
cmd
);
int32_t
taosSystem
(
const
char
*
cmd
);
void
taosKillSystem
();
void
taosKillSystem
();
...
...
source/client/src/clientImpl.c
浏览文件 @
21af31f4
...
@@ -161,7 +161,7 @@ int32_t parseSql(SRequestObj* pRequest, SQuery** pQuery) {
...
@@ -161,7 +161,7 @@ int32_t parseSql(SRequestObj* pRequest, SQuery** pQuery) {
}
}
code
=
qParseQuerySql
(
&
cxt
,
pQuery
);
code
=
qParseQuerySql
(
&
cxt
,
pQuery
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
!
((
*
pQuery
)
->
isCmd
))
{
if
(
TSDB_CODE_SUCCESS
==
code
&&
((
*
pQuery
)
->
haveResultSet
))
{
setResSchemaInfo
(
&
pRequest
->
body
.
resInfo
,
(
*
pQuery
)
->
pResSchema
,
(
*
pQuery
)
->
numOfResCols
);
setResSchemaInfo
(
&
pRequest
->
body
.
resInfo
,
(
*
pQuery
)
->
pResSchema
,
(
*
pQuery
)
->
numOfResCols
);
}
}
...
@@ -176,6 +176,14 @@ int32_t execDdlQuery(SRequestObj* pRequest, SQuery* pQuery) {
...
@@ -176,6 +176,14 @@ int32_t execDdlQuery(SRequestObj* pRequest, SQuery* pQuery) {
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
STscObj
*
pTscObj
=
pRequest
->
pTscObj
;
SMsgSendInfo
*
pSendMsg
=
buildMsgInfoImpl
(
pRequest
);
SMsgSendInfo
*
pSendMsg
=
buildMsgInfoImpl
(
pRequest
);
if
(
pMsgInfo
->
msgType
==
TDMT_VND_SHOW_TABLES
)
{
SShowReqInfo
*
pShowReqInfo
=
&
pRequest
->
body
.
showInfo
;
if
(
pShowReqInfo
->
pArray
==
NULL
)
{
pShowReqInfo
->
currentIndex
=
0
;
// set the first vnode/ then iterate the next vnode
pShowReqInfo
->
pArray
=
pMsgInfo
->
pExtension
;
}
}
int64_t
transporterId
=
0
;
int64_t
transporterId
=
0
;
asyncSendMsgToServer
(
pTscObj
->
pAppInfo
->
pTransporter
,
&
pMsgInfo
->
epSet
,
&
transporterId
,
pSendMsg
);
asyncSendMsgToServer
(
pTscObj
->
pAppInfo
->
pTransporter
,
&
pMsgInfo
->
epSet
,
&
transporterId
,
pSendMsg
);
...
@@ -183,20 +191,13 @@ int32_t execDdlQuery(SRequestObj* pRequest, SQuery* pQuery) {
...
@@ -183,20 +191,13 @@ int32_t execDdlQuery(SRequestObj* pRequest, SQuery* pQuery) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
getPlan
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
SQueryPlan
**
pDag
,
SArray
*
pNodeList
)
{
int32_t
getPlan
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
SQueryPlan
**
pPlan
,
SArray
*
pNodeList
)
{
// pRequest->type = pQuery->type;
pRequest
->
type
=
pQuery
->
msgType
;
SPlanContext
cxt
=
{
.
queryId
=
pRequest
->
requestId
,
.
pAstRoot
=
pQuery
->
pRoot
};
SPlanContext
cxt
=
{
.
queryId
=
pRequest
->
requestId
,
.
pAstRoot
=
pQuery
->
pRoot
};
int32_t
code
=
qCreateQueryPlan
(
&
cxt
,
p
Dag
);
int32_t
code
=
qCreateQueryPlan
(
&
cxt
,
p
Plan
,
pNodeList
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
return
code
;
return
code
;
}
}
// if (pQuery->type == TSDB_SQL_SELECT) {
// setResSchemaInfo(&pRequest->body.resInfo, pSchema, numOfCols);
// pRequest->type = TDMT_VND_QUERY;
// }
return
code
;
return
code
;
}
}
...
@@ -226,7 +227,7 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList
...
@@ -226,7 +227,7 @@ int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList
return
pRequest
->
code
;
return
pRequest
->
code
;
}
}
if
(
T
SDB_SQL_INSERT
==
pRequest
->
type
||
TSDB_SQL
_CREATE_TABLE
==
pRequest
->
type
)
{
if
(
T
DMT_VND_SUBMIT
==
pRequest
->
type
||
TDMT_VND
_CREATE_TABLE
==
pRequest
->
type
)
{
pRequest
->
body
.
resInfo
.
numOfRows
=
res
.
numOfRows
;
pRequest
->
body
.
resInfo
.
numOfRows
=
res
.
numOfRows
;
if
(
pRequest
->
body
.
queryJob
!=
0
)
{
if
(
pRequest
->
body
.
queryJob
!=
0
)
{
...
@@ -254,7 +255,7 @@ TAOS_RES* taos_query_l(TAOS* taos, const char* sql, int sqlLen) {
...
@@ -254,7 +255,7 @@ TAOS_RES* taos_query_l(TAOS* taos, const char* sql, int sqlLen) {
CHECK_CODE_GOTO
(
buildRequest
(
pTscObj
,
sql
,
sqlLen
,
&
pRequest
),
_return
);
CHECK_CODE_GOTO
(
buildRequest
(
pTscObj
,
sql
,
sqlLen
,
&
pRequest
),
_return
);
CHECK_CODE_GOTO
(
parseSql
(
pRequest
,
&
pQuery
),
_return
);
CHECK_CODE_GOTO
(
parseSql
(
pRequest
,
&
pQuery
),
_return
);
if
(
pQuery
->
isCmd
)
{
if
(
pQuery
->
directRpc
)
{
CHECK_CODE_GOTO
(
execDdlQuery
(
pRequest
,
pQuery
),
_return
);
CHECK_CODE_GOTO
(
execDdlQuery
(
pRequest
,
pQuery
),
_return
);
}
else
{
}
else
{
CHECK_CODE_GOTO
(
getPlan
(
pRequest
,
pQuery
,
&
pRequest
->
body
.
pDag
,
pNodeList
),
_return
);
CHECK_CODE_GOTO
(
getPlan
(
pRequest
,
pQuery
,
&
pRequest
->
body
.
pDag
,
pNodeList
),
_return
);
...
...
source/common/src/tglobal.c
浏览文件 @
21af31f4
...
@@ -279,11 +279,11 @@ static int32_t taosAddSystemCfg(SConfig *pCfg) {
...
@@ -279,11 +279,11 @@ static int32_t taosAddSystemCfg(SConfig *pCfg) {
if
(
cfgAddLocale
(
pCfg
,
"locale"
,
tsLocale
)
!=
0
)
return
-
1
;
if
(
cfgAddLocale
(
pCfg
,
"locale"
,
tsLocale
)
!=
0
)
return
-
1
;
if
(
cfgAddCharset
(
pCfg
,
"charset"
,
tsCharset
)
!=
0
)
return
-
1
;
if
(
cfgAddCharset
(
pCfg
,
"charset"
,
tsCharset
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"enableCoreFile"
,
1
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"enableCoreFile"
,
1
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"numOfCores"
,
tsNumOfCores
,
1
,
100000
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddFloat
(
pCfg
,
"numOfCores"
,
tsNumOfCores
,
0
,
100000
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"pageSize(KB)"
,
tsPageSize
,
0
,
INT64_MAX
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt64
(
pCfg
,
"openMax"
,
tsOpenMax
,
0
,
INT64_MAX
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt64
(
pCfg
,
"openMax"
,
tsOpenMax
,
0
,
INT64_MAX
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt64
(
pCfg
,
"streamMax"
,
tsStreamMax
,
0
,
INT64_MAX
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt64
(
pCfg
,
"streamMax"
,
tsStreamMax
,
0
,
INT64_MAX
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"totalMemory(MB)"
,
tsTotalMemoryMB
,
0
,
INT32_MAX
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt32
(
pCfg
,
"pageSize(KB)"
,
tsPageSizeKB
,
0
,
INT64_MAX
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddInt64
(
pCfg
,
"totalMemory(KB)"
,
tsTotalMemoryKB
,
0
,
INT64_MAX
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"os sysname"
,
info
.
sysname
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"os sysname"
,
info
.
sysname
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"os nodename"
,
info
.
nodename
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"os nodename"
,
info
.
nodename
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"os release"
,
info
.
release
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddString
(
pCfg
,
"os release"
,
info
.
release
,
1
)
!=
0
)
return
-
1
;
...
@@ -404,10 +404,6 @@ static void taosSetSystemCfg(SConfig *pCfg) {
...
@@ -404,10 +404,6 @@ static void taosSetSystemCfg(SConfig *pCfg) {
const
char
*
charset
=
cfgGetItem
(
pCfg
,
"charset"
)
->
str
;
const
char
*
charset
=
cfgGetItem
(
pCfg
,
"charset"
)
->
str
;
taosSetSystemLocale
(
locale
,
charset
);
taosSetSystemLocale
(
locale
,
charset
);
if
(
tsNumOfCores
<=
1
)
{
tsNumOfCores
=
2
;
}
bool
enableCore
=
cfgGetItem
(
pCfg
,
"enableCoreFile"
)
->
bval
;
bool
enableCore
=
cfgGetItem
(
pCfg
,
"enableCoreFile"
)
->
bval
;
taosSetConsoleEcho
(
enableCore
);
taosSetConsoleEcho
(
enableCore
);
...
...
source/common/test/commonTests.cpp
浏览文件 @
21af31f4
#include "tcommon.h"
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include <tep.h>
#include <iostream>
#include <iostream>
#pragma GCC diagnostic push
#pragma GCC diagnostic push
...
@@ -10,6 +8,8 @@
...
@@ -10,6 +8,8 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "os.h"
#include "os.h"
#include "tep.h"
#include "tcommon.h"
#include "taos.h"
#include "taos.h"
#include "tvariant.h"
#include "tvariant.h"
#include "tdef.h"
#include "tdef.h"
...
...
source/common/test/tmsgTest.cpp
浏览文件 @
21af31f4
#include <iostream>
#include <iostream>
#include
"gtest/gtest.h"
#include
<gtest/gtest.h>
#include "tmsg.h"
#include "tmsg.h"
...
...
source/dnode/mgmt/impl/inc/dndEnv.h
浏览文件 @
21af31f4
...
@@ -31,7 +31,7 @@ typedef struct {
...
@@ -31,7 +31,7 @@ typedef struct {
SDnode
*
pDnode
;
SDnode
*
pDnode
;
STaosQueue
*
queue
;
STaosQueue
*
queue
;
union
{
union
{
SQWorkerPool
pool
;
SQWorkerPool
pool
;
SWWorkerPool
mpool
;
SWWorkerPool
mpool
;
};
};
}
SDnodeWorker
;
}
SDnodeWorker
;
...
@@ -137,6 +137,8 @@ typedef struct SDnode {
...
@@ -137,6 +137,8 @@ typedef struct SDnode {
SStartupReq
startup
;
SStartupReq
startup
;
}
SDnode
;
}
SDnode
;
int32_t
dndGetMonitorDiskInfo
(
SDnode
*
pDnode
,
SMonDiskInfo
*
pInfo
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/dnode/mgmt/impl/inc/dndMnode.h
浏览文件 @
21af31f4
...
@@ -34,6 +34,7 @@ int32_t dndProcessDropMnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg);
...
@@ -34,6 +34,7 @@ int32_t dndProcessDropMnodeReq(SDnode *pDnode, SRpcMsg *pRpcMsg);
int32_t
dndGetMnodeMonitorInfo
(
SDnode
*
pDnode
,
SMonClusterInfo
*
pClusterInfo
,
SMonVgroupInfo
*
pVgroupInfo
,
int32_t
dndGetMnodeMonitorInfo
(
SDnode
*
pDnode
,
SMonClusterInfo
*
pClusterInfo
,
SMonVgroupInfo
*
pVgroupInfo
,
SMonGrantInfo
*
pGrantInfo
);
SMonGrantInfo
*
pGrantInfo
);
int8_t
dndIsMnode
(
SDnode
*
pDnode
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/dnode/mgmt/impl/src/dndEnv.c
浏览文件 @
21af31f4
...
@@ -323,3 +323,12 @@ void dndCleanup() {
...
@@ -323,3 +323,12 @@ void dndCleanup() {
taosStopCacheRefreshWorker
();
taosStopCacheRefreshWorker
();
dInfo
(
"dnode env is cleaned up"
);
dInfo
(
"dnode env is cleaned up"
);
}
}
int32_t
dndGetMonitorDiskInfo
(
SDnode
*
pDnode
,
SMonDiskInfo
*
pInfo
)
{
tstrncpy
(
pInfo
->
logdir
.
name
,
tsLogDir
,
sizeof
(
pInfo
->
logdir
.
name
));
pInfo
->
logdir
.
size
=
tsLogSpace
.
size
;
tstrncpy
(
pInfo
->
tempdir
.
name
,
tsTempDir
,
sizeof
(
pInfo
->
tempdir
.
name
));
pInfo
->
tempdir
.
size
=
tsTempSpace
.
size
;
return
tfsGetMonitorInfo
(
pDnode
->
pTfs
,
pInfo
);
}
\ No newline at end of file
source/dnode/mgmt/impl/src/dndMgmt.c
浏览文件 @
21af31f4
...
@@ -474,20 +474,48 @@ void dndProcessStartupReq(SDnode *pDnode, SRpcMsg *pReq) {
...
@@ -474,20 +474,48 @@ void dndProcessStartupReq(SDnode *pDnode, SRpcMsg *pReq) {
rpcSendResponse
(
&
rpcRsp
);
rpcSendResponse
(
&
rpcRsp
);
}
}
void
dndGet
BasicInfo
(
SDnode
*
pDnode
,
SMonBasicInfo
*
pInfo
)
{
static
void
dndGetMonitor
BasicInfo
(
SDnode
*
pDnode
,
SMonBasicInfo
*
pInfo
)
{
pInfo
->
dnode_id
=
dndGetDnodeId
(
pDnode
);
pInfo
->
dnode_id
=
dndGetDnodeId
(
pDnode
);
tstrncpy
(
pInfo
->
dnode_ep
,
tsLocalEp
,
TSDB_EP_LEN
);
tstrncpy
(
pInfo
->
dnode_ep
,
tsLocalEp
,
TSDB_EP_LEN
);
}
}
static
void
dndGetMonitorDnodeInfo
(
SDnode
*
pDnode
,
SMonDnodeInfo
*
pInfo
)
{
pInfo
->
uptime
=
(
taosGetTimestampMs
()
-
pDnode
->
dmgmt
.
rebootTime
)
/
(
86400000
.
0
f
);
taosGetCpuUsage
(
&
pInfo
->
cpu_engine
,
&
pInfo
->
cpu_system
);
pInfo
->
cpu_cores
=
tsNumOfCores
;
taosGetProcMemory
(
&
pInfo
->
mem_engine
);
taosGetSysMemory
(
&
pInfo
->
mem_system
);
pInfo
->
mem_total
=
tsTotalMemoryKB
;
pInfo
->
disk_engine
=
0
;
pInfo
->
disk_used
=
tsDataSpace
.
size
.
used
/
(
1024
*
1024
*
1024
.
0
);
pInfo
->
disk_total
=
tsDataSpace
.
size
.
avail
/
(
1024
*
1024
*
1024
.
0
);
taosGetCardInfo
(
NULL
,
&
pInfo
->
net_in
,
&
pInfo
->
net_out
);
taosGetProcIO
(
&
pInfo
->
io_read
,
&
pInfo
->
io_write
);
pInfo
->
io_read_disk
=
0
;
pInfo
->
io_write_disk
=
0
;
pInfo
->
req_select
=
0
;
pInfo
->
req_select_rate
=
0
;
pInfo
->
req_insert
=
0
;
pInfo
->
req_insert_success
=
0
;
pInfo
->
req_insert_rate
=
0
;
pInfo
->
req_insert_batch
=
0
;
pInfo
->
req_insert_batch_success
=
0
;
pInfo
->
req_insert_batch_rate
=
0
;
pInfo
->
errors
=
0
;
pInfo
->
vnodes_num
=
0
;
pInfo
->
masters
=
0
;
pInfo
->
has_mnode
=
dndIsMnode
(
pDnode
);
}
static
void
dndSendMonitorReport
(
SDnode
*
pDnode
)
{
static
void
dndSendMonitorReport
(
SDnode
*
pDnode
)
{
if
(
!
tsEnableMonitor
||
tsMonitorFqdn
[
0
]
==
0
)
return
;
if
(
!
tsEnableMonitor
||
tsMonitorFqdn
[
0
]
==
0
||
tsMonitorPort
==
0
)
return
;
dTrace
(
"pDnode:%p, send monitor report to %s:%u"
,
pDnode
,
tsMonitorFqdn
,
tsMonitorPort
);
SMonInfo
*
pMonitor
=
monCreateMonitorInfo
();
SMonInfo
*
pMonitor
=
monCreateMonitorInfo
();
if
(
pMonitor
==
NULL
)
return
;
if
(
pMonitor
==
NULL
)
return
;
dTrace
(
"pDnode:%p, send monitor report to %s:%u"
,
pDnode
,
tsMonitorFqdn
,
tsMonitorPort
);
SMonBasicInfo
basicInfo
=
{
0
};
SMonBasicInfo
basicInfo
=
{
0
};
dndGetBasicInfo
(
pDnode
,
&
basicInfo
);
dndGet
Monitor
BasicInfo
(
pDnode
,
&
basicInfo
);
monSetBasicInfo
(
pMonitor
,
&
basicInfo
);
monSetBasicInfo
(
pMonitor
,
&
basicInfo
);
SMonClusterInfo
clusterInfo
=
{
0
};
SMonClusterInfo
clusterInfo
=
{
0
};
...
@@ -499,6 +527,20 @@ static void dndSendMonitorReport(SDnode *pDnode) {
...
@@ -499,6 +527,20 @@ static void dndSendMonitorReport(SDnode *pDnode) {
monSetGrantInfo
(
pMonitor
,
&
grantInfo
);
monSetGrantInfo
(
pMonitor
,
&
grantInfo
);
}
}
SMonDnodeInfo
dnodeInfo
=
{
0
};
dndGetMonitorDnodeInfo
(
pDnode
,
&
dnodeInfo
);
monSetDnodeInfo
(
pMonitor
,
&
dnodeInfo
);
SMonDiskInfo
diskInfo
=
{
0
};
if
(
dndGetMonitorDiskInfo
(
pDnode
,
&
diskInfo
)
==
0
)
{
monSetDiskInfo
(
pMonitor
,
&
diskInfo
);
}
taosArrayDestroy
(
clusterInfo
.
dnodes
);
taosArrayDestroy
(
clusterInfo
.
mnodes
);
taosArrayDestroy
(
vgroupInfo
.
vgroups
);
taosArrayDestroy
(
diskInfo
.
datadirs
);
monSendReport
(
pMonitor
);
monSendReport
(
pMonitor
);
monCleanupMonitorInfo
(
pMonitor
);
monCleanupMonitorInfo
(
pMonitor
);
}
}
...
...
source/dnode/mgmt/impl/src/dndMnode.c
浏览文件 @
21af31f4
...
@@ -639,4 +639,11 @@ int32_t dndGetMnodeMonitorInfo(SDnode *pDnode, SMonClusterInfo *pClusterInfo, SM
...
@@ -639,4 +639,11 @@ int32_t dndGetMnodeMonitorInfo(SDnode *pDnode, SMonClusterInfo *pClusterInfo, SM
int32_t
code
=
mndGetMonitorInfo
(
pMnode
,
pClusterInfo
,
pVgroupInfo
,
pGrantInfo
);
int32_t
code
=
mndGetMonitorInfo
(
pMnode
,
pClusterInfo
,
pVgroupInfo
,
pGrantInfo
);
dndReleaseMnode
(
pDnode
,
pMnode
);
dndReleaseMnode
(
pDnode
,
pMnode
);
return
code
;
return
code
;
}
int8_t
dndIsMnode
(
SDnode
*
pDnode
)
{
SMnode
*
pMnode
=
dndAcquireMnode
(
pDnode
);
if
(
pMnode
==
NULL
)
return
0
;
dndReleaseMnode
(
pDnode
,
pMnode
);
return
1
;
}
}
\ No newline at end of file
source/dnode/mnode/impl/src/mndTelem.c
浏览文件 @
21af31f4
...
@@ -52,23 +52,20 @@ static char* mndBuildTelemetryReport(SMnode* pMnode) {
...
@@ -52,23 +52,20 @@ static char* mndBuildTelemetryReport(SMnode* pMnode) {
tjsonAddStringToObject
(
pJson
,
"instanceId"
,
clusterName
);
tjsonAddStringToObject
(
pJson
,
"instanceId"
,
clusterName
);
tjsonAddDoubleToObject
(
pJson
,
"reportVersion"
,
1
);
tjsonAddDoubleToObject
(
pJson
,
"reportVersion"
,
1
);
if
(
taosGetOsReleaseName
(
tmp
,
sizeof
(
tmp
)))
{
if
(
taosGetOsReleaseName
(
tmp
,
sizeof
(
tmp
))
==
0
)
{
tjsonAddStringToObject
(
pJson
,
"os"
,
tmp
);
tjsonAddStringToObject
(
pJson
,
"os"
,
tmp
);
}
}
int32_
t
numOfCores
=
0
;
floa
t
numOfCores
=
0
;
if
(
taosGetCpuInfo
(
tmp
,
sizeof
(
tmp
),
&
numOfCores
))
{
if
(
taosGetCpuInfo
(
tmp
,
sizeof
(
tmp
),
&
numOfCores
)
==
0
)
{
tjsonAddStringToObject
(
pJson
,
"cpuModel"
,
tmp
);
tjsonAddStringToObject
(
pJson
,
"cpuModel"
,
tmp
);
tjsonAddDoubleToObject
(
pJson
,
"numOfCpu"
,
numOfCores
);
tjsonAddDoubleToObject
(
pJson
,
"numOfCpu"
,
numOfCores
);
}
else
{
}
else
{
tjsonAddDoubleToObject
(
pJson
,
"numOfCpu"
,
t
aosGetCpuCores
()
);
tjsonAddDoubleToObject
(
pJson
,
"numOfCpu"
,
t
sNumOfCores
);
}
}
uint64_t
memoryKB
=
0
;
snprintf
(
tmp
,
sizeof
(
tmp
),
"%"
PRId64
" kB"
,
tsTotalMemoryKB
);
if
(
taosGetTotalSysMemoryKB
(
&
memoryKB
))
{
tjsonAddStringToObject
(
pJson
,
"memory"
,
tmp
);
snprintf
(
tmp
,
sizeof
(
tmp
),
"%"
PRIu64
" kB"
,
memoryKB
);
tjsonAddStringToObject
(
pJson
,
"memory"
,
tmp
);
}
tjsonAddStringToObject
(
pJson
,
"version"
,
version
);
tjsonAddStringToObject
(
pJson
,
"version"
,
version
);
tjsonAddStringToObject
(
pJson
,
"buildInfo"
,
buildinfo
);
tjsonAddStringToObject
(
pJson
,
"buildInfo"
,
buildinfo
);
...
...
source/dnode/vnode/src/tq/tqMetaStore.c
浏览文件 @
21af31f4
...
@@ -90,7 +90,7 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F
...
@@ -90,7 +90,7 @@ STqMetaStore* tqStoreOpen(STQ* pTq, const char* path, FTqSerialize serializer, F
char
name
[
pathLen
+
10
];
char
name
[
pathLen
+
10
];
strcpy
(
name
,
path
);
strcpy
(
name
,
path
);
if
(
taosDirExist
(
name
)
!=
0
&&
taosMkDir
(
name
)
!=
0
)
{
if
(
!
taosDirExist
(
name
)
&&
taosMkDir
(
name
)
!=
0
)
{
terrno
=
TSDB_CODE_TQ_FAILED_TO_CREATE_DIR
;
terrno
=
TSDB_CODE_TQ_FAILED_TO_CREATE_DIR
;
tqError
(
"failed to create dir:%s since %s "
,
name
,
terrstr
());
tqError
(
"failed to create dir:%s since %s "
,
name
,
terrstr
());
}
}
...
...
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
21af31f4
...
@@ -580,7 +580,7 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
...
@@ -580,7 +580,7 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
SDFile
*
pRSmadF
=
TSDB_READ_SMAD_FILE
(
&
(
pCommith
->
readh
));
SDFile
*
pRSmadF
=
TSDB_READ_SMAD_FILE
(
&
(
pCommith
->
readh
));
SDFile
*
pWSmadF
=
TSDB_COMMIT_SMAD_FILE
(
pCommith
);
SDFile
*
pWSmadF
=
TSDB_COMMIT_SMAD_FILE
(
pCommith
);
if
(
access
(
TSDB_FILE_FULL_NAME
(
pRSmadF
),
F_OK
)
!=
0
)
{
if
(
!
taosCheckExistFile
(
TSDB_FILE_FULL_NAME
(
pRSmadF
))
)
{
tsdbDebug
(
"vgId:%d create data file %s as not exist"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pRSmadF
));
tsdbDebug
(
"vgId:%d create data file %s as not exist"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pRSmadF
));
tsdbInitDFile
(
pRepo
,
pWSmadF
,
did
,
fid
,
FS_TXN_VERSION
(
REPO_FS
(
pRepo
)),
TSDB_FILE_SMAD
);
tsdbInitDFile
(
pRepo
,
pWSmadF
,
did
,
fid
,
FS_TXN_VERSION
(
REPO_FS
(
pRepo
)),
TSDB_FILE_SMAD
);
...
@@ -614,7 +614,7 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
...
@@ -614,7 +614,7 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
SDFile
*
pRSmalF
=
TSDB_READ_SMAL_FILE
(
&
(
pCommith
->
readh
));
SDFile
*
pRSmalF
=
TSDB_READ_SMAL_FILE
(
&
(
pCommith
->
readh
));
SDFile
*
pWSmalF
=
TSDB_COMMIT_SMAL_FILE
(
pCommith
);
SDFile
*
pWSmalF
=
TSDB_COMMIT_SMAL_FILE
(
pCommith
);
if
((
pCommith
->
isLFileSame
)
&&
access
(
TSDB_FILE_FULL_NAME
(
pRSmalF
),
F_OK
)
==
0
)
{
if
((
pCommith
->
isLFileSame
)
&&
taosCheckExistFile
(
TSDB_FILE_FULL_NAME
(
pRSmalF
))
)
{
tsdbInitDFileEx
(
pWSmalF
,
pRSmalF
);
tsdbInitDFileEx
(
pWSmalF
,
pRSmalF
);
if
(
tsdbOpenDFile
(
pWSmalF
,
O_RDWR
)
<
0
)
{
if
(
tsdbOpenDFile
(
pWSmalF
,
O_RDWR
)
<
0
)
{
tsdbError
(
"vgId:%d failed to open file %s to commit since %s"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pWSmalF
),
tsdbError
(
"vgId:%d failed to open file %s to commit since %s"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pWSmalF
),
...
...
source/dnode/vnode/src/tsdb/tsdbFS.c
浏览文件 @
21af31f4
...
@@ -314,7 +314,7 @@ int tsdbOpenFS(STsdb *pRepo) {
...
@@ -314,7 +314,7 @@ int tsdbOpenFS(STsdb *pRepo) {
tsdbGetTxnFname
(
pRepo
,
TSDB_TXN_CURR_FILE
,
current
);
tsdbGetTxnFname
(
pRepo
,
TSDB_TXN_CURR_FILE
,
current
);
tsdbGetRtnSnap
(
pRepo
,
&
pRepo
->
rtn
);
tsdbGetRtnSnap
(
pRepo
,
&
pRepo
->
rtn
);
if
(
access
(
current
,
F_OK
)
==
0
)
{
if
(
taosCheckExistFile
(
current
)
)
{
if
(
tsdbOpenFSFromCurrent
(
pRepo
)
<
0
)
{
if
(
tsdbOpenFSFromCurrent
(
pRepo
)
<
0
)
{
tsdbError
(
"vgId:%d failed to open FS since %s"
,
REPO_ID
(
pRepo
),
tstrerror
(
terrno
));
tsdbError
(
"vgId:%d failed to open FS since %s"
,
REPO_ID
(
pRepo
),
tstrerror
(
terrno
));
return
-
1
;
return
-
1
;
...
...
source/dnode/vnode/src/tsdb/tsdbFile.c
浏览文件 @
21af31f4
...
@@ -443,25 +443,24 @@ int tsdbLoadDFileHeader(SDFile *pDFile, SDFInfo *pInfo) {
...
@@ -443,25 +443,24 @@ int tsdbLoadDFileHeader(SDFile *pDFile, SDFInfo *pInfo) {
}
}
static
int
tsdbScanAndTryFixDFile
(
STsdb
*
pRepo
,
SDFile
*
pDFile
)
{
static
int
tsdbScanAndTryFixDFile
(
STsdb
*
pRepo
,
SDFile
*
pDFile
)
{
struct
stat
dfstat
;
SDFile
df
;
SDFile
df
;
tsdbInitDFileEx
(
&
df
,
pDFile
);
tsdbInitDFileEx
(
&
df
,
pDFile
);
if
(
access
(
TSDB_FILE_FULL_NAME
(
pDFile
),
F_OK
)
!=
0
)
{
if
(
!
taosCheckExistFile
(
TSDB_FILE_FULL_NAME
(
pDFile
))
)
{
tsdbError
(
"vgId:%d data file %s not exit, report to upper layer to fix it"
,
REPO_ID
(
pRepo
),
tsdbError
(
"vgId:%d data file %s not exit, report to upper layer to fix it"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pDFile
));
TSDB_FILE_FULL_NAME
(
pDFile
));
// pRepo->state |= TSDB_STATE_BAD_DATA;
// pRepo->state |= TSDB_STATE_BAD_DATA;
TSDB_FILE_SET_STATE
(
pDFile
,
TSDB_FILE_STATE_BAD
);
TSDB_FILE_SET_STATE
(
pDFile
,
TSDB_FILE_STATE_BAD
);
return
0
;
return
0
;
}
}
int64_t
file_size
=
0
;
if
(
stat
(
TSDB_FILE_FULL_NAME
(
&
df
),
&
dfstat
)
<
0
)
{
if
(
taosStatFile
(
TSDB_FILE_FULL_NAME
(
&
df
),
&
file_size
,
NULL
)
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
return
-
1
;
return
-
1
;
}
}
if
(
pDFile
->
info
.
size
<
dfstat
.
st
_size
)
{
if
(
pDFile
->
info
.
size
<
file
_size
)
{
// if (tsdbOpenDFile(&df, O_WRONLY) < 0) {
// if (tsdbOpenDFile(&df, O_WRONLY) < 0) {
if
(
tsdbOpenDFile
(
&
df
,
TD_FILE_WRITE
)
<
0
)
{
if
(
tsdbOpenDFile
(
&
df
,
TD_FILE_WRITE
)
<
0
)
{
return
-
1
;
return
-
1
;
...
@@ -480,10 +479,10 @@ static int tsdbScanAndTryFixDFile(STsdb *pRepo, SDFile *pDFile) {
...
@@ -480,10 +479,10 @@ static int tsdbScanAndTryFixDFile(STsdb *pRepo, SDFile *pDFile) {
tsdbCloseDFile
(
&
df
);
tsdbCloseDFile
(
&
df
);
tsdbInfo
(
"vgId:%d file %s is truncated from %"
PRId64
" to %"
PRId64
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pDFile
),
tsdbInfo
(
"vgId:%d file %s is truncated from %"
PRId64
" to %"
PRId64
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pDFile
),
dfstat
.
st
_size
,
pDFile
->
info
.
size
);
file
_size
,
pDFile
->
info
.
size
);
}
else
if
(
pDFile
->
info
.
size
>
dfstat
.
st
_size
)
{
}
else
if
(
pDFile
->
info
.
size
>
file
_size
)
{
tsdbError
(
"vgId:%d data file %s has wrong size %"
PRId64
" expected %"
PRId64
", report to upper layer to fix it"
,
tsdbError
(
"vgId:%d data file %s has wrong size %"
PRId64
" expected %"
PRId64
", report to upper layer to fix it"
,
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pDFile
),
dfstat
.
st
_size
,
pDFile
->
info
.
size
);
REPO_ID
(
pRepo
),
TSDB_FILE_FULL_NAME
(
pDFile
),
file
_size
,
pDFile
->
info
.
size
);
// pRepo->state |= TSDB_STATE_BAD_DATA;
// pRepo->state |= TSDB_STATE_BAD_DATA;
TSDB_FILE_SET_STATE
(
pDFile
,
TSDB_FILE_STATE_BAD
);
TSDB_FILE_SET_STATE
(
pDFile
,
TSDB_FILE_STATE_BAD
);
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
terrno
=
TSDB_CODE_TDB_FILE_CORRUPTED
;
...
...
source/libs/CMakeLists.txt
浏览文件 @
21af31f4
add_definitions
(
"-D ALLOW_FORBID_FUNC"
)
add_subdirectory
(
transport
)
add_subdirectory
(
transport
)
add_subdirectory
(
sync
)
add_subdirectory
(
sync
)
add_subdirectory
(
tdb
)
add_subdirectory
(
tdb
)
...
...
source/libs/catalog/test/catalogTests.cpp
浏览文件 @
21af31f4
...
@@ -14,9 +14,7 @@
...
@@ -14,9 +14,7 @@
*/
*/
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include <tglobal.h>
#include <iostream>
#include <iostream>
#include "os.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wwrite-strings"
#pragma GCC diagnostic ignored "-Wwrite-strings"
...
@@ -24,8 +22,10 @@
...
@@ -24,8 +22,10 @@
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wformat"
#pragma GCC diagnostic ignored "-Wformat"
#include <addr_any.h>
#include "addr_any.h"
#include "os.h"
#include "tglobal.h"
#include "catalog.h"
#include "catalog.h"
#include "stub.h"
#include "stub.h"
#include "taos.h"
#include "taos.h"
...
...
source/libs/executor/src/dataDispatcher.c
浏览文件 @
21af31f4
...
@@ -39,7 +39,7 @@ typedef struct SDataCacheEntry {
...
@@ -39,7 +39,7 @@ typedef struct SDataCacheEntry {
typedef
struct
SDataDispatchHandle
{
typedef
struct
SDataDispatchHandle
{
SDataSinkHandle
sink
;
SDataSinkHandle
sink
;
SDataSinkManager
*
pManager
;
SDataSinkManager
*
pManager
;
SDataBlockDescNode
s
chema
;
SDataBlockDescNode
*
pS
chema
;
STaosQueue
*
pDataBlocks
;
STaosQueue
*
pDataBlocks
;
SDataDispatchBuf
nextOutput
;
SDataDispatchBuf
nextOutput
;
int32_t
status
;
int32_t
status
;
...
@@ -109,14 +109,14 @@ static void copyData(const SInputData* pInput, const SDataBlockDescNode* pSchema
...
@@ -109,14 +109,14 @@ static void copyData(const SInputData* pInput, const SDataBlockDescNode* pSchema
// data format: SDataCacheEntry | col1_data col2_data ... | numOfTables | STableIdInfo STableIdInfo ...
// data format: SDataCacheEntry | col1_data col2_data ... | numOfTables | STableIdInfo STableIdInfo ...
static
void
toDataCacheEntry
(
const
SDataDispatchHandle
*
pHandle
,
const
SInputData
*
pInput
,
SDataDispatchBuf
*
pBuf
)
{
static
void
toDataCacheEntry
(
const
SDataDispatchHandle
*
pHandle
,
const
SInputData
*
pInput
,
SDataDispatchBuf
*
pBuf
)
{
SDataCacheEntry
*
pEntry
=
(
SDataCacheEntry
*
)
pBuf
->
pData
;
SDataCacheEntry
*
pEntry
=
(
SDataCacheEntry
*
)
pBuf
->
pData
;
pEntry
->
compressed
=
(
int8_t
)
needCompress
(
pInput
->
pData
,
&
(
pHandle
->
schema
)
);
pEntry
->
compressed
=
(
int8_t
)
needCompress
(
pInput
->
pData
,
pHandle
->
pSchema
);
pEntry
->
numOfRows
=
pInput
->
pData
->
info
.
rows
;
pEntry
->
numOfRows
=
pInput
->
pData
->
info
.
rows
;
pEntry
->
dataLen
=
0
;
pEntry
->
dataLen
=
0
;
pBuf
->
useSize
=
DATA_META_LENGTH
(
pInput
->
pTableRetrieveTsMap
);
pBuf
->
useSize
=
DATA_META_LENGTH
(
pInput
->
pTableRetrieveTsMap
);
copyData
(
pInput
,
&
pHandle
->
s
chema
,
pEntry
->
data
,
pEntry
->
compressed
,
&
pEntry
->
dataLen
);
copyData
(
pInput
,
pHandle
->
pS
chema
,
pEntry
->
data
,
pEntry
->
compressed
,
&
pEntry
->
dataLen
);
if
(
0
==
pEntry
->
compressed
)
{
if
(
0
==
pEntry
->
compressed
)
{
pEntry
->
dataLen
=
pHandle
->
schema
.
resultRowSize
*
pInput
->
pData
->
info
.
rows
;
pEntry
->
dataLen
=
pHandle
->
pSchema
->
resultRowSize
*
pInput
->
pData
->
info
.
rows
;
}
}
pBuf
->
useSize
+=
pEntry
->
dataLen
;
pBuf
->
useSize
+=
pEntry
->
dataLen
;
// todo completed
// todo completed
...
@@ -130,7 +130,7 @@ static bool allocBuf(SDataDispatchHandle* pDispatcher, const SInputData* pInput,
...
@@ -130,7 +130,7 @@ static bool allocBuf(SDataDispatchHandle* pDispatcher, const SInputData* pInput,
return
false
;
return
false
;
}
}
pBuf
->
allocSize
=
DATA_META_LENGTH
(
pInput
->
pTableRetrieveTsMap
)
+
pDispatcher
->
schema
.
resultRowSize
*
pInput
->
pData
->
info
.
rows
;
pBuf
->
allocSize
=
DATA_META_LENGTH
(
pInput
->
pTableRetrieveTsMap
)
+
pDispatcher
->
pSchema
->
resultRowSize
*
pInput
->
pData
->
info
.
rows
;
pBuf
->
pData
=
malloc
(
pBuf
->
allocSize
);
pBuf
->
pData
=
malloc
(
pBuf
->
allocSize
);
if
(
pBuf
->
pData
==
NULL
)
{
if
(
pBuf
->
pData
==
NULL
)
{
qError
(
"SinkNode failed to malloc memory, size:%d, code:%d"
,
pBuf
->
allocSize
,
TAOS_SYSTEM_ERROR
(
errno
));
qError
(
"SinkNode failed to malloc memory, size:%d, code:%d"
,
pBuf
->
allocSize
,
TAOS_SYSTEM_ERROR
(
errno
));
...
@@ -196,7 +196,7 @@ static int32_t getDataBlock(SDataSinkHandle* pHandle, SOutputData* pOutput) {
...
@@ -196,7 +196,7 @@ static int32_t getDataBlock(SDataSinkHandle* pHandle, SOutputData* pOutput) {
if
(
NULL
==
pDispatcher
->
nextOutput
.
pData
)
{
if
(
NULL
==
pDispatcher
->
nextOutput
.
pData
)
{
assert
(
pDispatcher
->
queryEnd
);
assert
(
pDispatcher
->
queryEnd
);
pOutput
->
useconds
=
pDispatcher
->
useconds
;
pOutput
->
useconds
=
pDispatcher
->
useconds
;
pOutput
->
precision
=
pDispatcher
->
schema
.
precision
;
pOutput
->
precision
=
pDispatcher
->
pSchema
->
precision
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
SDataCacheEntry
*
pEntry
=
(
SDataCacheEntry
*
)(
pDispatcher
->
nextOutput
.
pData
);
SDataCacheEntry
*
pEntry
=
(
SDataCacheEntry
*
)(
pDispatcher
->
nextOutput
.
pData
);
...
@@ -208,7 +208,7 @@ static int32_t getDataBlock(SDataSinkHandle* pHandle, SOutputData* pOutput) {
...
@@ -208,7 +208,7 @@ static int32_t getDataBlock(SDataSinkHandle* pHandle, SOutputData* pOutput) {
pthread_mutex_lock
(
&
pDispatcher
->
mutex
);
pthread_mutex_lock
(
&
pDispatcher
->
mutex
);
pOutput
->
queryEnd
=
pDispatcher
->
queryEnd
;
pOutput
->
queryEnd
=
pDispatcher
->
queryEnd
;
pOutput
->
useconds
=
pDispatcher
->
useconds
;
pOutput
->
useconds
=
pDispatcher
->
useconds
;
pOutput
->
precision
=
pDispatcher
->
schema
.
precision
;
pOutput
->
precision
=
pDispatcher
->
pSchema
->
precision
;
pthread_mutex_unlock
(
&
pDispatcher
->
mutex
);
pthread_mutex_unlock
(
&
pDispatcher
->
mutex
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -238,7 +238,7 @@ int32_t createDataDispatcher(SDataSinkManager* pManager, const SDataSinkNode* pD
...
@@ -238,7 +238,7 @@ int32_t createDataDispatcher(SDataSinkManager* pManager, const SDataSinkNode* pD
dispatcher
->
sink
.
fGetData
=
getDataBlock
;
dispatcher
->
sink
.
fGetData
=
getDataBlock
;
dispatcher
->
sink
.
fDestroy
=
destroyDataSinker
;
dispatcher
->
sink
.
fDestroy
=
destroyDataSinker
;
dispatcher
->
pManager
=
pManager
;
dispatcher
->
pManager
=
pManager
;
dispatcher
->
schema
=
pDataSink
->
i
nputDataBlockDesc
;
dispatcher
->
pSchema
=
pDataSink
->
pI
nputDataBlockDesc
;
dispatcher
->
status
=
DS_BUF_EMPTY
;
dispatcher
->
status
=
DS_BUF_EMPTY
;
dispatcher
->
queryEnd
=
false
;
dispatcher
->
queryEnd
=
false
;
dispatcher
->
pDataBlocks
=
taosOpenQueue
();
dispatcher
->
pDataBlocks
=
taosOpenQueue
();
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
21af31f4
...
@@ -315,8 +315,6 @@ SSDataBlock* createOutputBuf(SExprInfo* pExpr, int32_t numOfOutput, int32_t numO
...
@@ -315,8 +315,6 @@ SSDataBlock* createOutputBuf(SExprInfo* pExpr, int32_t numOfOutput, int32_t numO
}
}
SSDataBlock
*
createOutputBuf_rv
(
SArray
*
pExprInfo
,
int32_t
numOfRows
)
{
SSDataBlock
*
createOutputBuf_rv
(
SArray
*
pExprInfo
,
int32_t
numOfRows
)
{
const
static
int32_t
minSize
=
8
;
size_t
numOfOutput
=
taosArrayGetSize
(
pExprInfo
);
size_t
numOfOutput
=
taosArrayGetSize
(
pExprInfo
);
SSDataBlock
*
res
=
calloc
(
1
,
sizeof
(
SSDataBlock
));
SSDataBlock
*
res
=
calloc
(
1
,
sizeof
(
SSDataBlock
));
...
@@ -330,15 +328,28 @@ SSDataBlock* createOutputBuf_rv(SArray* pExprInfo, int32_t numOfRows) {
...
@@ -330,15 +328,28 @@ SSDataBlock* createOutputBuf_rv(SArray* pExprInfo, int32_t numOfRows) {
idata
.
info
.
type
=
pExpr
->
base
.
resSchema
.
type
;
idata
.
info
.
type
=
pExpr
->
base
.
resSchema
.
type
;
idata
.
info
.
bytes
=
pExpr
->
base
.
resSchema
.
bytes
;
idata
.
info
.
bytes
=
pExpr
->
base
.
resSchema
.
bytes
;
idata
.
info
.
colId
=
pExpr
->
base
.
resSchema
.
colId
;
idata
.
info
.
colId
=
pExpr
->
base
.
resSchema
.
colId
;
int32_t
size
=
TMAX
(
idata
.
info
.
bytes
*
numOfRows
,
minSize
);
idata
.
pData
=
calloc
(
1
,
size
);
// at least to hold a pointer on x64 platform
taosArrayPush
(
res
->
pDataBlock
,
&
idata
);
taosArrayPush
(
res
->
pDataBlock
,
&
idata
);
}
}
blockDataEnsureCapacity
(
res
,
numOfRows
);
return
res
;
return
res
;
}
}
SSDataBlock
*
createOutputBuf_rv1
(
SDataBlockDescNode
*
pNode
)
{
int32_t
numOfCols
=
LIST_LENGTH
(
pNode
->
pSlots
);
SSDataBlock
*
pBlock
=
calloc
(
1
,
sizeof
(
SSDataBlock
));
pBlock
->
info
.
numOfCols
=
numOfCols
;
pBlock
->
pDataBlock
=
taosArrayInit
(
numOfCols
,
sizeof
(
SColumnInfoData
));
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
idata
=
{{
0
}};
SSlotDescNode
*
pDescNode
=
nodesListGetNode
(
pNode
->
pSlots
,
i
);
idata
.
info
.
type
=
pDescNode
->
dataType
.
type
;
idata
.
info
.
bytes
=
pDescNode
->
dataType
.
bytes
;
idata
.
info
.
slotId
=
pDescNode
->
slotId
;
}
}
static
bool
isSelectivityWithTagsQuery
(
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
)
{
static
bool
isSelectivityWithTagsQuery
(
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
)
{
return
true
;
return
true
;
// bool hasTags = false;
// bool hasTags = false;
...
@@ -2215,10 +2226,10 @@ static void destroyTsComp(STaskRuntimeEnv *pRuntimeEnv, STaskAttr *pQueryAttr) {
...
@@ -2215,10 +2226,10 @@ static void destroyTsComp(STaskRuntimeEnv *pRuntimeEnv, STaskAttr *pQueryAttr) {
if
(
pQueryAttr
->
tsCompQuery
&&
pRuntimeEnv
->
outputBuf
&&
pRuntimeEnv
->
outputBuf
->
pDataBlock
&&
taosArrayGetSize
(
pRuntimeEnv
->
outputBuf
->
pDataBlock
)
>
0
)
{
if
(
pQueryAttr
->
tsCompQuery
&&
pRuntimeEnv
->
outputBuf
&&
pRuntimeEnv
->
outputBuf
->
pDataBlock
&&
taosArrayGetSize
(
pRuntimeEnv
->
outputBuf
->
pDataBlock
)
>
0
)
{
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pRuntimeEnv
->
outputBuf
->
pDataBlock
,
0
);
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pRuntimeEnv
->
outputBuf
->
pDataBlock
,
0
);
if
(
pColInfoData
)
{
if
(
pColInfoData
)
{
FILE
*
f
=
*
(
FILE
*
*
)
pColInfoData
->
pData
;
// TODO refactor
TdFilePtr
pFile
=
*
(
TdFilePtr
*
)
pColInfoData
->
pData
;
// TODO refactor
if
(
f
)
{
if
(
pFile
!=
NULL
)
{
fclose
(
f
);
taosCloseFile
(
&
pFile
);
*
(
FILE
*
*
)
pColInfoData
->
pData
=
NULL
;
*
(
TdFilePtr
*
)
pColInfoData
->
pData
=
NULL
;
}
}
}
}
}
}
...
@@ -8041,6 +8052,10 @@ static tsdbReaderT doCreateDataReader(STableScanPhysiNode* pTableScanNode, SRead
...
@@ -8041,6 +8052,10 @@ static tsdbReaderT doCreateDataReader(STableScanPhysiNode* pTableScanNode, SRead
static
int32_t
doCreateTableGroup
(
void
*
metaHandle
,
int32_t
tableType
,
uint64_t
tableUid
,
STableGroupInfo
*
pGroupInfo
,
uint64_t
queryId
,
uint64_t
taskId
);
static
int32_t
doCreateTableGroup
(
void
*
metaHandle
,
int32_t
tableType
,
uint64_t
tableUid
,
STableGroupInfo
*
pGroupInfo
,
uint64_t
queryId
,
uint64_t
taskId
);
SOperatorInfo
*
doCreateOperatorTreeNode
(
SPhysiNode
*
pPhyNode
,
SExecTaskInfo
*
pTaskInfo
,
SReadHandle
*
pHandle
,
uint64_t
queryId
,
uint64_t
taskId
,
STableGroupInfo
*
pTableGroupInfo
)
{
SOperatorInfo
*
doCreateOperatorTreeNode
(
SPhysiNode
*
pPhyNode
,
SExecTaskInfo
*
pTaskInfo
,
SReadHandle
*
pHandle
,
uint64_t
queryId
,
uint64_t
taskId
,
STableGroupInfo
*
pTableGroupInfo
)
{
if
(
nodeType
(
pPhyNode
)
==
QUERY_NODE_PHYSICAL_PLAN_PROJECT
)
{
// ignore the project node
pPhyNode
=
nodesListGetNode
(
pPhyNode
->
pChildren
,
0
);
}
if
(
pPhyNode
->
pChildren
==
NULL
||
LIST_LENGTH
(
pPhyNode
->
pChildren
)
==
0
)
{
if
(
pPhyNode
->
pChildren
==
NULL
||
LIST_LENGTH
(
pPhyNode
->
pChildren
)
==
0
)
{
if
(
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
==
nodeType
(
pPhyNode
))
{
if
(
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
==
nodeType
(
pPhyNode
))
{
SScanPhysiNode
*
pScanPhyNode
=
(
SScanPhysiNode
*
)
pPhyNode
;
SScanPhysiNode
*
pScanPhyNode
=
(
SScanPhysiNode
*
)
pPhyNode
;
...
@@ -8119,15 +8134,15 @@ static tsdbReaderT createDataReaderImpl(STableScanPhysiNode* pTableScanNode, STa
...
@@ -8119,15 +8134,15 @@ static tsdbReaderT createDataReaderImpl(STableScanPhysiNode* pTableScanNode, STa
cond
.
twindow
=
pTableScanNode
->
scanRange
;
cond
.
twindow
=
pTableScanNode
->
scanRange
;
cond
.
type
=
BLOCK_LOAD_OFFSET_SEQ_ORDER
;
cond
.
type
=
BLOCK_LOAD_OFFSET_SEQ_ORDER
;
// cond.type = pTableScanNode->scanFlag;
for
(
int32_t
i
=
0
;
i
<
cond
.
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
cond
.
numOfCols
;
++
i
)
{
// SExprInfo* pExprInfo = taosArrayGetP(pTableScanNode->scan.node.pTargets, i);
STargetNode
*
pNode
=
(
STargetNode
*
)
nodesListGetNode
(
pTableScanNode
->
scan
.
pScanCols
,
i
);
// assert(pExprInfo->pExpr->nodeType == TEXPR_COL_NODE);
// SSchema* pSchema = pExprInfo->pExpr->pSchema
;
SColumnNode
*
pColNode
=
(
SColumnNode
*
)
pNode
->
pExpr
;
// cond.colList[i].type = pSchema->t
ype;
cond
.
colList
[
i
].
type
=
pColNode
->
colT
ype
;
// cond.colList[i].bytes = pSchema->bytes
;
cond
.
colList
[
i
].
bytes
=
pColNode
->
node
.
resType
.
type
;
// cond.colList[i].colId = pSchema
->colId;
cond
.
colList
[
i
].
colId
=
pColNode
->
colId
;
}
}
return
tsdbQueryTables
(
readHandle
,
&
cond
,
pGroupInfo
,
queryId
,
taskId
);
return
tsdbQueryTables
(
readHandle
,
&
cond
,
pGroupInfo
,
queryId
,
taskId
);
...
...
source/libs/executor/test/executorTests.cpp
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/executor/test/sortTests.cpp
浏览文件 @
21af31f4
...
@@ -13,7 +13,6 @@
...
@@ -13,7 +13,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include <executorimpl.h>
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include <tglobal.h>
#include <tglobal.h>
#include <tsort.h>
#include <tsort.h>
...
@@ -26,6 +25,7 @@
...
@@ -26,6 +25,7 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "os.h"
#include "os.h"
#include "executorimpl.h"
#include "executor.h"
#include "executor.h"
#include "stub.h"
#include "stub.h"
#include "taos.h"
#include "taos.h"
...
...
source/libs/index/inc/indexInt.h
浏览文件 @
21af31f4
...
@@ -122,30 +122,53 @@ typedef struct TFileCacheKey {
...
@@ -122,30 +122,53 @@ typedef struct TFileCacheKey {
int
indexFlushCacheToTFile
(
SIndex
*
sIdx
,
void
*
);
int
indexFlushCacheToTFile
(
SIndex
*
sIdx
,
void
*
);
int32_t
indexSerialCacheKey
(
ICacheKey
*
key
,
char
*
buf
);
int32_t
indexSerialCacheKey
(
ICacheKey
*
key
,
char
*
buf
);
// int32_t indexSerialKey(ICacheKey* key, char* buf);
#define indexFatal(...) \
// int32_t indexSerialTermKey(SIndexTerm* itm, char* buf);
do { \
if (sDebugFlag & DEBUG_FATAL) { taosPrintLog("index FATAL ", 255, __VA_ARGS__); } \
#define indexFatal(...) \
do { \
if (sDebugFlag & DEBUG_FATAL) { \
taosPrintLog("index FATAL ", 255, __VA_ARGS__); \
} \
} while (0)
#define indexError(...) \
do { \
if (sDebugFlag & DEBUG_ERROR) { \
taosPrintLog("index ERROR ", 255, __VA_ARGS__); \
} \
} while (0)
} while (0)
#define indexError(...) \
#define indexWarn(...) \
do { \
do { \
if (sDebugFlag & DEBUG_ERROR) { taosPrintLog("index ERROR ", 255, __VA_ARGS__); } \
if (sDebugFlag & DEBUG_WARN) { \
taosPrintLog("index WARN ", 255, __VA_ARGS__); \
} \
} while (0)
} while (0)
#define indexWarn(...) \
#define indexInfo(...) \
do { \
do { \
if (sDebugFlag & DEBUG_WARN) { taosPrintLog("index WARN ", 255, __VA_ARGS__); } \
if (sDebugFlag & DEBUG_INFO) { \
taosPrintLog("index ", 255, __VA_ARGS__); \
} \
} while (0)
} while (0)
#define indexInfo(...) \
#define indexDebug(...) \
do { \
do { \
if (sDebugFlag & DEBUG_INFO) { taosPrintLog("index ", 255, __VA_ARGS__); } \
if (sDebugFlag & DEBUG_DEBUG) { \
taosPrintLog("index ", sDebugFlag, __VA_ARGS__); \
} \
} while (0)
} while (0)
#define indexDebug(...) \
#define indexTrace(...) \
do { \
do { \
if (sDebugFlag & DEBUG_DEBUG) { taosPrintLog("index ", sDebugFlag, __VA_ARGS__); } \
if (sDebugFlag & DEBUG_TRACE) { \
taosPrintLog("index ", sDebugFlag, __VA_ARGS__); \
} \
} while (0)
} while (0)
#define indexTrace(...) \
do { \
#define INDEX_TYPE_CONTAIN_EXTERN_TYPE(ty, exTy) (((ty >> 4) & (exTy)) != 0)
if (sDebugFlag & DEBUG_TRACE) { taosPrintLog("index ", sDebugFlag, __VA_ARGS__); } \
#define INDEX_TYPE_GET_TYPE(ty) (ty & 0x0F)
#define INDEX_TYPE_ADD_EXTERN_TYPE(ty, exTy) \
do { \
uint8_t oldTy = ty; \
ty = (ty >> 4) | exTy; \
ty = (ty << 4) | oldTy; \
} while (0)
} while (0)
#ifdef __cplusplus
#ifdef __cplusplus
...
...
source/libs/index/inc/index_comm.h
0 → 100644
浏览文件 @
21af31f4
/*
* 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 _TD_INDEX_COMM_H_
#define _TD_INDEX_COMM_H_
#ifdef __cplusplus
extern
"C"
{
#endif
extern
char
JSON_COLUMN
[];
extern
char
JSON_VALUE_DELIM
;
char
*
indexPackJsonData
(
SIndexTerm
*
itm
);
#ifdef __cplusplus
}
#endif
#endif
source/libs/index/src/index.c
浏览文件 @
21af31f4
...
@@ -2,8 +2,8 @@
...
@@ -2,8 +2,8 @@
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
*
* This program is free software: you can use, redistribute, and/or modify
* 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
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free
*
or later ("AGPL"), as published by the Free
Software Foundation.
* Software Foundation.
*
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
...
@@ -30,6 +30,8 @@
...
@@ -30,6 +30,8 @@
void
*
indexQhandle
=
NULL
;
void
*
indexQhandle
=
NULL
;
static
char
JSON_COLUMN
[]
=
"JSON"
;
void
indexInit
()
{
void
indexInit
()
{
// refactor later
// refactor later
indexQhandle
=
taosInitScheduler
(
INDEX_QUEUE_SIZE
,
INDEX_NUM_OF_THREADS
,
"index"
);
indexQhandle
=
taosInitScheduler
(
INDEX_QUEUE_SIZE
,
INDEX_NUM_OF_THREADS
,
"index"
);
...
@@ -63,6 +65,9 @@ static int indexGenTFile(SIndex* index, IndexCache* cache, SArray* batch);
...
@@ -63,6 +65,9 @@ static int indexGenTFile(SIndex* index, IndexCache* cache, SArray* batch);
static
void
indexMergeCacheAndTFile
(
SArray
*
result
,
IterateValue
*
icache
,
IterateValue
*
iTfv
);
static
void
indexMergeCacheAndTFile
(
SArray
*
result
,
IterateValue
*
icache
,
IterateValue
*
iTfv
);
static
void
indexMergeSameKey
(
SArray
*
result
,
TFileValue
*
tv
);
static
void
indexMergeSameKey
(
SArray
*
result
,
TFileValue
*
tv
);
// static int32_t indexSerialTermKey(SIndexTerm* itm, char* buf);
// int32_t indexSerialKey(ICacheKey* key, char* buf);
int
indexOpen
(
SIndexOpts
*
opts
,
const
char
*
path
,
SIndex
**
index
)
{
int
indexOpen
(
SIndexOpts
*
opts
,
const
char
*
path
,
SIndex
**
index
)
{
pthread_once
(
&
isInit
,
indexInit
);
pthread_once
(
&
isInit
,
indexInit
);
SIndex
*
sIdx
=
calloc
(
1
,
sizeof
(
SIndex
));
SIndex
*
sIdx
=
calloc
(
1
,
sizeof
(
SIndex
));
...
@@ -148,7 +153,7 @@ int indexPut(SIndex* index, SIndexMultiTerm* fVals, uint64_t uid) {
...
@@ -148,7 +153,7 @@ int indexPut(SIndex* index, SIndexMultiTerm* fVals, uint64_t uid) {
SIndexTerm
*
p
=
taosArrayGetP
(
fVals
,
i
);
SIndexTerm
*
p
=
taosArrayGetP
(
fVals
,
i
);
char
buf
[
128
]
=
{
0
};
char
buf
[
128
]
=
{
0
};
ICacheKey
key
=
{.
suid
=
p
->
suid
,
.
colName
=
p
->
colName
,
.
nColName
=
strlen
(
p
->
colName
)};
ICacheKey
key
=
{.
suid
=
p
->
suid
,
.
colName
=
p
->
colName
,
.
nColName
=
strlen
(
p
->
colName
)
,
.
colType
=
p
->
colType
};
int32_t
sz
=
indexSerialCacheKey
(
&
key
,
buf
);
int32_t
sz
=
indexSerialCacheKey
(
&
key
,
buf
);
IndexCache
**
cache
=
taosHashGet
(
index
->
colObj
,
buf
,
sz
);
IndexCache
**
cache
=
taosHashGet
(
index
->
colObj
,
buf
,
sz
);
...
@@ -163,7 +168,7 @@ int indexPut(SIndex* index, SIndexMultiTerm* fVals, uint64_t uid) {
...
@@ -163,7 +168,7 @@ int indexPut(SIndex* index, SIndexMultiTerm* fVals, uint64_t uid) {
SIndexTerm
*
p
=
taosArrayGetP
(
fVals
,
i
);
SIndexTerm
*
p
=
taosArrayGetP
(
fVals
,
i
);
char
buf
[
128
]
=
{
0
};
char
buf
[
128
]
=
{
0
};
ICacheKey
key
=
{.
suid
=
p
->
suid
,
.
colName
=
p
->
colName
,
.
nColName
=
strlen
(
p
->
colName
)};
ICacheKey
key
=
{.
suid
=
p
->
suid
,
.
colName
=
p
->
colName
,
.
nColName
=
strlen
(
p
->
colName
)
,
.
colType
=
p
->
colType
};
int32_t
sz
=
indexSerialCacheKey
(
&
key
,
buf
);
int32_t
sz
=
indexSerialCacheKey
(
&
key
,
buf
);
IndexCache
**
cache
=
taosHashGet
(
index
->
colObj
,
buf
,
sz
);
IndexCache
**
cache
=
taosHashGet
(
index
->
colObj
,
buf
,
sz
);
...
@@ -330,8 +335,9 @@ static int indexTermSearch(SIndex* sIdx, SIndexTermQuery* query, SArray** result
...
@@ -330,8 +335,9 @@ static int indexTermSearch(SIndex* sIdx, SIndexTermQuery* query, SArray** result
IndexCache
*
cache
=
NULL
;
IndexCache
*
cache
=
NULL
;
char
buf
[
128
]
=
{
0
};
char
buf
[
128
]
=
{
0
};
ICacheKey
key
=
{.
suid
=
term
->
suid
,
.
colName
=
term
->
colName
,
.
nColName
=
strlen
(
term
->
colName
)};
ICacheKey
key
=
{
int32_t
sz
=
indexSerialCacheKey
(
&
key
,
buf
);
.
suid
=
term
->
suid
,
.
colName
=
term
->
colName
,
.
nColName
=
strlen
(
term
->
colName
),
.
colType
=
term
->
colType
};
int32_t
sz
=
indexSerialCacheKey
(
&
key
,
buf
);
pthread_mutex_lock
(
&
sIdx
->
mtx
);
pthread_mutex_lock
(
&
sIdx
->
mtx
);
IndexCache
**
pCache
=
taosHashGet
(
sIdx
->
colObj
,
buf
,
sz
);
IndexCache
**
pCache
=
taosHashGet
(
sIdx
->
colObj
,
buf
,
sz
);
...
@@ -555,11 +561,17 @@ END:
...
@@ -555,11 +561,17 @@ END:
}
}
int32_t
indexSerialCacheKey
(
ICacheKey
*
key
,
char
*
buf
)
{
int32_t
indexSerialCacheKey
(
ICacheKey
*
key
,
char
*
buf
)
{
bool
hasJson
=
INDEX_TYPE_CONTAIN_EXTERN_TYPE
(
key
->
colType
,
TSDB_DATA_TYPE_JSON
);
char
*
p
=
buf
;
char
*
p
=
buf
;
SERIALIZE_MEM_TO_BUF
(
buf
,
key
,
suid
);
SERIALIZE_MEM_TO_BUF
(
buf
,
key
,
suid
);
SERIALIZE_VAR_TO_BUF
(
buf
,
'_'
,
char
);
SERIALIZE_VAR_TO_BUF
(
buf
,
'_'
,
char
);
// SERIALIZE_MEM_TO_BUF(buf, key, colType);
// SERIALIZE_MEM_TO_BUF(buf, key, colType);
// SERIALIZE_VAR_TO_BUF(buf, '_', char);
// SERIALIZE_VAR_TO_BUF(buf, '_', char);
SERIALIZE_STR_MEM_TO_BUF
(
buf
,
key
,
colName
,
key
->
nColName
);
if
(
hasJson
)
{
SERIALIZE_STR_VAR_TO_BUF
(
buf
,
JSON_COLUMN
,
strlen
(
JSON_COLUMN
));
}
else
{
SERIALIZE_STR_MEM_TO_BUF
(
buf
,
key
,
colName
,
key
->
nColName
);
}
return
buf
-
p
;
return
buf
-
p
;
}
}
source/libs/index/src/index_cache.c
浏览文件 @
21af31f4
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
*/
*/
#include "index_cache.h"
#include "index_cache.h"
#include "index_comm.h"
#include "index_util.h"
#include "index_util.h"
#include "tcompare.h"
#include "tcompare.h"
#include "tsched.h"
#include "tsched.h"
...
@@ -44,8 +45,9 @@ IndexCache* indexCacheCreate(SIndex* idx, uint64_t suid, const char* colName, in
...
@@ -44,8 +45,9 @@ IndexCache* indexCacheCreate(SIndex* idx, uint64_t suid, const char* colName, in
indexError
(
"failed to create index cache"
);
indexError
(
"failed to create index cache"
);
return
NULL
;
return
NULL
;
};
};
cache
->
mem
=
indexInternalCacheCreate
(
type
);
cache
->
mem
=
indexInternalCacheCreate
(
type
);
cache
->
colName
=
tstrdup
(
colName
);
cache
->
colName
=
INDEX_TYPE_CONTAIN_EXTERN_TYPE
(
type
,
TSDB_DATA_TYPE_JSON
)
?
tstrdup
(
JSON_COLUMN
)
:
tstrdup
(
colName
);
cache
->
type
=
type
;
cache
->
type
=
type
;
cache
->
index
=
idx
;
cache
->
index
=
idx
;
cache
->
version
=
0
;
cache
->
version
=
0
;
...
@@ -207,11 +209,11 @@ static void indexCacheMakeRoomForWrite(IndexCache* cache) {
...
@@ -207,11 +209,11 @@ static void indexCacheMakeRoomForWrite(IndexCache* cache) {
}
}
}
}
}
}
int
indexCachePut
(
void
*
cache
,
SIndexTerm
*
term
,
uint64_t
uid
)
{
int
indexCachePut
(
void
*
cache
,
SIndexTerm
*
term
,
uint64_t
uid
)
{
if
(
cache
==
NULL
)
{
if
(
cache
==
NULL
)
{
return
-
1
;
return
-
1
;
}
}
bool
hasJson
=
INDEX_TYPE_CONTAIN_EXTERN_TYPE
(
term
->
colType
,
TSDB_DATA_TYPE_JSON
);
IndexCache
*
pCache
=
cache
;
IndexCache
*
pCache
=
cache
;
indexCacheRef
(
pCache
);
indexCacheRef
(
pCache
);
...
@@ -222,8 +224,12 @@ int indexCachePut(void* cache, SIndexTerm* term, uint64_t uid) {
...
@@ -222,8 +224,12 @@ int indexCachePut(void* cache, SIndexTerm* term, uint64_t uid) {
}
}
// set up key
// set up key
ct
->
colType
=
term
->
colType
;
ct
->
colType
=
term
->
colType
;
ct
->
colVal
=
(
char
*
)
calloc
(
1
,
sizeof
(
char
)
*
(
term
->
nColVal
+
1
));
if
(
hasJson
)
{
memcpy
(
ct
->
colVal
,
term
->
colVal
,
term
->
nColVal
);
ct
->
colVal
=
indexPackJsonData
(
term
);
}
else
{
ct
->
colVal
=
(
char
*
)
calloc
(
1
,
sizeof
(
char
)
*
(
term
->
nColVal
+
1
));
memcpy
(
ct
->
colVal
,
term
->
colVal
,
term
->
nColVal
);
}
ct
->
version
=
atomic_add_fetch_32
(
&
pCache
->
version
,
1
);
ct
->
version
=
atomic_add_fetch_32
(
&
pCache
->
version
,
1
);
// set value
// set value
ct
->
uid
=
uid
;
ct
->
uid
=
uid
;
...
@@ -294,13 +300,22 @@ int indexCacheSearch(void* cache, SIndexTermQuery* query, SArray* result, STermV
...
@@ -294,13 +300,22 @@ int indexCacheSearch(void* cache, SIndexTermQuery* query, SArray* result, STermV
SIndexTerm
*
term
=
query
->
term
;
SIndexTerm
*
term
=
query
->
term
;
EIndexQueryType
qtype
=
query
->
qType
;
EIndexQueryType
qtype
=
query
->
qType
;
CacheTerm
ct
=
{.
colVal
=
term
->
colVal
,
.
version
=
atomic_load_32
(
&
pCache
->
version
)};
bool
hasJson
=
INDEX_TYPE_CONTAIN_EXTERN_TYPE
(
term
->
colType
,
TSDB_DATA_TYPE_JSON
);
char
*
p
=
term
->
colVal
;
if
(
hasJson
)
{
p
=
indexPackJsonData
(
term
);
}
CacheTerm
ct
=
{.
colVal
=
p
,
.
version
=
atomic_load_32
(
&
pCache
->
version
)};
int
ret
=
indexQueryMem
(
mem
,
&
ct
,
qtype
,
result
,
s
);
int
ret
=
indexQueryMem
(
mem
,
&
ct
,
qtype
,
result
,
s
);
if
(
ret
==
0
&&
*
s
!=
kTypeDeletion
)
{
if
(
ret
==
0
&&
*
s
!=
kTypeDeletion
)
{
// continue search in imm
// continue search in imm
ret
=
indexQueryMem
(
imm
,
&
ct
,
qtype
,
result
,
s
);
ret
=
indexQueryMem
(
imm
,
&
ct
,
qtype
,
result
,
s
);
}
}
if
(
hasJson
)
{
tfree
(
p
);
}
indexMemUnRef
(
mem
);
indexMemUnRef
(
mem
);
indexMemUnRef
(
imm
);
indexMemUnRef
(
imm
);
...
@@ -367,6 +382,8 @@ static int32_t indexCacheTermCompare(const void* l, const void* r) {
...
@@ -367,6 +382,8 @@ static int32_t indexCacheTermCompare(const void* l, const void* r) {
}
}
static
MemTable
*
indexInternalCacheCreate
(
int8_t
type
)
{
static
MemTable
*
indexInternalCacheCreate
(
int8_t
type
)
{
type
=
INDEX_TYPE_CONTAIN_EXTERN_TYPE
(
type
,
TSDB_DATA_TYPE_JSON
)
?
TSDB_DATA_TYPE_BINARY
:
type
;
MemTable
*
tbl
=
calloc
(
1
,
sizeof
(
MemTable
));
MemTable
*
tbl
=
calloc
(
1
,
sizeof
(
MemTable
));
indexMemRef
(
tbl
);
indexMemRef
(
tbl
);
if
(
type
==
TSDB_DATA_TYPE_BINARY
||
type
==
TSDB_DATA_TYPE_NCHAR
)
{
if
(
type
==
TSDB_DATA_TYPE_BINARY
||
type
==
TSDB_DATA_TYPE_NCHAR
)
{
...
@@ -389,9 +406,6 @@ static bool indexCacheIteratorNext(Iterate* itera) {
...
@@ -389,9 +406,6 @@ static bool indexCacheIteratorNext(Iterate* itera) {
IterateValue
*
iv
=
&
itera
->
val
;
IterateValue
*
iv
=
&
itera
->
val
;
iterateValueDestroy
(
iv
,
false
);
iterateValueDestroy
(
iv
,
false
);
// IterateValue* iv = &itera->val;
// IterateValue tIterVal = {.colVal = NULL, .val = taosArrayInit(1, sizeof(uint64_t))};
bool
next
=
tSkipListIterNext
(
iter
);
bool
next
=
tSkipListIterNext
(
iter
);
if
(
next
)
{
if
(
next
)
{
SSkipListNode
*
node
=
tSkipListIterGet
(
iter
);
SSkipListNode
*
node
=
tSkipListIterGet
(
iter
);
...
@@ -411,10 +425,6 @@ static bool indexCacheIteratorNext(Iterate* itera) {
...
@@ -411,10 +425,6 @@ static bool indexCacheIteratorNext(Iterate* itera) {
taosArrayPush
(
iv
->
val
,
&
ct
->
uid
);
taosArrayPush
(
iv
->
val
,
&
ct
->
uid
);
}
}
// IterateValue* iv = &itera->val;
// iterateValueDestroy(iv, true);
//*iv = tIterVal;
return
next
;
return
next
;
}
}
...
...
source/libs/index/src/index_comm.c
0 → 100644
浏览文件 @
21af31f4
/*
* 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 "index.h"
#include "indexInt.h"
char
JSON_COLUMN
[]
=
"JSON"
;
char
JSON_VALUE_DELIM
=
'&'
;
char
*
indexPackJsonData
(
SIndexTerm
*
itm
)
{
/*
* |<-----colname---->|<-----dataType---->|<--------colVal---------->|
* |<-----string----->|<-----uint8_t----->|<----depend on dataType-->|
*/
uint8_t
ty
=
INDEX_TYPE_GET_TYPE
(
itm
->
colType
);
int32_t
sz
=
itm
->
nColName
+
itm
->
nColVal
+
sizeof
(
uint8_t
)
+
sizeof
(
JSON_VALUE_DELIM
)
*
2
+
1
;
char
*
buf
=
(
char
*
)
calloc
(
1
,
sz
);
char
*
p
=
buf
;
memcpy
(
p
,
itm
->
colName
,
itm
->
nColName
);
p
+=
itm
->
nColName
;
memcpy
(
p
,
&
JSON_VALUE_DELIM
,
sizeof
(
JSON_VALUE_DELIM
));
p
+=
sizeof
(
JSON_VALUE_DELIM
);
memcpy
(
p
,
&
ty
,
sizeof
(
ty
));
p
+=
sizeof
(
ty
);
memcpy
(
p
,
&
JSON_VALUE_DELIM
,
sizeof
(
JSON_VALUE_DELIM
));
p
+=
sizeof
(
JSON_VALUE_DELIM
);
memcpy
(
p
,
itm
->
colVal
,
itm
->
nColVal
);
return
buf
;
}
source/libs/index/src/index_fst_counting_writer.c
浏览文件 @
21af31f4
...
@@ -63,9 +63,9 @@ static int writeCtxDoReadFrom(WriterCtx* ctx, uint8_t* buf, int len, int32_t off
...
@@ -63,9 +63,9 @@ static int writeCtxDoReadFrom(WriterCtx* ctx, uint8_t* buf, int len, int32_t off
}
}
static
int
writeCtxGetSize
(
WriterCtx
*
ctx
)
{
static
int
writeCtxGetSize
(
WriterCtx
*
ctx
)
{
if
(
ctx
->
type
==
TFile
)
{
if
(
ctx
->
type
==
TFile
)
{
struct
stat
fstat
;
int64_t
file_size
=
0
;
stat
(
ctx
->
file
.
buf
,
&
fstat
);
taosStatFile
(
ctx
->
file
.
buf
,
&
file_size
,
NULL
);
return
fstat
.
st
_size
;
return
(
int
)
file
_size
;
}
}
return
0
;
return
0
;
}
}
...
@@ -99,9 +99,9 @@ WriterCtx* writerCtxCreate(WriterType type, const char* path, bool readOnly, int
...
@@ -99,9 +99,9 @@ WriterCtx* writerCtxCreate(WriterType type, const char* path, bool readOnly, int
// ctx->file.pFile = open(path, O_RDONLY, S_IRWXU | S_IRWXG | S_IRWXO);
// ctx->file.pFile = open(path, O_RDONLY, S_IRWXU | S_IRWXG | S_IRWXO);
ctx
->
file
.
pFile
=
taosOpenFile
(
path
,
TD_FILE_READ
);
ctx
->
file
.
pFile
=
taosOpenFile
(
path
,
TD_FILE_READ
);
struct
stat
fstat
;
int64_t
file_size
=
0
;
stat
(
path
,
&
fstat
);
taosFStatFile
(
ctx
->
file
.
pFile
,
&
file_size
,
NULL
);
ctx
->
file
.
size
=
fstat
.
st
_size
;
ctx
->
file
.
size
=
(
int
)
file
_size
;
#ifdef USE_MMAP
#ifdef USE_MMAP
ctx
->
file
.
ptr
=
(
char
*
)
tfMmapReadOnly
(
ctx
->
file
.
pFile
,
ctx
->
file
.
size
);
ctx
->
file
.
ptr
=
(
char
*
)
tfMmapReadOnly
(
ctx
->
file
.
pFile
,
ctx
->
file
.
size
);
#endif
#endif
...
@@ -142,8 +142,10 @@ void writerCtxDestroy(WriterCtx* ctx, bool remove) {
...
@@ -142,8 +142,10 @@ void writerCtxDestroy(WriterCtx* ctx, bool remove) {
#endif
#endif
}
}
if
(
ctx
->
file
.
readOnly
==
false
)
{
if
(
ctx
->
file
.
readOnly
==
false
)
{
struct
stat
fstat
;
int64_t
file_size
=
0
;
stat
(
ctx
->
file
.
buf
,
&
fstat
);
taosStatFile
(
ctx
->
file
.
buf
,
&
file_size
,
NULL
);
// struct stat fstat;
// stat(ctx->file.buf, &fstat);
// indexError("write file size: %d", (int)(fstat.st_size));
// indexError("write file size: %d", (int)(fstat.st_size));
}
}
if
(
remove
)
{
unlink
(
ctx
->
file
.
buf
);
}
if
(
remove
)
{
unlink
(
ctx
->
file
.
buf
);
}
...
...
source/libs/index/src/index_json.c
0 → 100644
浏览文件 @
21af31f4
/*
* 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 "index.h"
#include "indexInt.h"
int
tIndexJsonOpen
(
SIndexJsonOpts
*
opts
,
const
char
*
path
,
SIndexJson
**
index
)
{
// handle
return
indexOpen
(
opts
,
path
,
index
);
}
int
tIndexJsonPut
(
SIndexJson
*
index
,
SIndexJsonMultiTerm
*
terms
,
uint64_t
uid
)
{
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
terms
);
i
++
)
{
SIndexJsonTerm
*
p
=
taosArrayGetP
(
terms
,
i
);
INDEX_TYPE_ADD_EXTERN_TYPE
(
p
->
colType
,
TSDB_DATA_TYPE_JSON
);
}
return
indexPut
(
index
,
terms
,
uid
);
// handle put
}
int
tIndexJsonSearch
(
SIndexJson
*
index
,
SIndexJsonMultiTermQuery
*
tq
,
SArray
*
result
)
{
SArray
*
terms
=
tq
->
query
;
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
terms
);
i
++
)
{
SIndexJsonTerm
*
p
=
taosArrayGetP
(
terms
,
i
);
INDEX_TYPE_ADD_EXTERN_TYPE
(
p
->
colType
,
TSDB_DATA_TYPE_JSON
);
}
return
indexSearch
(
index
,
tq
,
result
);
// handle search
}
void
tIndexJsonClose
(
SIndexJson
*
index
)
{
return
indexClose
(
index
);
// handle close
}
source/libs/index/src/index_tfile.c
浏览文件 @
21af31f4
...
@@ -15,6 +15,7 @@ p *
...
@@ -15,6 +15,7 @@ p *
#include "index_tfile.h"
#include "index_tfile.h"
#include "index.h"
#include "index.h"
#include "index_comm.h"
#include "index_fst.h"
#include "index_fst.h"
#include "index_fst_counting_writer.h"
#include "index_fst_counting_writer.h"
#include "index_util.h"
#include "index_util.h"
...
@@ -186,13 +187,20 @@ void tfileReaderDestroy(TFileReader* reader) {
...
@@ -186,13 +187,20 @@ void tfileReaderDestroy(TFileReader* reader) {
int
tfileReaderSearch
(
TFileReader
*
reader
,
SIndexTermQuery
*
query
,
SArray
*
result
)
{
int
tfileReaderSearch
(
TFileReader
*
reader
,
SIndexTermQuery
*
query
,
SArray
*
result
)
{
SIndexTerm
*
term
=
query
->
term
;
SIndexTerm
*
term
=
query
->
term
;
bool
hasJson
=
INDEX_TYPE_CONTAIN_EXTERN_TYPE
(
term
->
colType
,
TSDB_DATA_TYPE_JSON
);
EIndexQueryType
qtype
=
query
->
qType
;
EIndexQueryType
qtype
=
query
->
qType
;
int
ret
=
-
1
;
int
ret
=
-
1
;
// refactor to callback later
// refactor to callback later
if
(
qtype
==
QUERY_TERM
)
{
if
(
qtype
==
QUERY_TERM
)
{
uint64_t
offset
;
uint64_t
offset
;
FstSlice
key
=
fstSliceCreate
(
term
->
colVal
,
term
->
nColVal
);
char
*
p
=
term
->
colVal
;
uint64_t
sz
=
term
->
nColVal
;
if
(
hasJson
)
{
p
=
indexPackJsonData
(
term
);
sz
=
strlen
(
p
);
}
FstSlice
key
=
fstSliceCreate
(
p
,
sz
);
if
(
fstGet
(
reader
->
fst
,
&
key
,
&
offset
))
{
if
(
fstGet
(
reader
->
fst
,
&
key
,
&
offset
))
{
indexInfo
(
"index: %"
PRIu64
", col: %s, colVal: %s, found table info in tindex"
,
term
->
suid
,
term
->
colName
,
indexInfo
(
"index: %"
PRIu64
", col: %s, colVal: %s, found table info in tindex"
,
term
->
suid
,
term
->
colName
,
term
->
colVal
);
term
->
colVal
);
...
@@ -202,10 +210,17 @@ int tfileReaderSearch(TFileReader* reader, SIndexTermQuery* query, SArray* resul
...
@@ -202,10 +210,17 @@ int tfileReaderSearch(TFileReader* reader, SIndexTermQuery* query, SArray* resul
term
->
colVal
);
term
->
colVal
);
}
}
fstSliceDestroy
(
&
key
);
fstSliceDestroy
(
&
key
);
if
(
hasJson
)
{
free
(
p
);
}
}
else
if
(
qtype
==
QUERY_PREFIX
)
{
}
else
if
(
qtype
==
QUERY_PREFIX
)
{
// handle later
// handle later
//
//
}
else
{
}
else
if
(
qtype
==
QUERY_SUFFIX
)
{
// handle later
}
else
if
(
qtype
==
QUERY_REGEX
)
{
// handle later
}
else
if
(
qtype
==
QUERY_RANGE
)
{
// handle later
// handle later
}
}
tfileReaderUnRef
(
reader
);
tfileReaderUnRef
(
reader
);
...
@@ -260,6 +275,7 @@ int tfileWriterPut(TFileWriter* tw, void* data, bool order) {
...
@@ -260,6 +275,7 @@ int tfileWriterPut(TFileWriter* tw, void* data, bool order) {
__compar_fn_t
fn
;
__compar_fn_t
fn
;
int8_t
colType
=
tw
->
header
.
colType
;
int8_t
colType
=
tw
->
header
.
colType
;
colType
=
INDEX_TYPE_GET_TYPE
(
colType
);
if
(
colType
==
TSDB_DATA_TYPE_BINARY
||
colType
==
TSDB_DATA_TYPE_NCHAR
)
{
if
(
colType
==
TSDB_DATA_TYPE_BINARY
||
colType
==
TSDB_DATA_TYPE_NCHAR
)
{
fn
=
tfileStrCompare
;
fn
=
tfileStrCompare
;
}
else
{
}
else
{
...
@@ -557,6 +573,8 @@ static int tfileWriteHeader(TFileWriter* writer) {
...
@@ -557,6 +573,8 @@ static int tfileWriteHeader(TFileWriter* writer) {
static
int
tfileWriteData
(
TFileWriter
*
write
,
TFileValue
*
tval
)
{
static
int
tfileWriteData
(
TFileWriter
*
write
,
TFileValue
*
tval
)
{
TFileHeader
*
header
=
&
write
->
header
;
TFileHeader
*
header
=
&
write
->
header
;
uint8_t
colType
=
header
->
colType
;
uint8_t
colType
=
header
->
colType
;
colType
=
INDEX_TYPE_GET_TYPE
(
colType
);
if
(
colType
==
TSDB_DATA_TYPE_BINARY
||
colType
==
TSDB_DATA_TYPE_NCHAR
)
{
if
(
colType
==
TSDB_DATA_TYPE_BINARY
||
colType
==
TSDB_DATA_TYPE_NCHAR
)
{
FstSlice
key
=
fstSliceCreate
((
uint8_t
*
)(
tval
->
colVal
),
(
size_t
)
strlen
(
tval
->
colVal
));
FstSlice
key
=
fstSliceCreate
((
uint8_t
*
)(
tval
->
colVal
),
(
size_t
)
strlen
(
tval
->
colVal
));
if
(
fstBuilderInsert
(
write
->
fb
,
key
,
tval
->
offset
))
{
if
(
fstBuilderInsert
(
write
->
fb
,
key
,
tval
->
offset
))
{
...
@@ -586,11 +604,10 @@ static int tfileReaderLoadHeader(TFileReader* reader) {
...
@@ -586,11 +604,10 @@ static int tfileReaderLoadHeader(TFileReader* reader) {
int64_t
nread
=
reader
->
ctx
->
readFrom
(
reader
->
ctx
,
buf
,
sizeof
(
buf
),
0
);
int64_t
nread
=
reader
->
ctx
->
readFrom
(
reader
->
ctx
,
buf
,
sizeof
(
buf
),
0
);
if
(
nread
==
-
1
)
{
if
(
nread
==
-
1
)
{
indexError
(
"actual Read: %d, to read: %d, errno: %d, filename: %s"
,
(
int
)(
nread
),
(
int
)
sizeof
(
buf
),
indexError
(
"actual Read: %d, to read: %d, errno: %d, filename: %s"
,
(
int
)(
nread
),
(
int
)
sizeof
(
buf
),
errno
,
errno
,
reader
->
ctx
->
file
.
buf
);
reader
->
ctx
->
file
.
buf
);
}
else
{
}
else
{
indexInfo
(
"actual Read: %d, to read: %d, filename: %s"
,
(
int
)(
nread
),
(
int
)
sizeof
(
buf
),
indexInfo
(
"actual Read: %d, to read: %d, filename: %s"
,
(
int
)(
nread
),
(
int
)
sizeof
(
buf
),
reader
->
ctx
->
file
.
buf
);
reader
->
ctx
->
file
.
buf
);
}
}
// assert(nread == sizeof(buf));
// assert(nread == sizeof(buf));
memcpy
(
&
reader
->
header
,
buf
,
sizeof
(
buf
));
memcpy
(
&
reader
->
header
,
buf
,
sizeof
(
buf
));
...
...
source/libs/index/test/CMakeLists.txt
浏览文件 @
21af31f4
...
@@ -2,6 +2,7 @@ add_executable(indexTest "")
...
@@ -2,6 +2,7 @@ add_executable(indexTest "")
add_executable
(
fstTest
""
)
add_executable
(
fstTest
""
)
add_executable
(
fstUT
""
)
add_executable
(
fstUT
""
)
add_executable
(
UtilUT
""
)
add_executable
(
UtilUT
""
)
add_executable
(
jsonUT
""
)
target_sources
(
indexTest
target_sources
(
indexTest
PRIVATE
PRIVATE
...
@@ -21,6 +22,10 @@ target_sources(UtilUT
...
@@ -21,6 +22,10 @@ target_sources(UtilUT
"utilUT.cc"
"utilUT.cc"
)
)
target_sources
(
jsonUT
PRIVATE
"jsonUT.cc"
)
target_include_directories
(
indexTest
target_include_directories
(
indexTest
PUBLIC
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/index"
"
${
CMAKE_SOURCE_DIR
}
/include/libs/index"
...
@@ -43,6 +48,12 @@ target_include_directories ( UtilUT
...
@@ -43,6 +48,12 @@ target_include_directories ( UtilUT
"
${
CMAKE_SOURCE_DIR
}
/include/libs/index"
"
${
CMAKE_SOURCE_DIR
}
/include/libs/index"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
)
target_include_directories
(
jsonUT
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/index"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../inc"
)
target_link_libraries
(
indexTest
target_link_libraries
(
indexTest
os
os
util
util
...
@@ -73,6 +84,13 @@ target_link_libraries (UtilUT
...
@@ -73,6 +84,13 @@ target_link_libraries (UtilUT
index
index
)
)
target_link_libraries
(
jsonUT
os
util
common
gtest_main
index
)
#add_test(
#add_test(
# NAME index_test
# NAME index_test
...
...
source/libs/index/test/fstTest.cc
浏览文件 @
21af31f4
...
@@ -301,13 +301,18 @@ void validateTFile(char* arg) {
...
@@ -301,13 +301,18 @@ void validateTFile(char* arg) {
}
}
}
}
void
iterTFileReader
(
char
*
path
,
char
*
ver
)
{
void
iterTFileReader
(
char
*
path
,
char
*
uid
,
char
*
colName
,
char
*
ver
)
{
int
version
=
atoi
(
ver
);
// tfInit();
TFileReader
*
reader
=
tfileReaderOpen
(
path
,
0
,
version
,
"tag1"
);
Iterate
*
iter
=
tfileIteratorCreate
(
reader
);
uint64_t
suid
=
atoi
(
uid
);
bool
tn
=
iter
?
iter
->
next
(
iter
)
:
false
;
int
version
=
atoi
(
ver
);
int
count
=
0
;
int
termCount
=
0
;
TFileReader
*
reader
=
tfileReaderOpen
(
path
,
suid
,
version
,
colName
);
Iterate
*
iter
=
tfileIteratorCreate
(
reader
);
bool
tn
=
iter
?
iter
->
next
(
iter
)
:
false
;
int
count
=
0
;
int
termCount
=
0
;
while
(
tn
==
true
)
{
while
(
tn
==
true
)
{
count
++
;
count
++
;
IterateValue
*
cv
=
iter
->
getValue
(
iter
);
IterateValue
*
cv
=
iter
->
getValue
(
iter
);
...
@@ -323,9 +328,9 @@ void iterTFileReader(char* path, char* ver) {
...
@@ -323,9 +328,9 @@ void iterTFileReader(char* path, char* ver) {
int
main
(
int
argc
,
char
*
argv
[])
{
int
main
(
int
argc
,
char
*
argv
[])
{
// tool to check all kind of fst test
// tool to check all kind of fst test
// if (argc > 1) { validateTFile(argv[1]); }
// if (argc > 1) { validateTFile(argv[1]); }
if
(
argc
>
2
)
{
if
(
argc
>
4
)
{
//
opt
//
path suid colName ver
iterTFileReader
(
argv
[
1
],
argv
[
2
]);
iterTFileReader
(
argv
[
1
],
argv
[
2
]
,
argv
[
3
],
argv
[
4
]
);
}
}
// checkFstCheckIterator();
// checkFstCheckIterator();
// checkFstLongTerm();
// checkFstLongTerm();
...
...
source/libs/index/test/fstUT.cc
浏览文件 @
21af31f4
...
@@ -213,21 +213,21 @@ class FstEnv : public ::testing::Test {
...
@@ -213,21 +213,21 @@ class FstEnv : public ::testing::Test {
TEST_F
(
FstEnv
,
writeNormal
)
{
TEST_F
(
FstEnv
,
writeNormal
)
{
fst
->
CreateWriter
();
fst
->
CreateWriter
();
std
::
string
str
(
"
aa
"
);
std
::
string
str
(
"
11
"
);
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
for
(
int
i
=
0
;
i
<
10
;
i
++
)
{
str
[
0
]
=
'
a
'
+
i
;
str
[
0
]
=
'
1
'
+
i
;
str
.
resize
(
2
);
str
.
resize
(
2
);
assert
(
fst
->
Put
(
str
,
i
)
==
true
);
assert
(
fst
->
Put
(
str
,
i
)
==
true
);
}
}
// order failed
// order failed
assert
(
fst
->
Put
(
"
aa
"
,
1
)
==
false
);
assert
(
fst
->
Put
(
"
11
"
,
1
)
==
false
);
fst
->
DestroyWriter
();
fst
->
DestroyWriter
();
fst
->
CreateReader
();
fst
->
CreateReader
();
uint64_t
val
;
uint64_t
val
;
assert
(
fst
->
Get
(
"
a
"
,
&
val
)
==
false
);
assert
(
fst
->
Get
(
"
1
"
,
&
val
)
==
false
);
assert
(
fst
->
Get
(
"
aa
"
,
&
val
)
==
true
);
assert
(
fst
->
Get
(
"
11
"
,
&
val
)
==
true
);
assert
(
val
==
0
);
assert
(
val
==
0
);
std
::
vector
<
uint64_t
>
rlt
;
std
::
vector
<
uint64_t
>
rlt
;
...
@@ -235,3 +235,19 @@ TEST_F(FstEnv, writeNormal) {
...
@@ -235,3 +235,19 @@ TEST_F(FstEnv, writeNormal) {
assert
(
fst
->
Search
(
ctx
,
rlt
)
==
true
);
assert
(
fst
->
Search
(
ctx
,
rlt
)
==
true
);
}
}
TEST_F
(
FstEnv
,
WriteMillonrRecord
)
{}
TEST_F
(
FstEnv
,
WriteMillonrRecord
)
{}
TEST_F
(
FstEnv
,
writeAbNormal
)
{
fst
->
CreateWriter
();
std
::
string
str1
(
"voltage&
\b
&ab"
);
std
::
string
str2
(
"voltbge&
\b
&ab"
);
fst
->
Put
(
str1
,
1
);
fst
->
Put
(
str2
,
2
);
fst
->
DestroyWriter
();
fst
->
CreateReader
();
uint64_t
val
;
assert
(
fst
->
Get
(
"1"
,
&
val
)
==
false
);
assert
(
fst
->
Get
(
"voltage&
\b
&ab"
,
&
val
)
==
true
);
assert
(
val
==
1
);
}
source/libs/index/test/jsonUT.cc
0 → 100644
浏览文件 @
21af31f4
#include <gtest/gtest.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <thread>
#include <vector>
#include "index.h"
#include "indexInt.h"
#include "index_cache.h"
#include "index_fst.h"
#include "index_fst_counting_writer.h"
#include "index_fst_util.h"
#include "index_tfile.h"
#include "index_util.h"
#include "tglobal.h"
#include "tskiplist.h"
#include "tutil.h"
static
std
::
string
dir
=
"/tmp/json"
;
class
JsonEnv
:
public
::
testing
::
Test
{
protected:
virtual
void
SetUp
()
{
taosRemoveDir
(
dir
.
c_str
());
taosMkDir
(
dir
.
c_str
());
printf
(
"set up
\n
"
);
opts
=
indexOptsCreate
();
int
ret
=
tIndexJsonOpen
(
opts
,
dir
.
c_str
(),
&
index
);
assert
(
ret
==
0
);
}
virtual
void
TearDown
()
{
tIndexJsonClose
(
index
);
indexOptsDestroy
(
opts
);
printf
(
"destory
\n
"
);
}
SIndexJsonOpts
*
opts
;
SIndexJson
*
index
;
};
TEST_F
(
JsonEnv
,
testWrite
)
{
{
std
::
string
colName
(
"test"
);
std
::
string
colVal
(
"ab"
);
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
indexMultiTermAdd
(
terms
,
term
);
for
(
size_t
i
=
0
;
i
<
100
;
i
++
)
{
tIndexJsonPut
(
index
,
terms
,
i
);
}
indexMultiTermDestroy
(
terms
);
}
{
std
::
string
colName
(
"voltage"
);
std
::
string
colVal
(
"ab1"
);
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
indexMultiTermAdd
(
terms
,
term
);
for
(
size_t
i
=
0
;
i
<
100
;
i
++
)
{
tIndexJsonPut
(
index
,
terms
,
i
);
}
indexMultiTermDestroy
(
terms
);
}
{
std
::
string
colName
(
"voltage"
);
std
::
string
colVal
(
"123"
);
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
indexMultiTermAdd
(
terms
,
term
);
for
(
size_t
i
=
0
;
i
<
100
;
i
++
)
{
tIndexJsonPut
(
index
,
terms
,
i
);
}
indexMultiTermDestroy
(
terms
);
}
{
std
::
string
colName
(
"test"
);
std
::
string
colVal
(
"ab"
);
SIndexMultiTermQuery
*
mq
=
indexMultiTermQueryCreate
(
MUST
);
SIndexTerm
*
q
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SArray
*
result
=
taosArrayInit
(
1
,
sizeof
(
uint64_t
));
indexMultiTermQueryAdd
(
mq
,
q
,
QUERY_TERM
);
tIndexJsonSearch
(
index
,
mq
,
result
);
assert
(
100
==
taosArrayGetSize
(
result
));
indexMultiTermQueryDestroy
(
mq
);
}
}
TEST_F
(
JsonEnv
,
testWriteMillonData
)
{
{
std
::
string
colName
(
"test"
);
std
::
string
colVal
(
"ab"
);
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
indexMultiTermAdd
(
terms
,
term
);
for
(
size_t
i
=
0
;
i
<
100
;
i
++
)
{
tIndexJsonPut
(
index
,
terms
,
i
);
}
indexMultiTermDestroy
(
terms
);
}
{
std
::
string
colName
(
"voltagefdadfa"
);
std
::
string
colVal
(
"abxxxxxxxxxxxx"
);
SIndexTerm
*
term
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SIndexMultiTerm
*
terms
=
indexMultiTermCreate
();
indexMultiTermAdd
(
terms
,
term
);
for
(
size_t
i
=
0
;
i
<
1000000
;
i
++
)
{
tIndexJsonPut
(
index
,
terms
,
i
);
}
indexMultiTermDestroy
(
terms
);
}
{
std
::
string
colName
(
"test"
);
std
::
string
colVal
(
"ab"
);
SIndexMultiTermQuery
*
mq
=
indexMultiTermQueryCreate
(
MUST
);
SIndexTerm
*
q
=
indexTermCreate
(
1
,
ADD_VALUE
,
TSDB_DATA_TYPE_BINARY
,
colName
.
c_str
(),
colName
.
size
(),
colVal
.
c_str
(),
colVal
.
size
());
SArray
*
result
=
taosArrayInit
(
1
,
sizeof
(
uint64_t
));
indexMultiTermQueryAdd
(
mq
,
q
,
QUERY_TERM
);
tIndexJsonSearch
(
index
,
mq
,
result
);
assert
(
100
==
taosArrayGetSize
(
result
));
indexMultiTermQueryDestroy
(
mq
);
}
}
source/libs/monitor/src/monitor.c
浏览文件 @
21af31f4
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
static
SMonitor
tsMonitor
=
{
0
};
static
SMonitor
tsMonitor
=
{
0
};
int32_t
monInit
(
const
SMonCfg
*
pCfg
)
{
int32_t
monInit
(
const
SMonCfg
*
pCfg
)
{
tsMonitor
.
logs
=
taosArrayInit
(
16
,
sizeof
(
SMon
Info
));
tsMonitor
.
logs
=
taosArrayInit
(
16
,
sizeof
(
SMon
LogItem
));
if
(
tsMonitor
.
logs
==
NULL
)
{
if
(
tsMonitor
.
logs
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
...
@@ -44,7 +44,7 @@ void monCleanup() {
...
@@ -44,7 +44,7 @@ void monCleanup() {
void
monAddLogItem
(
SMonLogItem
*
pItem
)
{
void
monAddLogItem
(
SMonLogItem
*
pItem
)
{
taosWLockLatch
(
&
tsMonitor
.
lock
);
taosWLockLatch
(
&
tsMonitor
.
lock
);
int32_t
size
=
taosArrayGetSize
(
tsMonitor
.
logs
);
int32_t
size
=
taosArrayGetSize
(
tsMonitor
.
logs
);
if
(
size
>
tsMonitor
.
maxLogs
)
{
if
(
size
>
=
tsMonitor
.
maxLogs
)
{
uInfo
(
"too many logs for monitor"
);
uInfo
(
"too many logs for monitor"
);
}
else
{
}
else
{
taosArrayPush
(
tsMonitor
.
logs
,
pItem
);
taosArrayPush
(
tsMonitor
.
logs
,
pItem
);
...
@@ -54,7 +54,10 @@ void monAddLogItem(SMonLogItem *pItem) {
...
@@ -54,7 +54,10 @@ void monAddLogItem(SMonLogItem *pItem) {
SMonInfo
*
monCreateMonitorInfo
()
{
SMonInfo
*
monCreateMonitorInfo
()
{
SMonInfo
*
pMonitor
=
calloc
(
1
,
sizeof
(
SMonInfo
));
SMonInfo
*
pMonitor
=
calloc
(
1
,
sizeof
(
SMonInfo
));
if
(
pMonitor
==
NULL
)
return
NULL
;
if
(
pMonitor
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
taosWLockLatch
(
&
tsMonitor
.
lock
);
taosWLockLatch
(
&
tsMonitor
.
lock
);
pMonitor
->
logs
=
taosArrayDup
(
tsMonitor
.
logs
);
pMonitor
->
logs
=
taosArrayDup
(
tsMonitor
.
logs
);
...
@@ -77,41 +80,257 @@ void monCleanupMonitorInfo(SMonInfo *pMonitor) {
...
@@ -77,41 +80,257 @@ void monCleanupMonitorInfo(SMonInfo *pMonitor) {
free
(
pMonitor
);
free
(
pMonitor
);
}
}
void
monSendReport
(
SMonInfo
*
pMonitor
)
{
char
*
pCont
=
tjsonToString
(
pMonitor
->
pJson
);
if
(
pCont
!=
NULL
)
{
taosSendHttpReport
(
tsMonitor
.
server
,
tsMonitor
.
port
,
pCont
,
strlen
(
pCont
));
free
(
pCont
);
}
}
void
monSetBasicInfo
(
SMonInfo
*
pMonitor
,
SMonBasicInfo
*
pInfo
)
{
void
monSetBasicInfo
(
SMonInfo
*
pMonitor
,
SMonBasicInfo
*
pInfo
)
{
SJson
*
pJson
=
pMonitor
->
pJson
;
SJson
*
pJson
=
pMonitor
->
pJson
;
tjsonAddDoubleToObject
(
pJson
,
"dnode_id"
,
pInfo
->
dnode_id
);
tjsonAddStringToObject
(
pJson
,
"dnode_ep"
,
pInfo
->
dnode_ep
);
int64_t
ms
=
taosGetTimestampMs
();
int64_t
ms
=
taosGetTimestampMs
();
char
buf
[
40
]
=
{
0
};
char
buf
[
40
]
=
{
0
};
taosFormatUtcTime
(
buf
,
sizeof
(
buf
),
ms
,
TSDB_TIME_PRECISION_MILLI
);
taosFormatUtcTime
(
buf
,
sizeof
(
buf
),
ms
,
TSDB_TIME_PRECISION_MILLI
);
tjsonAddStringToObject
(
pJson
,
"ts"
,
buf
);
tjsonAddStringToObject
(
pJson
,
"ts"
,
buf
);
tjsonAddDoubleToObject
(
pJson
,
"dnode_id"
,
pInfo
->
dnode_id
);
tjsonAddStringToObject
(
pJson
,
"dnode_ep"
,
pInfo
->
dnode_ep
);
}
}
void
monSetClusterInfo
(
SMonInfo
*
pMonitor
,
SMonClusterInfo
*
pInfo
)
{
void
monSetClusterInfo
(
SMonInfo
*
pMonitor
,
SMonClusterInfo
*
pInfo
)
{
SJson
*
pJson
=
tjsonCreateObject
();
if
(
pJson
==
NULL
)
return
;
if
(
tjsonAddItemToObject
(
pMonitor
->
pJson
,
"cluster_info"
,
pJson
)
!=
0
)
{
tjsonDelete
(
pJson
);
return
;
}
tjsonAddStringToObject
(
pJson
,
"first_ep"
,
pInfo
->
first_ep
);
tjsonAddDoubleToObject
(
pJson
,
"first_ep_dnode_id"
,
pInfo
->
first_ep_dnode_id
);
tjsonAddStringToObject
(
pJson
,
"version"
,
pInfo
->
version
);
tjsonAddDoubleToObject
(
pJson
,
"master_uptime"
,
pInfo
->
master_uptime
);
tjsonAddDoubleToObject
(
pJson
,
"monitor_interval"
,
pInfo
->
monitor_interval
);
tjsonAddDoubleToObject
(
pJson
,
"vgroups_total"
,
pInfo
->
vgroups_total
);
tjsonAddDoubleToObject
(
pJson
,
"vgroups_alive"
,
pInfo
->
vgroups_alive
);
tjsonAddDoubleToObject
(
pJson
,
"vnodes_total"
,
pInfo
->
vnodes_total
);
tjsonAddDoubleToObject
(
pJson
,
"vnodes_alive"
,
pInfo
->
vnodes_alive
);
tjsonAddDoubleToObject
(
pJson
,
"connections_total"
,
pInfo
->
connections_total
);
SJson
*
pDnodesJson
=
tjsonAddArrayToObject
(
pJson
,
"dnodes"
);
if
(
pDnodesJson
==
NULL
)
return
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pInfo
->
dnodes
);
++
i
)
{
SJson
*
pDnodeJson
=
tjsonCreateObject
();
if
(
pDnodeJson
==
NULL
)
continue
;
SMonDnodeDesc
*
pDnodeDesc
=
taosArrayGet
(
pInfo
->
dnodes
,
i
);
tjsonAddDoubleToObject
(
pDnodeJson
,
"dnode_id"
,
pDnodeDesc
->
dnode_id
);
tjsonAddStringToObject
(
pDnodeJson
,
"dnode_ep"
,
pDnodeDesc
->
dnode_ep
);
tjsonAddStringToObject
(
pDnodeJson
,
"status"
,
pDnodeDesc
->
status
);
if
(
tjsonAddItemToArray
(
pDnodesJson
,
pDnodeJson
)
!=
0
)
tjsonDelete
(
pDnodeJson
);
}
SJson
*
pMnodesJson
=
tjsonAddArrayToObject
(
pJson
,
"mnodes"
);
if
(
pMnodesJson
==
NULL
)
return
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pInfo
->
dnodes
);
++
i
)
{
SJson
*
pMnodeJson
=
tjsonCreateObject
();
if
(
pMnodeJson
==
NULL
)
continue
;
SMonMnodeDesc
*
pMnodeDesc
=
taosArrayGet
(
pInfo
->
dnodes
,
i
);
tjsonAddDoubleToObject
(
pMnodeJson
,
"mnode_id"
,
pMnodeDesc
->
mnode_id
);
tjsonAddStringToObject
(
pMnodeJson
,
"mnode_ep"
,
pMnodeDesc
->
mnode_ep
);
tjsonAddStringToObject
(
pMnodeJson
,
"role"
,
pMnodeDesc
->
role
);
if
(
tjsonAddItemToArray
(
pMnodesJson
,
pMnodeJson
)
!=
0
)
tjsonDelete
(
pMnodeJson
);
}
}
}
void
monSetVgroupInfo
(
SMonInfo
*
pMonitor
,
SMonVgroupInfo
*
pInfo
)
{
void
monSetVgroupInfo
(
SMonInfo
*
pMonitor
,
SMonVgroupInfo
*
pInfo
)
{
SJson
*
pJson
=
tjsonAddArrayToObject
(
pMonitor
->
pJson
,
"vgroup_infos"
);
if
(
pJson
==
NULL
)
return
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pInfo
->
vgroups
);
++
i
)
{
SJson
*
pVgroupJson
=
tjsonCreateObject
();
if
(
pVgroupJson
==
NULL
)
continue
;
if
(
tjsonAddItemToArray
(
pJson
,
pVgroupJson
)
!=
0
)
{
tjsonDelete
(
pVgroupJson
);
continue
;
}
SMonVgroupDesc
*
pVgroupDesc
=
taosArrayGet
(
pInfo
->
vgroups
,
i
);
tjsonAddDoubleToObject
(
pVgroupJson
,
"vgroup_id"
,
pVgroupDesc
->
vgroup_id
);
tjsonAddStringToObject
(
pVgroupJson
,
"database_name"
,
pVgroupDesc
->
database_name
);
tjsonAddDoubleToObject
(
pVgroupJson
,
"tables_num"
,
pVgroupDesc
->
tables_num
);
tjsonAddStringToObject
(
pVgroupJson
,
"status"
,
pVgroupDesc
->
status
);
SJson
*
pVnodesJson
=
tjsonAddArrayToObject
(
pVgroupJson
,
"vnodes"
);
if
(
pVnodesJson
==
NULL
)
continue
;
for
(
int32_t
j
=
0
;
j
<
TSDB_MAX_REPLICA
;
++
j
)
{
SMonVnodeDesc
*
pVnodeDesc
=
&
pVgroupDesc
->
vnodes
[
j
];
if
(
pVnodeDesc
->
dnode_id
<=
0
)
continue
;
SJson
*
pVnodeJson
=
tjsonCreateObject
();
if
(
pVnodeJson
==
NULL
)
continue
;
tjsonAddDoubleToObject
(
pVnodeJson
,
"dnode_id"
,
pVnodeDesc
->
dnode_id
);
tjsonAddStringToObject
(
pVnodeJson
,
"vnode_role"
,
pVnodeDesc
->
vnode_role
);
if
(
tjsonAddItemToArray
(
pVnodesJson
,
pVnodeJson
)
!=
0
)
tjsonDelete
(
pVnodeJson
);
}
}
}
}
void
monSetGrantInfo
(
SMonInfo
*
pMonitor
,
SMonGrantInfo
*
pInfo
)
{
void
monSetGrantInfo
(
SMonInfo
*
pMonitor
,
SMonGrantInfo
*
pInfo
)
{
SJson
*
pJson
=
tjsonCreateObject
();
if
(
pJson
==
NULL
)
return
;
if
(
tjsonAddItemToObject
(
pMonitor
->
pJson
,
"grant_info"
,
pJson
)
!=
0
)
{
tjsonDelete
(
pJson
);
return
;
}
tjsonAddDoubleToObject
(
pJson
,
"expire_time"
,
pInfo
->
expire_time
);
tjsonAddDoubleToObject
(
pJson
,
"timeseries_used"
,
pInfo
->
timeseries_used
);
tjsonAddDoubleToObject
(
pJson
,
"timeseries_total"
,
pInfo
->
timeseries_total
);
}
}
void
monSetDnodeInfo
(
SMonInfo
*
pMonitor
,
SMonDnodeInfo
*
pInfo
)
{
void
monSetDnodeInfo
(
SMonInfo
*
pMonitor
,
SMonDnodeInfo
*
pInfo
)
{
SJson
*
pJson
=
tjsonCreateObject
();
if
(
pJson
==
NULL
)
return
;
if
(
tjsonAddItemToObject
(
pMonitor
->
pJson
,
"dnode_info"
,
pJson
)
!=
0
)
{
tjsonDelete
(
pJson
);
return
;
}
tjsonAddDoubleToObject
(
pJson
,
"uptime"
,
pInfo
->
uptime
);
tjsonAddDoubleToObject
(
pJson
,
"cpu_engine"
,
pInfo
->
cpu_engine
);
tjsonAddDoubleToObject
(
pJson
,
"cpu_system"
,
pInfo
->
cpu_system
);
tjsonAddDoubleToObject
(
pJson
,
"cpu_cores"
,
pInfo
->
cpu_cores
);
tjsonAddDoubleToObject
(
pJson
,
"mem_engine"
,
pInfo
->
mem_engine
);
tjsonAddDoubleToObject
(
pJson
,
"mem_system"
,
pInfo
->
mem_system
);
tjsonAddDoubleToObject
(
pJson
,
"mem_total"
,
pInfo
->
mem_total
);
tjsonAddDoubleToObject
(
pJson
,
"disk_engine"
,
pInfo
->
disk_engine
);
tjsonAddDoubleToObject
(
pJson
,
"disk_used"
,
pInfo
->
disk_used
);
tjsonAddDoubleToObject
(
pJson
,
"disk_total"
,
pInfo
->
disk_total
);
tjsonAddDoubleToObject
(
pJson
,
"net_in"
,
pInfo
->
net_in
);
tjsonAddDoubleToObject
(
pJson
,
"net_out"
,
pInfo
->
net_out
);
tjsonAddDoubleToObject
(
pJson
,
"io_read"
,
pInfo
->
io_read
);
tjsonAddDoubleToObject
(
pJson
,
"io_write"
,
pInfo
->
io_write
);
tjsonAddDoubleToObject
(
pJson
,
"io_read_disk"
,
pInfo
->
io_read_disk
);
tjsonAddDoubleToObject
(
pJson
,
"io_write_disk"
,
pInfo
->
io_write_disk
);
tjsonAddDoubleToObject
(
pJson
,
"req_select"
,
pInfo
->
req_select
);
tjsonAddDoubleToObject
(
pJson
,
"req_select_rate"
,
pInfo
->
req_select_rate
);
tjsonAddDoubleToObject
(
pJson
,
"req_insert"
,
pInfo
->
req_insert
);
tjsonAddDoubleToObject
(
pJson
,
"req_insert_success"
,
pInfo
->
req_insert_success
);
tjsonAddDoubleToObject
(
pJson
,
"req_insert_rate"
,
pInfo
->
req_insert_rate
);
tjsonAddDoubleToObject
(
pJson
,
"req_insert_batch"
,
pInfo
->
req_insert_batch
);
tjsonAddDoubleToObject
(
pJson
,
"req_insert_batch_success"
,
pInfo
->
req_insert_batch_success
);
tjsonAddDoubleToObject
(
pJson
,
"req_insert_batch_rate"
,
pInfo
->
req_insert_batch_rate
);
tjsonAddDoubleToObject
(
pJson
,
"errors"
,
pInfo
->
errors
);
tjsonAddDoubleToObject
(
pJson
,
"vnodes_num"
,
pInfo
->
vnodes_num
);
tjsonAddDoubleToObject
(
pJson
,
"masters"
,
pInfo
->
masters
);
tjsonAddDoubleToObject
(
pJson
,
"has_mnode"
,
pInfo
->
has_mnode
);
}
}
void
monSetDiskInfo
(
SMonInfo
*
pMonitor
,
SMonDiskInfo
*
pInfo
)
{
void
monSetDiskInfo
(
SMonInfo
*
pMonitor
,
SMonDiskInfo
*
pInfo
)
{
SJson
*
pJson
=
tjsonCreateObject
();
if
(
pJson
==
NULL
)
return
;
if
(
tjsonAddItemToObject
(
pMonitor
->
pJson
,
"disk_infos"
,
pJson
)
!=
0
)
{
tjsonDelete
(
pJson
);
return
;
}
SJson
*
pDatadirsJson
=
tjsonAddArrayToObject
(
pJson
,
"datadir"
);
if
(
pDatadirsJson
==
NULL
)
return
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pInfo
->
datadirs
);
++
i
)
{
SJson
*
pDatadirJson
=
tjsonCreateObject
();
if
(
pDatadirJson
==
NULL
)
continue
;
SMonDiskDesc
*
pDatadirDesc
=
taosArrayGet
(
pInfo
->
datadirs
,
i
);
if
(
tjsonAddStringToObject
(
pDatadirJson
,
"name"
,
pDatadirDesc
->
name
)
!=
0
)
tjsonDelete
(
pDatadirJson
);
if
(
tjsonAddDoubleToObject
(
pDatadirJson
,
"level"
,
pDatadirDesc
->
level
)
!=
0
)
tjsonDelete
(
pDatadirJson
);
if
(
tjsonAddDoubleToObject
(
pDatadirJson
,
"avail"
,
pDatadirDesc
->
size
.
avail
)
!=
0
)
tjsonDelete
(
pDatadirJson
);
if
(
tjsonAddDoubleToObject
(
pDatadirJson
,
"used"
,
pDatadirDesc
->
size
.
used
)
!=
0
)
tjsonDelete
(
pDatadirJson
);
if
(
tjsonAddDoubleToObject
(
pDatadirJson
,
"total"
,
pDatadirDesc
->
size
.
total
)
!=
0
)
tjsonDelete
(
pDatadirJson
);
if
(
tjsonAddItemToArray
(
pDatadirsJson
,
pDatadirJson
)
!=
0
)
tjsonDelete
(
pDatadirJson
);
}
SJson
*
pLogdirJson
=
tjsonCreateObject
();
if
(
pLogdirJson
==
NULL
)
return
;
if
(
tjsonAddItemToObject
(
pJson
,
"logdir"
,
pLogdirJson
)
!=
0
)
return
;
tjsonAddStringToObject
(
pLogdirJson
,
"name"
,
pInfo
->
logdir
.
name
);
tjsonAddDoubleToObject
(
pLogdirJson
,
"avail"
,
pInfo
->
logdir
.
size
.
avail
);
tjsonAddDoubleToObject
(
pLogdirJson
,
"used"
,
pInfo
->
logdir
.
size
.
used
);
tjsonAddDoubleToObject
(
pLogdirJson
,
"total"
,
pInfo
->
logdir
.
size
.
total
);
SJson
*
pTempdirJson
=
tjsonCreateObject
();
if
(
pTempdirJson
==
NULL
)
return
;
if
(
tjsonAddItemToObject
(
pJson
,
"tempdir"
,
pTempdirJson
)
!=
0
)
return
;
tjsonAddStringToObject
(
pTempdirJson
,
"name"
,
pInfo
->
tempdir
.
name
);
tjsonAddDoubleToObject
(
pTempdirJson
,
"avail"
,
pInfo
->
tempdir
.
size
.
avail
);
tjsonAddDoubleToObject
(
pTempdirJson
,
"used"
,
pInfo
->
tempdir
.
size
.
used
);
tjsonAddDoubleToObject
(
pTempdirJson
,
"total"
,
pInfo
->
tempdir
.
size
.
total
);
}
static
void
monSetLogInfo
(
SMonInfo
*
pMonitor
)
{
SJson
*
pJson
=
tjsonCreateObject
();
if
(
pJson
==
NULL
)
return
;
if
(
tjsonAddItemToObject
(
pMonitor
->
pJson
,
"log_infos"
,
pJson
)
!=
0
)
{
tjsonDelete
(
pJson
);
return
;
}
SJson
*
pLogsJson
=
tjsonAddArrayToObject
(
pJson
,
"logs"
);
if
(
pLogsJson
==
NULL
)
return
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pMonitor
->
logs
);
++
i
)
{
SJson
*
pLogJson
=
tjsonCreateObject
();
if
(
pLogJson
==
NULL
)
continue
;
SMonLogItem
*
pLogItem
=
taosArrayGet
(
pMonitor
->
logs
,
i
);
char
buf
[
40
]
=
{
0
};
taosFormatUtcTime
(
buf
,
sizeof
(
buf
),
pLogItem
->
ts
,
TSDB_TIME_PRECISION_MILLI
);
tjsonAddStringToObject
(
pLogJson
,
"ts"
,
buf
);
tjsonAddDoubleToObject
(
pLogJson
,
"level"
,
pLogItem
->
level
);
tjsonAddStringToObject
(
pLogJson
,
"content"
,
pLogItem
->
content
);
if
(
tjsonAddItemToArray
(
pLogsJson
,
pLogJson
)
!=
0
)
tjsonDelete
(
pLogJson
);
}
SJson
*
pSummaryJson
=
tjsonAddArrayToObject
(
pJson
,
"summary"
);
if
(
pSummaryJson
==
NULL
)
return
;
SJson
*
pLogError
=
tjsonCreateObject
();
if
(
pLogError
==
NULL
)
return
;
tjsonAddStringToObject
(
pLogError
,
"level"
,
"error"
);
tjsonAddDoubleToObject
(
pLogError
,
"total"
,
1
);
if
(
tjsonAddItemToArray
(
pSummaryJson
,
pLogError
)
!=
0
)
tjsonDelete
(
pLogError
);
SJson
*
pLogInfo
=
tjsonCreateObject
();
if
(
pLogInfo
==
NULL
)
return
;
tjsonAddStringToObject
(
pLogInfo
,
"level"
,
"info"
);
tjsonAddDoubleToObject
(
pLogInfo
,
"total"
,
1
);
if
(
tjsonAddItemToArray
(
pSummaryJson
,
pLogInfo
)
!=
0
)
tjsonDelete
(
pLogInfo
);
SJson
*
pLogDebug
=
tjsonCreateObject
();
if
(
pLogDebug
==
NULL
)
return
;
tjsonAddStringToObject
(
pLogDebug
,
"level"
,
"debug"
);
tjsonAddDoubleToObject
(
pLogDebug
,
"total"
,
1
);
if
(
tjsonAddItemToArray
(
pSummaryJson
,
pLogDebug
)
!=
0
)
tjsonDelete
(
pLogDebug
);
SJson
*
pLogTrace
=
tjsonCreateObject
();
if
(
pLogTrace
==
NULL
)
return
;
tjsonAddStringToObject
(
pLogTrace
,
"level"
,
"trace"
);
tjsonAddDoubleToObject
(
pLogTrace
,
"total"
,
1
);
if
(
tjsonAddItemToArray
(
pSummaryJson
,
pLogTrace
)
!=
0
)
tjsonDelete
(
pLogTrace
);
}
void
monSendReport
(
SMonInfo
*
pMonitor
)
{
monSetLogInfo
(
pMonitor
);
char
*
pCont
=
tjsonToString
(
pMonitor
->
pJson
);
if
(
pCont
!=
NULL
)
{
taosSendHttpReport
(
tsMonitor
.
server
,
tsMonitor
.
port
,
pCont
,
strlen
(
pCont
));
free
(
pCont
);
}
}
}
source/libs/monitor/test/monTest.cpp
浏览文件 @
21af31f4
...
@@ -13,21 +13,262 @@
...
@@ -13,21 +13,262 @@
#include "os.h"
#include "os.h"
#include "monitor.h"
#include "monitor.h"
#include "tglobal.h"
class
MonitorTest
:
public
::
testing
::
Test
{
class
MonitorTest
:
public
::
testing
::
Test
{
protected:
protected:
static
void
SetUpTestSuite
()
{
root
=
"/tmp/monTest"
;
}
static
void
SetUpTestSuite
()
{
static
void
TearDownTestSuite
()
{}
SMonCfg
cfg
;
cfg
.
maxLogs
=
2
;
cfg
.
port
=
80
;
cfg
.
server
=
"localhost"
;
monInit
(
&
cfg
);
}
static
void
TearDownTestSuite
()
{
monCleanup
();
}
public:
public:
void
SetUp
()
override
{}
void
SetUp
()
override
{}
void
TearDown
()
override
{}
void
TearDown
()
override
{}
static
const
char
*
root
;
void
GetBasicInfo
(
SMonInfo
*
pMonitor
,
SMonBasicInfo
*
pInfo
);
void
GetClusterInfo
(
SMonInfo
*
pMonitor
,
SMonClusterInfo
*
pInfo
);
void
GetVgroupInfo
(
SMonInfo
*
pMonitor
,
SMonVgroupInfo
*
pInfo
);
void
GetGrantInfo
(
SMonInfo
*
pMonitor
,
SMonGrantInfo
*
pInfo
);
void
GetDnodeInfo
(
SMonInfo
*
pMonitor
,
SMonDnodeInfo
*
pInfo
);
void
GetDiskInfo
(
SMonInfo
*
pMonitor
,
SMonDiskInfo
*
pInfo
);
void
AddLogInfo1
();
void
AddLogInfo2
();
};
};
const
char
*
MonitorTest
::
root
;
void
MonitorTest
::
GetBasicInfo
(
SMonInfo
*
pMonitor
,
SMonBasicInfo
*
pInfo
)
{
pInfo
->
dnode_id
=
1
;
strcpy
(
pInfo
->
dnode_ep
,
"localhost"
);
}
void
MonitorTest
::
GetClusterInfo
(
SMonInfo
*
pMonitor
,
SMonClusterInfo
*
pInfo
)
{
strcpy
(
pInfo
->
first_ep
,
"localhost:6030"
);
pInfo
->
first_ep_dnode_id
=
1
;
strcpy
(
pInfo
->
version
,
"3.0.0.0"
);
pInfo
->
master_uptime
=
1
;
pInfo
->
monitor_interval
=
2
;
pInfo
->
vgroups_total
=
3
;
pInfo
->
vgroups_alive
=
43
;
pInfo
->
vnodes_total
=
5
;
pInfo
->
vnodes_alive
=
6
;
pInfo
->
connections_total
=
7
;
pInfo
->
dnodes
=
taosArrayInit
(
4
,
sizeof
(
SMonDnodeDesc
));
SMonDnodeDesc
d1
=
{
0
};
d1
.
dnode_id
=
1
;
strcpy
(
d1
.
dnode_ep
,
"localhost:6030"
);
strcpy
(
d1
.
status
,
"ready"
);
taosArrayPush
(
pInfo
->
dnodes
,
&
d1
);
SMonDnodeDesc
d2
=
{
0
};
d2
.
dnode_id
=
2
;
strcpy
(
d2
.
dnode_ep
,
"localhost:7030"
);
strcpy
(
d2
.
status
,
"offline"
);
taosArrayPush
(
pInfo
->
dnodes
,
&
d2
);
pInfo
->
mnodes
=
taosArrayInit
(
4
,
sizeof
(
SMonMnodeDesc
));
SMonMnodeDesc
m1
=
{
0
};
m1
.
mnode_id
=
1
;
strcpy
(
m1
.
mnode_ep
,
"localhost:6030"
);
strcpy
(
m1
.
role
,
"master"
);
taosArrayPush
(
pInfo
->
mnodes
,
&
m1
);
SMonMnodeDesc
m2
=
{
0
};
m2
.
mnode_id
=
2
;
strcpy
(
m2
.
mnode_ep
,
"localhost:7030"
);
strcpy
(
m2
.
role
,
"unsynced"
);
taosArrayPush
(
pInfo
->
mnodes
,
&
m2
);
}
void
MonitorTest
::
GetVgroupInfo
(
SMonInfo
*
pMonitor
,
SMonVgroupInfo
*
pInfo
)
{
pInfo
->
vgroups
=
taosArrayInit
(
4
,
sizeof
(
SMonVgroupDesc
));
SMonVgroupDesc
vg1
=
{
0
};
vg1
.
vgroup_id
=
1
;
strcpy
(
vg1
.
database_name
,
"d1"
);
vg1
.
tables_num
=
4
;
strcpy
(
vg1
.
status
,
"ready"
);
vg1
.
vnodes
[
0
].
dnode_id
=
1
;
strcpy
(
vg1
.
vnodes
[
0
].
vnode_role
,
"master"
);
vg1
.
vnodes
[
1
].
dnode_id
=
2
;
strcpy
(
vg1
.
vnodes
[
1
].
vnode_role
,
"slave"
);
taosArrayPush
(
pInfo
->
vgroups
,
&
vg1
);
SMonVgroupDesc
vg2
=
{
0
};
vg2
.
vgroup_id
=
2
;
strcpy
(
vg2
.
database_name
,
"d2"
);
vg2
.
tables_num
=
5
;
strcpy
(
vg2
.
status
,
"offline"
);
vg2
.
vnodes
[
0
].
dnode_id
=
1
;
strcpy
(
vg2
.
vnodes
[
0
].
vnode_role
,
"master"
);
vg2
.
vnodes
[
1
].
dnode_id
=
2
;
strcpy
(
vg2
.
vnodes
[
1
].
vnode_role
,
"unsynced"
);
taosArrayPush
(
pInfo
->
vgroups
,
&
vg2
);
SMonVgroupDesc
vg3
=
{
0
};
vg3
.
vgroup_id
=
3
;
strcpy
(
vg3
.
database_name
,
"d3"
);
vg3
.
tables_num
=
6
;
strcpy
(
vg3
.
status
,
"ready"
);
vg3
.
vnodes
[
0
].
dnode_id
=
1
;
strcpy
(
vg3
.
vnodes
[
0
].
vnode_role
,
"master"
);
taosArrayPush
(
pInfo
->
vgroups
,
&
vg3
);
}
void
MonitorTest
::
GetGrantInfo
(
SMonInfo
*
pMonitor
,
SMonGrantInfo
*
pInfo
)
{
pInfo
->
expire_time
=
1234567
;
pInfo
->
timeseries_total
=
234567
;
pInfo
->
timeseries_used
=
34567
;
}
void
MonitorTest
::
GetDnodeInfo
(
SMonInfo
*
pMonitor
,
SMonDnodeInfo
*
pInfo
)
{
pInfo
->
uptime
=
1.2
;
pInfo
->
cpu_engine
=
2.1
;
pInfo
->
cpu_system
=
2.1
;
pInfo
->
cpu_cores
=
2
;
pInfo
->
mem_engine
=
3.1
;
pInfo
->
mem_system
=
3.2
;
pInfo
->
mem_total
=
3.3
;
pInfo
->
disk_engine
=
4.1
;
pInfo
->
disk_used
=
4.2
;
pInfo
->
disk_total
=
4.3
;
pInfo
->
net_in
=
5.1
;
pInfo
->
net_out
=
5.2
;
pInfo
->
io_read
=
6.1
;
pInfo
->
io_write
=
6.2
;
pInfo
->
io_read_disk
=
7.1
;
pInfo
->
io_write_disk
=
7.2
;
pInfo
->
req_select
=
8
;
pInfo
->
req_select_rate
=
8.1
;
pInfo
->
req_insert
=
9
;
pInfo
->
req_insert_success
=
10
;
pInfo
->
req_insert_rate
=
10.1
;
pInfo
->
req_insert_batch
=
11
;
pInfo
->
req_insert_batch_success
=
12
;
pInfo
->
req_insert_batch_rate
=
12.3
;
pInfo
->
errors
=
4
;
pInfo
->
vnodes_num
=
5
;
pInfo
->
masters
=
6
;
pInfo
->
has_mnode
=
1
;
}
void
MonitorTest
::
GetDiskInfo
(
SMonInfo
*
pMonitor
,
SMonDiskInfo
*
pInfo
)
{
pInfo
->
datadirs
=
taosArrayInit
(
2
,
sizeof
(
SMonDiskDesc
));
SMonDiskDesc
d1
=
{
0
};
strcpy
(
d1
.
name
,
"/t1/d1/d"
);
d1
.
level
=
0
;
d1
.
size
.
avail
=
11
;
d1
.
size
.
total
=
12
;
d1
.
size
.
used
=
13
;
taosArrayPush
(
pInfo
->
datadirs
,
&
d1
);
SMonDiskDesc
d2
=
{
0
};
strcpy
(
d2
.
name
,
"/t2d2/d"
);
d2
.
level
=
2
;
d2
.
size
.
avail
=
21
;
d2
.
size
.
total
=
22
;
d2
.
size
.
used
=
23
;
taosArrayPush
(
pInfo
->
datadirs
,
&
d2
);
SMonDiskDesc
d3
=
{
0
};
strcpy
(
d3
.
name
,
"/t3/d3/d"
);
d3
.
level
=
3
;
d3
.
size
.
avail
=
31
;
d3
.
size
.
total
=
32
;
d3
.
size
.
used
=
33
;
taosArrayPush
(
pInfo
->
datadirs
,
&
d3
);
strcpy
(
pInfo
->
logdir
.
name
,
"/log/dir/d"
);
pInfo
->
logdir
.
size
.
avail
=
41
;
pInfo
->
logdir
.
size
.
total
=
42
;
pInfo
->
logdir
.
size
.
used
=
43
;
strcpy
(
pInfo
->
tempdir
.
name
,
"/data/dir/d"
);
pInfo
->
tempdir
.
size
.
avail
=
51
;
pInfo
->
tempdir
.
size
.
total
=
52
;
pInfo
->
tempdir
.
size
.
used
=
53
;
}
void
MonitorTest
::
AddLogInfo1
()
{
SMonLogItem
log1
=
{
0
};
log1
.
ts
=
taosGetTimestampMs
();
log1
.
level
=
1
;
strcpy
(
log1
.
content
,
"1 -------------------------- a"
);
monAddLogItem
(
&
log1
);
SMonLogItem
log2
=
{
0
};
log2
.
ts
=
taosGetTimestampMs
();
log2
.
level
=
1
;
strcpy
(
log2
.
content
,
"1 ------------------------ b"
);
monAddLogItem
(
&
log2
);
SMonLogItem
log3
=
{
0
};
log3
.
ts
=
taosGetTimestampMs
();
log3
.
level
=
1
;
strcpy
(
log3
.
content
,
"1 ------- c"
);
monAddLogItem
(
&
log3
);
}
void
MonitorTest
::
AddLogInfo2
()
{
SMonLogItem
log1
;
log1
.
ts
=
taosGetTimestampMs
();
log1
.
level
=
01
;
strcpy
(
log1
.
content
,
"2 ------- a"
);
monAddLogItem
(
&
log1
);
SMonLogItem
log2
;
log2
.
ts
=
taosGetTimestampMs
();
log2
.
level
=
0
;
strcpy
(
log2
.
content
,
"2 ------- b"
);
monAddLogItem
(
&
log2
);
}
TEST_F
(
MonitorTest
,
01
_Full
)
{
AddLogInfo1
();
SMonInfo
*
pMonitor
=
monCreateMonitorInfo
();
if
(
pMonitor
==
NULL
)
return
;
SMonBasicInfo
basicInfo
=
{
0
};
GetBasicInfo
(
pMonitor
,
&
basicInfo
);
monSetBasicInfo
(
pMonitor
,
&
basicInfo
);
SMonClusterInfo
clusterInfo
=
{
0
};
SMonVgroupInfo
vgroupInfo
=
{
0
};
SMonGrantInfo
grantInfo
=
{
0
};
GetClusterInfo
(
pMonitor
,
&
clusterInfo
);
GetVgroupInfo
(
pMonitor
,
&
vgroupInfo
);
GetGrantInfo
(
pMonitor
,
&
grantInfo
);
monSetClusterInfo
(
pMonitor
,
&
clusterInfo
);
monSetVgroupInfo
(
pMonitor
,
&
vgroupInfo
);
monSetGrantInfo
(
pMonitor
,
&
grantInfo
);
SMonDnodeInfo
dnodeInfo
=
{
0
};
GetDnodeInfo
(
pMonitor
,
&
dnodeInfo
);
monSetDnodeInfo
(
pMonitor
,
&
dnodeInfo
);
SMonDiskInfo
diskInfo
=
{
0
};
GetDiskInfo
(
pMonitor
,
&
diskInfo
);
monSetDiskInfo
(
pMonitor
,
&
diskInfo
);
monSendReport
(
pMonitor
);
monCleanupMonitorInfo
(
pMonitor
);
taosArrayDestroy
(
clusterInfo
.
dnodes
);
taosArrayDestroy
(
clusterInfo
.
mnodes
);
taosArrayDestroy
(
vgroupInfo
.
vgroups
);
taosArrayDestroy
(
diskInfo
.
datadirs
);
}
TEST_F
(
MonitorTest
,
02
_Log
)
{
AddLogInfo2
();
SMonInfo
*
pMonitor
=
monCreateMonitorInfo
();
if
(
pMonitor
==
NULL
)
return
;
TEST_F
(
MonitorTest
,
01
_Open_Close
)
{
monSendReport
(
pMonitor
);
monCleanupMonitorInfo
(
pMonitor
);
}
}
source/libs/nodes/src/nodesCloneFuncs.c
浏览文件 @
21af31f4
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "plannodes.h"
#include "querynodes.h"
#include "querynodes.h"
#include "taos.h"
#include "taos.h"
#include "taoserror.h"
#include "taoserror.h"
...
@@ -157,6 +158,29 @@ static SNode* groupingSetNodeCopy(const SGroupingSetNode* pSrc, SGroupingSetNode
...
@@ -157,6 +158,29 @@ static SNode* groupingSetNodeCopy(const SGroupingSetNode* pSrc, SGroupingSetNode
return
(
SNode
*
)
pDst
;
return
(
SNode
*
)
pDst
;
}
}
static
SNode
*
logicSubplanCopy
(
const
SSubLogicPlan
*
pSrc
,
SSubLogicPlan
*
pDst
)
{
COPY_NODE_FIELD
(
pNode
);
COPY_SCALAR_FIELD
(
subplanType
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
dataBlockDescCopy
(
const
SDataBlockDescNode
*
pSrc
,
SDataBlockDescNode
*
pDst
)
{
COPY_SCALAR_FIELD
(
dataBlockId
);
COPY_NODE_LIST_FIELD
(
pSlots
);
COPY_SCALAR_FIELD
(
resultRowSize
);
COPY_SCALAR_FIELD
(
precision
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
slotDescCopy
(
const
SSlotDescNode
*
pSrc
,
SSlotDescNode
*
pDst
)
{
COPY_SCALAR_FIELD
(
slotId
);
dataTypeCopy
(
&
pSrc
->
dataType
,
&
pDst
->
dataType
);
COPY_SCALAR_FIELD
(
reserve
);
COPY_SCALAR_FIELD
(
output
);
COPY_SCALAR_FIELD
(
tag
);
return
(
SNode
*
)
pDst
;
}
SNodeptr
nodesCloneNode
(
const
SNodeptr
pNode
)
{
SNodeptr
nodesCloneNode
(
const
SNodeptr
pNode
)
{
if
(
NULL
==
pNode
)
{
if
(
NULL
==
pNode
)
{
return
NULL
;
return
NULL
;
...
@@ -187,9 +211,17 @@ SNodeptr nodesCloneNode(const SNodeptr pNode) {
...
@@ -187,9 +211,17 @@ SNodeptr nodesCloneNode(const SNodeptr pNode) {
return
groupingSetNodeCopy
((
const
SGroupingSetNode
*
)
pNode
,
(
SGroupingSetNode
*
)
pDst
);
return
groupingSetNodeCopy
((
const
SGroupingSetNode
*
)
pNode
,
(
SGroupingSetNode
*
)
pDst
);
case
QUERY_NODE_ORDER_BY_EXPR
:
case
QUERY_NODE_ORDER_BY_EXPR
:
case
QUERY_NODE_LIMIT
:
case
QUERY_NODE_LIMIT
:
break
;
case
QUERY_NODE_DATABLOCK_DESC
:
return
dataBlockDescCopy
((
const
SDataBlockDescNode
*
)
pNode
,
(
SDataBlockDescNode
*
)
pDst
);
case
QUERY_NODE_SLOT_DESC
:
return
slotDescCopy
((
const
SSlotDescNode
*
)
pNode
,
(
SSlotDescNode
*
)
pDst
);
case
QUERY_NODE_LOGIC_SUBPLAN
:
return
logicSubplanCopy
((
const
SSubLogicPlan
*
)
pNode
,
(
SSubLogicPlan
*
)
pDst
);
default:
default:
break
;
break
;
}
}
printf
(
"nodesCloneNode unknown node = %s
\n
"
,
nodesNodeName
(
nodeType
(
pNode
)));
return
pDst
;
return
pDst
;
}
}
...
...
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
21af31f4
...
@@ -24,7 +24,7 @@ static int32_t jsonToNode(const SJson* pJson, void* pObj);
...
@@ -24,7 +24,7 @@ static int32_t jsonToNode(const SJson* pJson, void* pObj);
static
int32_t
jsonToNodeObject
(
const
SJson
*
pJson
,
const
char
*
pName
,
SNode
**
pNode
);
static
int32_t
jsonToNodeObject
(
const
SJson
*
pJson
,
const
char
*
pName
,
SNode
**
pNode
);
static
int32_t
makeNodeByJson
(
const
SJson
*
pJson
,
SNode
**
pNode
);
static
int32_t
makeNodeByJson
(
const
SJson
*
pJson
,
SNode
**
pNode
);
static
char
*
n
odeName
(
ENodeType
type
)
{
const
char
*
nodesN
odeName
(
ENodeType
type
)
{
switch
(
type
)
{
switch
(
type
)
{
case
QUERY_NODE_COLUMN
:
case
QUERY_NODE_COLUMN
:
return
"Column"
;
return
"Column"
;
...
@@ -58,20 +58,32 @@ static char* nodeName(ENodeType type) {
...
@@ -58,20 +58,32 @@ static char* nodeName(ENodeType type) {
return
"NodeList"
;
return
"NodeList"
;
case
QUERY_NODE_FILL
:
case
QUERY_NODE_FILL
:
return
"Fill"
;
return
"Fill"
;
case
QUERY_NODE_TARGET
:
return
"Target"
;
case
QUERY_NODE_RAW_EXPR
:
case
QUERY_NODE_RAW_EXPR
:
return
"RawExpr"
;
return
"RawExpr"
;
case
QUERY_NODE_TARGET
:
return
"Target"
;
case
QUERY_NODE_DATABLOCK_DESC
:
case
QUERY_NODE_DATABLOCK_DESC
:
return
"TupleDesc"
;
return
"TupleDesc"
;
case
QUERY_NODE_SLOT_DESC
:
case
QUERY_NODE_SLOT_DESC
:
return
"SlotDesc"
;
return
"SlotDesc"
;
case
QUERY_NODE_COLUMN_DEF
:
return
"ColumnDef"
;
case
QUERY_NODE_SET_OPERATOR
:
case
QUERY_NODE_SET_OPERATOR
:
return
"SetOperator"
;
return
"SetOperator"
;
case
QUERY_NODE_SELECT_STMT
:
case
QUERY_NODE_SELECT_STMT
:
return
"SelectStmt"
;
return
"SelectStmt"
;
case
QUERY_NODE_SHOW_STMT
:
case
QUERY_NODE_VNODE_MODIF_STMT
:
return
"ShowStmt"
;
return
"VnodeModifStmt"
;
case
QUERY_NODE_CREATE_DATABASE_STMT
:
return
"CreateDatabaseStmt"
;
case
QUERY_NODE_CREATE_TABLE_STMT
:
return
"CreateTableStmt"
;
case
QUERY_NODE_USE_DATABASE_STMT
:
return
"UseDatabaseStmt"
;
case
QUERY_NODE_SHOW_DATABASES_STMT
:
return
"ShowDatabaseStmt"
;
case
QUERY_NODE_SHOW_TABLES_STMT
:
return
"ShowTablesStmt"
;
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
return
"LogicScan"
;
return
"LogicScan"
;
case
QUERY_NODE_LOGIC_PLAN_JOIN
:
case
QUERY_NODE_LOGIC_PLAN_JOIN
:
...
@@ -80,16 +92,34 @@ static char* nodeName(ENodeType type) {
...
@@ -80,16 +92,34 @@ static char* nodeName(ENodeType type) {
return
"LogicAgg"
;
return
"LogicAgg"
;
case
QUERY_NODE_LOGIC_PLAN_PROJECT
:
case
QUERY_NODE_LOGIC_PLAN_PROJECT
:
return
"LogicProject"
;
return
"LogicProject"
;
case
QUERY_NODE_LOGIC_PLAN_VNODE_MODIF
:
return
"LogicVnodeModif"
;
case
QUERY_NODE_LOGIC_SUBPLAN
:
return
"LogicSubplan"
;
case
QUERY_NODE_LOGIC_PLAN
:
return
"LogicPlan"
;
case
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN
:
case
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN
:
return
"PhysiTagScan"
;
return
"PhysiTagScan"
;
case
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
:
case
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
:
return
"PhysiTableScan"
;
return
"PhysiTableScan"
;
case
QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN
:
return
"PhysiTableSeqScan"
;
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
:
return
"PhysiSreamScan"
;
case
QUERY_NODE_PHYSICAL_PLAN_PROJECT
:
case
QUERY_NODE_PHYSICAL_PLAN_PROJECT
:
return
"PhysiProject"
;
return
"PhysiProject"
;
case
QUERY_NODE_PHYSICAL_PLAN_JOIN
:
case
QUERY_NODE_PHYSICAL_PLAN_JOIN
:
return
"PhysiJoin"
;
return
"PhysiJoin"
;
case
QUERY_NODE_PHYSICAL_PLAN_AGG
:
case
QUERY_NODE_PHYSICAL_PLAN_AGG
:
return
"PhysiAgg"
;
return
"PhysiAgg"
;
case
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
:
return
"PhysiExchange"
;
case
QUERY_NODE_PHYSICAL_PLAN_SORT
:
return
"PhysiSort"
;
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
return
"PhysiDispatch"
;
case
QUERY_NODE_PHYSICAL_PLAN_INSERT
:
return
"PhysiInsert"
;
case
QUERY_NODE_PHYSICAL_SUBPLAN
:
case
QUERY_NODE_PHYSICAL_SUBPLAN
:
return
"PhysiSubplan"
;
return
"PhysiSubplan"
;
case
QUERY_NODE_PHYSICAL_PLAN
:
case
QUERY_NODE_PHYSICAL_PLAN
:
...
@@ -234,7 +264,7 @@ static const char* jkPhysiPlanChildren = "Children";
...
@@ -234,7 +264,7 @@ static const char* jkPhysiPlanChildren = "Children";
static
int32_t
physicPlanNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
static
int32_t
physicPlanNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SPhysiNode
*
pNode
=
(
const
SPhysiNode
*
)
pObj
;
const
SPhysiNode
*
pNode
=
(
const
SPhysiNode
*
)
pObj
;
int32_t
code
=
tjsonAddObject
(
pJson
,
jkPhysiPlanOutputDataBlockDesc
,
nodeToJson
,
&
pNode
->
o
utputDataBlockDesc
);
int32_t
code
=
tjsonAddObject
(
pJson
,
jkPhysiPlanOutputDataBlockDesc
,
nodeToJson
,
pNode
->
pO
utputDataBlockDesc
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddObject
(
pJson
,
jkPhysiPlanConditions
,
nodeToJson
,
pNode
->
pConditions
);
code
=
tjsonAddObject
(
pJson
,
jkPhysiPlanConditions
,
nodeToJson
,
pNode
->
pConditions
);
}
}
...
@@ -248,7 +278,7 @@ static int32_t physicPlanNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -248,7 +278,7 @@ static int32_t physicPlanNodeToJson(const void* pObj, SJson* pJson) {
static
int32_t
jsonToPhysicPlanNode
(
const
SJson
*
pJson
,
void
*
pObj
)
{
static
int32_t
jsonToPhysicPlanNode
(
const
SJson
*
pJson
,
void
*
pObj
)
{
SPhysiNode
*
pNode
=
(
SPhysiNode
*
)
pObj
;
SPhysiNode
*
pNode
=
(
SPhysiNode
*
)
pObj
;
int32_t
code
=
tjsonToObject
(
pJson
,
jkPhysiPlanOutputDataBlockDesc
,
jsonToNode
,
&
pNode
->
o
utputDataBlockDesc
);
int32_t
code
=
jsonToNodeObject
(
pJson
,
jkPhysiPlanOutputDataBlockDesc
,
(
SNode
**
)
&
pNode
->
pO
utputDataBlockDesc
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkPhysiPlanConditions
,
&
pNode
->
pConditions
);
code
=
jsonToNodeObject
(
pJson
,
jkPhysiPlanConditions
,
&
pNode
->
pConditions
);
}
}
...
@@ -466,6 +496,26 @@ static int32_t jsonToPhysiAggNode(const SJson* pJson, void* pObj) {
...
@@ -466,6 +496,26 @@ static int32_t jsonToPhysiAggNode(const SJson* pJson, void* pObj) {
return
code
;
return
code
;
}
}
static
const
char
*
jkDataSinkInputDataBlockDesc
=
"InputDataBlockDesc"
;
static
int32_t
physicDataSinkNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SDataSinkNode
*
pNode
=
(
const
SDataSinkNode
*
)
pObj
;
return
tjsonAddObject
(
pJson
,
jkDataSinkInputDataBlockDesc
,
nodeToJson
,
pNode
->
pInputDataBlockDesc
);
}
static
int32_t
jsonToPhysicDataSinkNode
(
const
SJson
*
pJson
,
void
*
pObj
)
{
SDataSinkNode
*
pNode
=
(
SDataSinkNode
*
)
pObj
;
return
jsonToNodeObject
(
pJson
,
jkDataSinkInputDataBlockDesc
,
(
SNode
**
)
&
pNode
->
pInputDataBlockDesc
);
}
static
int32_t
physiDispatchNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
return
physicDataSinkNodeToJson
(
pObj
,
pJson
);
}
static
int32_t
jsonToPhysiDispatchNode
(
const
SJson
*
pJson
,
void
*
pObj
)
{
return
jsonToPhysicDataSinkNode
(
pJson
,
pObj
);
}
static
const
char
*
jkSubplanIdQueryId
=
"QueryId"
;
static
const
char
*
jkSubplanIdQueryId
=
"QueryId"
;
static
const
char
*
jkSubplanIdTemplateId
=
"TemplateId"
;
static
const
char
*
jkSubplanIdTemplateId
=
"TemplateId"
;
static
const
char
*
jkSubplanIdSubplanId
=
"SubplanId"
;
static
const
char
*
jkSubplanIdSubplanId
=
"SubplanId"
;
...
@@ -833,41 +883,43 @@ static int32_t valueNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -833,41 +883,43 @@ static int32_t valueNodeToJson(const void* pObj, SJson* pJson) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddBoolToObject
(
pJson
,
jkValueDuration
,
pNode
->
isDuration
);
code
=
tjsonAddBoolToObject
(
pJson
,
jkValueDuration
,
pNode
->
isDuration
);
}
}
switch
(
pNode
->
node
.
resType
.
type
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
case
TSDB_DATA_TYPE_NULL
:
switch
(
pNode
->
node
.
resType
.
type
)
{
break
;
case
TSDB_DATA_TYPE_NULL
:
case
TSDB_DATA_TYPE_BOOL
:
break
;
code
=
tjsonAddIntegerToObject
(
pJson
,
jkValueDuration
,
pNode
->
datum
.
b
);
case
TSDB_DATA_TYPE_BOOL
:
break
;
code
=
tjsonAddIntegerToObject
(
pJson
,
jkValueDatum
,
pNode
->
datum
.
b
);
case
TSDB_DATA_TYPE_TINYINT
:
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDB_DATA_TYPE_BIGINT
:
code
=
tjsonAddIntegerToObject
(
pJson
,
jkValueDuration
,
pNode
->
datum
.
i
);
case
TSDB_DATA_TYPE_TIMESTAMP
:
break
;
code
=
tjsonAddIntegerToObject
(
pJson
,
jkValueDatum
,
pNode
->
datum
.
i
);
case
TSDB_DATA_TYPE_UTINYINT
:
break
;
case
TSDB_DATA_TYPE_USMALLINT
:
case
TSDB_DATA_TYPE_UTINYINT
:
case
TSDB_DATA_TYPE_UINT
:
case
TSDB_DATA_TYPE_USMALLINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
case
TSDB_DATA_TYPE_UINT
:
code
=
tjsonAddIntegerToObject
(
pJson
,
jkValueDuration
,
pNode
->
datum
.
u
);
case
TSDB_DATA_TYPE_UBIGINT
:
break
;
code
=
tjsonAddIntegerToObject
(
pJson
,
jkValueDatum
,
pNode
->
datum
.
u
);
case
TSDB_DATA_TYPE_FLOAT
:
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
case
TSDB_DATA_TYPE_FLOAT
:
code
=
tjsonAddDoubleToObject
(
pJson
,
jkValueDuration
,
pNode
->
datum
.
d
);
case
TSDB_DATA_TYPE_DOUBLE
:
break
;
code
=
tjsonAddDoubleToObject
(
pJson
,
jkValueDatum
,
pNode
->
datum
.
d
);
case
TSDB_DATA_TYPE_BINARY
:
break
;
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_VARBINARY
:
case
TSDB_DATA_TYPE_VARCHAR
:
code
=
tjsonAddStringToObject
(
pJson
,
jkValueLiteral
,
pNode
->
datum
.
p
);
case
TSDB_DATA_TYPE_VARBINARY
:
break
;
code
=
tjsonAddStringToObject
(
pJson
,
jkValueDatum
,
pNode
->
datum
.
p
);
case
TSDB_DATA_TYPE_JSON
:
break
;
case
TSDB_DATA_TYPE_DECIMAL
:
case
TSDB_DATA_TYPE_JSON
:
case
TSDB_DATA_TYPE_BLOB
:
case
TSDB_DATA_TYPE_DECIMAL
:
// todo
case
TSDB_DATA_TYPE_BLOB
:
default:
// todo
break
;
default:
break
;
}
}
}
return
code
;
return
code
;
...
@@ -883,41 +935,43 @@ static int32_t jsonToValueNode(const SJson* pJson, void* pObj) {
...
@@ -883,41 +935,43 @@ static int32_t jsonToValueNode(const SJson* pJson, void* pObj) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetBoolValue
(
pJson
,
jkValueDuration
,
&
pNode
->
isDuration
);
code
=
tjsonGetBoolValue
(
pJson
,
jkValueDuration
,
&
pNode
->
isDuration
);
}
}
switch
(
pNode
->
node
.
resType
.
type
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
case
TSDB_DATA_TYPE_NULL
:
switch
(
pNode
->
node
.
resType
.
type
)
{
break
;
case
TSDB_DATA_TYPE_NULL
:
case
TSDB_DATA_TYPE_BOOL
:
break
;
code
=
tjsonGetBoolValue
(
pJson
,
jkValueDuration
,
&
pNode
->
datum
.
b
);
case
TSDB_DATA_TYPE_BOOL
:
break
;
code
=
tjsonGetBoolValue
(
pJson
,
jkValueDatum
,
&
pNode
->
datum
.
b
);
case
TSDB_DATA_TYPE_TINYINT
:
break
;
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDB_DATA_TYPE_BIGINT
:
code
=
tjsonGetBigIntValue
(
pJson
,
jkValueDuration
,
&
pNode
->
datum
.
i
);
case
TSDB_DATA_TYPE_TIMESTAMP
:
break
;
code
=
tjsonGetBigIntValue
(
pJson
,
jkValueDatum
,
&
pNode
->
datum
.
i
);
case
TSDB_DATA_TYPE_UTINYINT
:
break
;
case
TSDB_DATA_TYPE_USMALLINT
:
case
TSDB_DATA_TYPE_UTINYINT
:
case
TSDB_DATA_TYPE_UINT
:
case
TSDB_DATA_TYPE_USMALLINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
case
TSDB_DATA_TYPE_UINT
:
code
=
tjsonGetUBigIntValue
(
pJson
,
jkValueDuration
,
&
pNode
->
datum
.
u
);
case
TSDB_DATA_TYPE_UBIGINT
:
break
;
code
=
tjsonGetUBigIntValue
(
pJson
,
jkValueDatum
,
&
pNode
->
datum
.
u
);
case
TSDB_DATA_TYPE_FLOAT
:
break
;
case
TSDB_DATA_TYPE_DOUBLE
:
case
TSDB_DATA_TYPE_FLOAT
:
code
=
tjsonGetDoubleValue
(
pJson
,
jkValueDuration
,
&
pNode
->
datum
.
d
);
case
TSDB_DATA_TYPE_DOUBLE
:
break
;
code
=
tjsonGetDoubleValue
(
pJson
,
jkValueDatum
,
&
pNode
->
datum
.
d
);
case
TSDB_DATA_TYPE_BINARY
:
break
;
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_VARBINARY
:
case
TSDB_DATA_TYPE_VARCHAR
:
code
=
tjsonDupStringValue
(
pJson
,
jkValueLiteral
,
&
pNode
->
datum
.
p
);
case
TSDB_DATA_TYPE_VARBINARY
:
break
;
code
=
tjsonDupStringValue
(
pJson
,
jkValueDatum
,
&
pNode
->
datum
.
p
);
case
TSDB_DATA_TYPE_JSON
:
break
;
case
TSDB_DATA_TYPE_DECIMAL
:
case
TSDB_DATA_TYPE_JSON
:
case
TSDB_DATA_TYPE_BLOB
:
case
TSDB_DATA_TYPE_DECIMAL
:
// todo
case
TSDB_DATA_TYPE_BLOB
:
default:
// todo
break
;
default:
break
;
}
}
}
return
code
;
return
code
;
...
@@ -1249,23 +1303,29 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -1249,23 +1303,29 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
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
:
break
;
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
:
case
QUERY_NODE_RAW_EXPR
:
break
;
break
;
case
QUERY_NODE_TARGET
:
case
QUERY_NODE_TARGET
:
return
targetNodeToJson
(
pObj
,
pJson
);
return
targetNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_RAW_EXPR
:
break
;
case
QUERY_NODE_DATABLOCK_DESC
:
case
QUERY_NODE_DATABLOCK_DESC
:
return
dataBlockDescNodeToJson
(
pObj
,
pJson
);
return
dataBlockDescNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_SLOT_DESC
:
case
QUERY_NODE_SLOT_DESC
:
return
slotDescNodeToJson
(
pObj
,
pJson
);
return
slotDescNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_COLUMN_DEF
:
case
QUERY_NODE_SET_OPERATOR
:
case
QUERY_NODE_SET_OPERATOR
:
break
;
break
;
case
QUERY_NODE_SELECT_STMT
:
case
QUERY_NODE_SELECT_STMT
:
return
selectStmtTojson
(
pObj
,
pJson
);
return
selectStmtTojson
(
pObj
,
pJson
);
case
QUERY_NODE_SHOW_STMT
:
case
QUERY_NODE_VNODE_MODIF_STMT
:
case
QUERY_NODE_CREATE_DATABASE_STMT
:
case
QUERY_NODE_CREATE_TABLE_STMT
:
case
QUERY_NODE_USE_DATABASE_STMT
:
case
QUERY_NODE_SHOW_DATABASES_STMT
:
case
QUERY_NODE_SHOW_TABLES_STMT
:
break
;
break
;
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
return
logicScanNodeToJson
(
pObj
,
pJson
);
return
logicScanNodeToJson
(
pObj
,
pJson
);
...
@@ -1275,16 +1335,29 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -1275,16 +1335,29 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
return
logicAggNodeToJson
(
pObj
,
pJson
);
return
logicAggNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_LOGIC_PLAN_PROJECT
:
case
QUERY_NODE_LOGIC_PLAN_PROJECT
:
return
logicProjectNodeToJson
(
pObj
,
pJson
);
return
logicProjectNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_LOGIC_PLAN_VNODE_MODIF
:
case
QUERY_NODE_LOGIC_SUBPLAN
:
case
QUERY_NODE_LOGIC_PLAN
:
break
;
case
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN
:
case
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN
:
return
physiTagScanNodeToJson
(
pObj
,
pJson
);
return
physiTagScanNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
:
case
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
:
return
physiTableScanNodeToJson
(
pObj
,
pJson
);
return
physiTableScanNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
:
break
;
case
QUERY_NODE_PHYSICAL_PLAN_PROJECT
:
case
QUERY_NODE_PHYSICAL_PLAN_PROJECT
:
return
physiProjectNodeToJson
(
pObj
,
pJson
);
return
physiProjectNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_PHYSICAL_PLAN_JOIN
:
case
QUERY_NODE_PHYSICAL_PLAN_JOIN
:
return
physiJoinNodeToJson
(
pObj
,
pJson
);
return
physiJoinNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_PHYSICAL_PLAN_AGG
:
case
QUERY_NODE_PHYSICAL_PLAN_AGG
:
return
physiAggNodeToJson
(
pObj
,
pJson
);
return
physiAggNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
:
case
QUERY_NODE_PHYSICAL_PLAN_SORT
:
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
return
physiDispatchNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_PHYSICAL_PLAN_INSERT
:
break
;
case
QUERY_NODE_PHYSICAL_SUBPLAN
:
case
QUERY_NODE_PHYSICAL_SUBPLAN
:
return
subplanToJson
(
pObj
,
pJson
);
return
subplanToJson
(
pObj
,
pJson
);
case
QUERY_NODE_PHYSICAL_PLAN
:
case
QUERY_NODE_PHYSICAL_PLAN
:
...
@@ -1292,7 +1365,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -1292,7 +1365,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
default:
default:
break
;
break
;
}
}
printf
(
"================================ specificNodeToJson unknown node = %s
\n
"
,
nodeName
(
nodeType
(
pObj
)));
printf
(
"================================ specificNodeToJson unknown node = %s
\n
"
,
node
sNode
Name
(
nodeType
(
pObj
)));
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -1334,8 +1407,6 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
...
@@ -1334,8 +1407,6 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
// break;
// break;
// case QUERY_NODE_SELECT_STMT:
// case QUERY_NODE_SELECT_STMT:
// return jsonToSelectStmt(pJson, pObj);
// return jsonToSelectStmt(pJson, pObj);
// case QUERY_NODE_SHOW_STMT:
// break;
// case QUERY_NODE_LOGIC_PLAN_SCAN:
// case QUERY_NODE_LOGIC_PLAN_SCAN:
// return jsonToLogicScanNode(pJson, pObj);
// return jsonToLogicScanNode(pJson, pObj);
// case QUERY_NODE_LOGIC_PLAN_JOIN:
// case QUERY_NODE_LOGIC_PLAN_JOIN:
...
@@ -1354,6 +1425,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
...
@@ -1354,6 +1425,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
return
jsonToPhysiJoinNode
(
pJson
,
pObj
);
return
jsonToPhysiJoinNode
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_PLAN_AGG
:
case
QUERY_NODE_PHYSICAL_PLAN_AGG
:
return
jsonToPhysiAggNode
(
pJson
,
pObj
);
return
jsonToPhysiAggNode
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
return
jsonToPhysiDispatchNode
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_SUBPLAN
:
case
QUERY_NODE_PHYSICAL_SUBPLAN
:
return
jsonToSubplan
(
pJson
,
pObj
);
return
jsonToSubplan
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_PLAN
:
case
QUERY_NODE_PHYSICAL_PLAN
:
...
@@ -1361,6 +1434,7 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
...
@@ -1361,6 +1434,7 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
default:
default:
break
;
break
;
}
}
printf
(
"================================ jsonToSpecificNode unknown node = %s
\n
"
,
nodesNodeName
(
nodeType
(
pObj
)));
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -1372,10 +1446,10 @@ static int32_t nodeToJson(const void* pObj, SJson* pJson) {
...
@@ -1372,10 +1446,10 @@ static int32_t nodeToJson(const void* pObj, SJson* pJson) {
int32_t
code
=
tjsonAddIntegerToObject
(
pJson
,
jkNodeType
,
pNode
->
type
);
int32_t
code
=
tjsonAddIntegerToObject
(
pJson
,
jkNodeType
,
pNode
->
type
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddStringToObject
(
pJson
,
jkNodeName
,
nodeName
(
pNode
->
type
));
code
=
tjsonAddStringToObject
(
pJson
,
jkNodeName
,
node
sNode
Name
(
pNode
->
type
));
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddObject
(
pJson
,
nodeName
(
pNode
->
type
),
specificNodeToJson
,
pNode
);
code
=
tjsonAddObject
(
pJson
,
node
sNode
Name
(
pNode
->
type
),
specificNodeToJson
,
pNode
);
}
}
return
code
;
return
code
;
...
@@ -1388,7 +1462,10 @@ static int32_t jsonToNode(const SJson* pJson, void* pObj) {
...
@@ -1388,7 +1462,10 @@ static int32_t jsonToNode(const SJson* pJson, void* pObj) {
int32_t
code
=
tjsonGetIntValue
(
pJson
,
jkNodeType
,
&
val
);
int32_t
code
=
tjsonGetIntValue
(
pJson
,
jkNodeType
,
&
val
);
pNode
->
type
=
val
;
pNode
->
type
=
val
;
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonToObject
(
pJson
,
nodeName
(
pNode
->
type
),
jsonToSpecificNode
,
pNode
);
code
=
tjsonToObject
(
pJson
,
nodesNodeName
(
pNode
->
type
),
jsonToSpecificNode
,
pNode
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
printf
(
"%s toNode error
\n
"
,
nodesNodeName
(
pNode
->
type
));
}
}
}
return
code
;
return
code
;
...
@@ -1411,7 +1488,7 @@ static int32_t makeNodeByJson(const SJson* pJson, SNode** pNode) {
...
@@ -1411,7 +1488,7 @@ static int32_t makeNodeByJson(const SJson* pJson, SNode** pNode) {
static
int32_t
jsonToNodeObject
(
const
SJson
*
pJson
,
const
char
*
pName
,
SNode
**
pNode
)
{
static
int32_t
jsonToNodeObject
(
const
SJson
*
pJson
,
const
char
*
pName
,
SNode
**
pNode
)
{
SJson
*
pJsonNode
=
tjsonGetObjectItem
(
pJson
,
pName
);
SJson
*
pJsonNode
=
tjsonGetObjectItem
(
pJson
,
pName
);
if
(
NULL
==
pJsonNode
)
{
if
(
NULL
==
pJsonNode
)
{
return
TSDB_CODE_
FAILED
;
return
TSDB_CODE_
SUCCESS
;
}
}
return
makeNodeByJson
(
pJsonNode
,
pNode
);
return
makeNodeByJson
(
pJsonNode
,
pNode
);
}
}
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
21af31f4
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "cmdnodes.h"
#include "querynodes.h"
#include "querynodes.h"
#include "plannodes.h"
#include "plannodes.h"
#include "taos.h"
#include "taos.h"
...
@@ -65,12 +66,29 @@ SNodeptr nodesMakeNode(ENodeType type) {
...
@@ -65,12 +66,29 @@ SNodeptr nodesMakeNode(ENodeType type) {
return
makeNode
(
type
,
sizeof
(
SFillNode
));
return
makeNode
(
type
,
sizeof
(
SFillNode
));
case
QUERY_NODE_RAW_EXPR
:
case
QUERY_NODE_RAW_EXPR
:
return
makeNode
(
type
,
sizeof
(
SRawExprNode
));
return
makeNode
(
type
,
sizeof
(
SRawExprNode
));
case
QUERY_NODE_TARGET
:
return
makeNode
(
type
,
sizeof
(
STargetNode
));
case
QUERY_NODE_DATABLOCK_DESC
:
return
makeNode
(
type
,
sizeof
(
SDataBlockDescNode
));
case
QUERY_NODE_SLOT_DESC
:
return
makeNode
(
type
,
sizeof
(
SSlotDescNode
));
case
QUERY_NODE_COLUMN_DEF
:
return
makeNode
(
type
,
sizeof
(
SColumnDefNode
));
case
QUERY_NODE_SET_OPERATOR
:
case
QUERY_NODE_SET_OPERATOR
:
return
makeNode
(
type
,
sizeof
(
SSetOperator
));
return
makeNode
(
type
,
sizeof
(
SSetOperator
));
case
QUERY_NODE_SELECT_STMT
:
case
QUERY_NODE_SELECT_STMT
:
return
makeNode
(
type
,
sizeof
(
SSelectStmt
));
return
makeNode
(
type
,
sizeof
(
SSelectStmt
));
// case QUERY_NODE_SHOW_STMT:
case
QUERY_NODE_VNODE_MODIF_STMT
:
// return makeNode(type, sizeof(SShowStmt));
return
makeNode
(
type
,
sizeof
(
SVnodeModifOpStmt
));
case
QUERY_NODE_CREATE_DATABASE_STMT
:
return
makeNode
(
type
,
sizeof
(
SCreateDatabaseStmt
));
case
QUERY_NODE_CREATE_TABLE_STMT
:
return
makeNode
(
type
,
sizeof
(
SCreateTableStmt
));
case
QUERY_NODE_USE_DATABASE_STMT
:
return
makeNode
(
type
,
sizeof
(
SUseDatabaseStmt
));
case
QUERY_NODE_SHOW_DATABASES_STMT
:
case
QUERY_NODE_SHOW_TABLES_STMT
:
return
makeNode
(
type
,
sizeof
(
SNode
));;
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
return
makeNode
(
type
,
sizeof
(
SScanLogicNode
));
return
makeNode
(
type
,
sizeof
(
SScanLogicNode
));
case
QUERY_NODE_LOGIC_PLAN_JOIN
:
case
QUERY_NODE_LOGIC_PLAN_JOIN
:
...
@@ -79,26 +97,34 @@ SNodeptr nodesMakeNode(ENodeType type) {
...
@@ -79,26 +97,34 @@ SNodeptr nodesMakeNode(ENodeType type) {
return
makeNode
(
type
,
sizeof
(
SAggLogicNode
));
return
makeNode
(
type
,
sizeof
(
SAggLogicNode
));
case
QUERY_NODE_LOGIC_PLAN_PROJECT
:
case
QUERY_NODE_LOGIC_PLAN_PROJECT
:
return
makeNode
(
type
,
sizeof
(
SProjectLogicNode
));
return
makeNode
(
type
,
sizeof
(
SProjectLogicNode
));
case
QUERY_NODE_LOGIC_PLAN_VNODE_MODIF
:
return
makeNode
(
type
,
sizeof
(
SVnodeModifLogicNode
));
case
QUERY_NODE_LOGIC_SUBPLAN
:
case
QUERY_NODE_LOGIC_SUBPLAN
:
return
makeNode
(
type
,
sizeof
(
SSubLogicPlan
));
return
makeNode
(
type
,
sizeof
(
SSubLogicPlan
));
case
QUERY_NODE_LOGIC_PLAN
:
case
QUERY_NODE_LOGIC_PLAN
:
return
makeNode
(
type
,
sizeof
(
SQueryLogicPlan
));
return
makeNode
(
type
,
sizeof
(
SQueryLogicPlan
));
case
QUERY_NODE_TARGET
:
return
makeNode
(
type
,
sizeof
(
STargetNode
));
case
QUERY_NODE_DATABLOCK_DESC
:
return
makeNode
(
type
,
sizeof
(
SDataBlockDescNode
));
case
QUERY_NODE_SLOT_DESC
:
return
makeNode
(
type
,
sizeof
(
SSlotDescNode
));
case
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN
:
case
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN
:
return
makeNode
(
type
,
sizeof
(
STagScanPhysiNode
));
return
makeNode
(
type
,
sizeof
(
STagScanPhysiNode
));
case
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
:
case
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
:
return
makeNode
(
type
,
sizeof
(
STableScanPhysiNode
));
return
makeNode
(
type
,
sizeof
(
STableScanPhysiNode
));
case
QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN
:
return
makeNode
(
type
,
sizeof
(
STableSeqScanPhysiNode
));
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
:
return
makeNode
(
type
,
sizeof
(
SNode
));
case
QUERY_NODE_PHYSICAL_PLAN_PROJECT
:
case
QUERY_NODE_PHYSICAL_PLAN_PROJECT
:
return
makeNode
(
type
,
sizeof
(
SProjectPhysiNode
));
return
makeNode
(
type
,
sizeof
(
SProjectPhysiNode
));
case
QUERY_NODE_PHYSICAL_PLAN_JOIN
:
case
QUERY_NODE_PHYSICAL_PLAN_JOIN
:
return
makeNode
(
type
,
sizeof
(
SJoinPhysiNode
));
return
makeNode
(
type
,
sizeof
(
SJoinPhysiNode
));
case
QUERY_NODE_PHYSICAL_PLAN_AGG
:
case
QUERY_NODE_PHYSICAL_PLAN_AGG
:
return
makeNode
(
type
,
sizeof
(
SAggPhysiNode
));
return
makeNode
(
type
,
sizeof
(
SAggPhysiNode
));
case
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
:
return
makeNode
(
type
,
sizeof
(
SExchangePhysiNode
));
case
QUERY_NODE_PHYSICAL_PLAN_SORT
:
return
makeNode
(
type
,
sizeof
(
SNode
));
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
return
makeNode
(
type
,
sizeof
(
SDataDispatcherNode
));
case
QUERY_NODE_PHYSICAL_PLAN_INSERT
:
return
makeNode
(
type
,
sizeof
(
SDataInserterNode
));
case
QUERY_NODE_PHYSICAL_SUBPLAN
:
case
QUERY_NODE_PHYSICAL_SUBPLAN
:
return
makeNode
(
type
,
sizeof
(
SSubplan
));
return
makeNode
(
type
,
sizeof
(
SSubplan
));
case
QUERY_NODE_PHYSICAL_PLAN
:
case
QUERY_NODE_PHYSICAL_PLAN
:
...
@@ -106,6 +132,7 @@ SNodeptr nodesMakeNode(ENodeType type) {
...
@@ -106,6 +132,7 @@ SNodeptr nodesMakeNode(ENodeType type) {
default:
default:
break
;
break
;
}
}
printf
(
"================================ nodesMakeNode unknown node = %s
\n
"
,
nodesNodeName
(
type
));
return
NULL
;
return
NULL
;
}
}
...
@@ -176,6 +203,17 @@ int32_t nodesListAppend(SNodeList* pList, SNodeptr pNode) {
...
@@ -176,6 +203,17 @@ int32_t nodesListAppend(SNodeList* pList, SNodeptr pNode) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
nodesListStrictAppend
(
SNodeList
*
pList
,
SNodeptr
pNode
)
{
if
(
NULL
==
pNode
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
int32_t
code
=
nodesListAppend
(
pList
,
pNode
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
nodesDestroyNode
(
pNode
);
}
return
code
;
}
int32_t
nodesListAppendList
(
SNodeList
*
pTarget
,
SNodeList
*
pSrc
)
{
int32_t
nodesListAppendList
(
SNodeList
*
pTarget
,
SNodeList
*
pSrc
)
{
if
(
NULL
==
pTarget
||
NULL
==
pSrc
)
{
if
(
NULL
==
pTarget
||
NULL
==
pSrc
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
...
source/libs/parser/inc/astCreateFuncs.h
浏览文件 @
21af31f4
...
@@ -116,8 +116,14 @@ typedef enum ETableOptionType {
...
@@ -116,8 +116,14 @@ typedef enum ETableOptionType {
STableOptions
*
createDefaultTableOptions
(
SAstCreateContext
*
pCxt
);
STableOptions
*
createDefaultTableOptions
(
SAstCreateContext
*
pCxt
);
STableOptions
*
setTableOption
(
SAstCreateContext
*
pCxt
,
STableOptions
*
pOptions
,
ETableOptionType
type
,
const
SToken
*
pVal
);
STableOptions
*
setTableOption
(
SAstCreateContext
*
pCxt
,
STableOptions
*
pOptions
,
ETableOptionType
type
,
const
SToken
*
pVal
);
SNode
*
createColumnDefNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pColName
,
SDataType
dataType
,
const
SToken
*
pComment
);
SNode
*
createColumnDefNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pColName
,
SDataType
dataType
,
const
SToken
*
pComment
);
SDataType
createDataType
(
uint8_t
type
);
SDataType
createVarLenDataType
(
uint8_t
type
,
const
SToken
*
pLen
);
SNode
*
createCreateTableStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
STokenPair
*
pFullTableName
,
SNodeList
*
pCols
,
STableOptions
*
pOptions
);
SNode
*
createCreateTableStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
STokenPair
*
pFullTableName
,
SNodeList
*
pCols
,
STableOptions
*
pOptions
);
SNode
*
createUseDatabaseStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDbName
);
SNode
*
createShowStmt
(
SAstCreateContext
*
pCxt
,
ENodeType
type
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/libs/parser/inc/new_sql.y
浏览文件 @
21af31f4
...
@@ -92,22 +92,25 @@ db_options(A) ::= db_options(B) VGROUPS NK_INTEGER(C).
...
@@ -92,22 +92,25 @@ db_options(A) ::= db_options(B) VGROUPS NK_INTEGER(C).
db_options(A) ::= db_options(B) SINGLESTABLE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_SINGLESTABLE, &C); }
db_options(A) ::= db_options(B) SINGLESTABLE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_SINGLESTABLE, &C); }
db_options(A) ::= db_options(B) STREAMMODE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_STREAMMODE, &C); }
db_options(A) ::= db_options(B) STREAMMODE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_STREAMMODE, &C); }
/************************************************ create database *****************************************************/
cmd ::= USE db_name(A). { pCxt->pRootNode = createUseDatabaseStmt(pCxt, &A);}
/************************************************ create table *******************************************************/
/************************************************ create table *******************************************************/
cmd ::= CREATE TABLE exists_opt(A) full_table_name(B)
cmd ::= CREATE TABLE exists_opt(A) full_table_name(B)
NK_LP column_def_list(C) NK_RP table_options(D). { pCxt->pRootNode = createCreateTableStmt(pCxt, A, &B, C, D);}
NK_LP column_def_list(C) NK_RP table_options(D). { pCxt->pRootNode = createCreateTableStmt(pCxt, A, &B, C, D);}
%type full_table_name { STokenPair }
%type full_table_name { STokenPair }
%destructor full_table_name { }
%destructor full_table_name { }
full_table_name(A) ::= NK_ID(B). {
A = { .first = B, .second = nil_token}
; }
full_table_name(A) ::= NK_ID(B). {
STokenPair t = { .first = nil_token, .second = B }; A = t
; }
full_table_name(A) ::= NK_ID(B) NK_DOT NK_ID(C). {
A = { .first = B, .second = C}
; }
full_table_name(A) ::= NK_ID(B) NK_DOT NK_ID(C). {
STokenPair t = { .first = B, .second = C }; A = t
; }
%type column_def_list { SNodeList* }
%type column_def_list { SNodeList* }
%destructor column_def_list { nodesDestroyList($$); }
%destructor column_def_list { nodesDestroyList($$); }
column_def_list(A) ::= column_def(B). { A = createNodeList(pCxt, B); }
column_def_list(A) ::= column_def(B). { A = createNodeList(pCxt, B); }
column_def_list(A) ::= column_def_list(B) NK_COMMA column_def(C). { A = addNodeToList(pCxt, B, C); }
column_def_list(A) ::= column_def_list(B) NK_COMMA column_def(C). { A = addNodeToList(pCxt, B, C); }
column_def(A) ::= column_name(B) type_name(C). { A = createColumnDefNode(pCxt, B, C, NULL); }
column_def(A) ::= column_name(B) type_name(C). { A = createColumnDefNode(pCxt,
&
B, C, NULL); }
column_def(A) ::= column_name(B) type_name(C) COMMENT NK_STRING(D). { A = createColumnDefNode(pCxt, B, C, &D); }
column_def(A) ::= column_name(B) type_name(C) COMMENT NK_STRING(D). { A = createColumnDefNode(pCxt,
&
B, C, &D); }
%type type_name { SDataType }
%type type_name { SDataType }
%destructor type_name { }
%destructor type_name { }
...
@@ -115,6 +118,7 @@ type_name(A) ::= BOOL.
...
@@ -115,6 +118,7 @@ type_name(A) ::= BOOL.
type_name(A) ::= TINYINT. { A = createDataType(TSDB_DATA_TYPE_TINYINT); }
type_name(A) ::= TINYINT. { A = createDataType(TSDB_DATA_TYPE_TINYINT); }
type_name(A) ::= SMALLINT. { A = createDataType(TSDB_DATA_TYPE_SMALLINT); }
type_name(A) ::= SMALLINT. { A = createDataType(TSDB_DATA_TYPE_SMALLINT); }
type_name(A) ::= INT. { A = createDataType(TSDB_DATA_TYPE_INT); }
type_name(A) ::= INT. { A = createDataType(TSDB_DATA_TYPE_INT); }
type_name(A) ::= INTEGER. { A = createDataType(TSDB_DATA_TYPE_INT); }
type_name(A) ::= BIGINT. { A = createDataType(TSDB_DATA_TYPE_BIGINT); }
type_name(A) ::= BIGINT. { A = createDataType(TSDB_DATA_TYPE_BIGINT); }
type_name(A) ::= FLOAT. { A = createDataType(TSDB_DATA_TYPE_FLOAT); }
type_name(A) ::= FLOAT. { A = createDataType(TSDB_DATA_TYPE_FLOAT); }
type_name(A) ::= DOUBLE. { A = createDataType(TSDB_DATA_TYPE_DOUBLE); }
type_name(A) ::= DOUBLE. { A = createDataType(TSDB_DATA_TYPE_DOUBLE); }
...
@@ -134,14 +138,16 @@ type_name(A) ::= DECIMAL.
...
@@ -134,14 +138,16 @@ type_name(A) ::= DECIMAL.
type_name(A) ::= DECIMAL NK_LP NK_INTEGER NK_RP. { A = createDataType(TSDB_DATA_TYPE_DECIMAL); }
type_name(A) ::= DECIMAL NK_LP NK_INTEGER NK_RP. { A = createDataType(TSDB_DATA_TYPE_DECIMAL); }
type_name(A) ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP. { A = createDataType(TSDB_DATA_TYPE_DECIMAL); }
type_name(A) ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP. { A = createDataType(TSDB_DATA_TYPE_DECIMAL); }
%type table_options { S
Databas
eOptions* }
%type table_options { S
Tabl
eOptions* }
%destructor table_options { tfree($$); }
%destructor table_options { tfree($$); }
table_options(A) ::= . { A = createDefaultTableOptions(pCxt);}
table_options(A) ::= . { A = createDefaultTableOptions(pCxt);}
table_options(A) ::= table_options(B) COMMENT NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_COMMENT, &C); }
table_options(A) ::= table_options(B) COMMENT NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_COMMENT, &C); }
table_options(A) ::= table_options(B) KEEP NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_KEEP, &C); }
table_options(A) ::= table_options(B) KEEP NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_KEEP, &C); }
table_options(A) ::= table_options(B) TTL NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_TTL, &C); }
table_options(A) ::= table_options(B) TTL NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_TTL, &C); }
//cmd ::= SHOW DATABASES. { PARSER_TRACE; createShowStmt(pCxt, SHOW_TYPE_DATABASE); }
/************************************************ show ***************************************************************/
cmd ::= SHOW DATABASES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); }
cmd ::= SHOW TABLES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT); }
/************************************************ select *************************************************************/
/************************************************ select *************************************************************/
cmd ::= query_expression(A). { PARSER_TRACE; pCxt->pRootNode = A; }
cmd ::= query_expression(A). { PARSER_TRACE; pCxt->pRootNode = A; }
...
...
source/libs/parser/src/astCreateFuncs.c
浏览文件 @
21af31f4
...
@@ -44,7 +44,7 @@ static SDatabaseOptions* setDbBlocks(SAstCreateContext* pCxt, SDatabaseOptions*
...
@@ -44,7 +44,7 @@ static SDatabaseOptions* setDbBlocks(SAstCreateContext* pCxt, SDatabaseOptions*
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
if
(
val
<
TSDB_MIN_TOTAL_BLOCKS
||
val
>
TSDB_MAX_TOTAL_BLOCKS
)
{
if
(
val
<
TSDB_MIN_TOTAL_BLOCKS
||
val
>
TSDB_MAX_TOTAL_BLOCKS
)
{
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
"invalid db option totalBlocks: %"
PRId64
" valid range: [%d, %d]"
,
val
,
TSDB_MIN_TOTAL_BLOCKS
,
TSDB_MAX_TOTAL_BLOCKS
);
"invalid db option totalBlocks: %"
PRId64
" valid range: [%d, %d]"
,
val
,
TSDB_MIN_TOTAL_BLOCKS
,
TSDB_MAX_TOTAL_BLOCKS
);
pCxt
->
valid
=
false
;
pCxt
->
valid
=
false
;
return
pOptions
;
return
pOptions
;
}
}
...
@@ -56,7 +56,7 @@ static SDatabaseOptions* setDbCache(SAstCreateContext* pCxt, SDatabaseOptions* p
...
@@ -56,7 +56,7 @@ static SDatabaseOptions* setDbCache(SAstCreateContext* pCxt, SDatabaseOptions* p
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
if
(
val
<
TSDB_MIN_CACHE_BLOCK_SIZE
||
val
>
TSDB_MAX_CACHE_BLOCK_SIZE
)
{
if
(
val
<
TSDB_MIN_CACHE_BLOCK_SIZE
||
val
>
TSDB_MAX_CACHE_BLOCK_SIZE
)
{
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
"invalid db option cacheBlockSize: %"
PRId64
" valid range: [%d, %d]"
,
val
,
TSDB_MIN_CACHE_BLOCK_SIZE
,
TSDB_MAX_CACHE_BLOCK_SIZE
);
"invalid db option cacheBlockSize: %"
PRId64
" valid range: [%d, %d]"
,
val
,
TSDB_MIN_CACHE_BLOCK_SIZE
,
TSDB_MAX_CACHE_BLOCK_SIZE
);
pCxt
->
valid
=
false
;
pCxt
->
valid
=
false
;
return
pOptions
;
return
pOptions
;
}
}
...
@@ -68,7 +68,7 @@ static SDatabaseOptions* setDbCacheLast(SAstCreateContext* pCxt, SDatabaseOption
...
@@ -68,7 +68,7 @@ static SDatabaseOptions* setDbCacheLast(SAstCreateContext* pCxt, SDatabaseOption
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
if
(
val
<
TSDB_MIN_DB_CACHE_LAST_ROW
||
val
>
TSDB_MAX_DB_CACHE_LAST_ROW
)
{
if
(
val
<
TSDB_MIN_DB_CACHE_LAST_ROW
||
val
>
TSDB_MAX_DB_CACHE_LAST_ROW
)
{
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
"invalid db option cacheLast: %"
PRId64
" valid range: [%d, %d]"
,
val
,
TSDB_MIN_DB_CACHE_LAST_ROW
,
TSDB_MAX_DB_CACHE_LAST_ROW
);
"invalid db option cacheLast: %"
PRId64
" valid range: [%d, %d]"
,
val
,
TSDB_MIN_DB_CACHE_LAST_ROW
,
TSDB_MAX_DB_CACHE_LAST_ROW
);
pCxt
->
valid
=
false
;
pCxt
->
valid
=
false
;
return
pOptions
;
return
pOptions
;
}
}
...
@@ -80,7 +80,7 @@ static SDatabaseOptions* setDbComp(SAstCreateContext* pCxt, SDatabaseOptions* pO
...
@@ -80,7 +80,7 @@ static SDatabaseOptions* setDbComp(SAstCreateContext* pCxt, SDatabaseOptions* pO
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
if
(
val
<
TSDB_MIN_COMP_LEVEL
||
val
>
TSDB_MAX_COMP_LEVEL
)
{
if
(
val
<
TSDB_MIN_COMP_LEVEL
||
val
>
TSDB_MAX_COMP_LEVEL
)
{
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
"invalid db option compression: %"
PRId64
" valid range: [%d, %d]"
,
val
,
TSDB_MIN_COMP_LEVEL
,
TSDB_MAX_COMP_LEVEL
);
"invalid db option compression: %"
PRId64
" valid range: [%d, %d]"
,
val
,
TSDB_MIN_COMP_LEVEL
,
TSDB_MAX_COMP_LEVEL
);
pCxt
->
valid
=
false
;
pCxt
->
valid
=
false
;
return
pOptions
;
return
pOptions
;
}
}
...
@@ -92,7 +92,7 @@ static SDatabaseOptions* setDbDays(SAstCreateContext* pCxt, SDatabaseOptions* pO
...
@@ -92,7 +92,7 @@ static SDatabaseOptions* setDbDays(SAstCreateContext* pCxt, SDatabaseOptions* pO
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
if
(
val
<
TSDB_MIN_DAYS_PER_FILE
||
val
>
TSDB_MAX_DAYS_PER_FILE
)
{
if
(
val
<
TSDB_MIN_DAYS_PER_FILE
||
val
>
TSDB_MAX_DAYS_PER_FILE
)
{
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
"invalid db option daysPerFile: %"
PRId64
" valid range: [%d, %d]"
,
val
,
TSDB_MIN_DAYS_PER_FILE
,
TSDB_MAX_DAYS_PER_FILE
);
"invalid db option daysPerFile: %"
PRId64
" valid range: [%d, %d]"
,
val
,
TSDB_MIN_DAYS_PER_FILE
,
TSDB_MAX_DAYS_PER_FILE
);
pCxt
->
valid
=
false
;
pCxt
->
valid
=
false
;
return
pOptions
;
return
pOptions
;
}
}
...
@@ -104,7 +104,7 @@ static SDatabaseOptions* setDbFsync(SAstCreateContext* pCxt, SDatabaseOptions* p
...
@@ -104,7 +104,7 @@ static SDatabaseOptions* setDbFsync(SAstCreateContext* pCxt, SDatabaseOptions* p
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
if
(
val
<
TSDB_MIN_FSYNC_PERIOD
||
val
>
TSDB_MAX_FSYNC_PERIOD
)
{
if
(
val
<
TSDB_MIN_FSYNC_PERIOD
||
val
>
TSDB_MAX_FSYNC_PERIOD
)
{
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
"invalid db option fsyncPeriod: %"
PRId64
" valid range: [%d, %d]"
,
val
,
TSDB_MIN_FSYNC_PERIOD
,
TSDB_MAX_FSYNC_PERIOD
);
"invalid db option fsyncPeriod: %"
PRId64
" valid range: [%d, %d]"
,
val
,
TSDB_MIN_FSYNC_PERIOD
,
TSDB_MAX_FSYNC_PERIOD
);
pCxt
->
valid
=
false
;
pCxt
->
valid
=
false
;
return
pOptions
;
return
pOptions
;
}
}
...
@@ -116,7 +116,7 @@ static SDatabaseOptions* setDbMaxRows(SAstCreateContext* pCxt, SDatabaseOptions*
...
@@ -116,7 +116,7 @@ static SDatabaseOptions* setDbMaxRows(SAstCreateContext* pCxt, SDatabaseOptions*
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
if
(
val
<
TSDB_MIN_MAX_ROW_FBLOCK
||
val
>
TSDB_MAX_MAX_ROW_FBLOCK
)
{
if
(
val
<
TSDB_MIN_MAX_ROW_FBLOCK
||
val
>
TSDB_MAX_MAX_ROW_FBLOCK
)
{
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
"invalid db option maxRowsPerBlock: %"
PRId64
" valid range: [%d, %d]"
,
val
,
TSDB_MIN_MAX_ROW_FBLOCK
,
TSDB_MAX_MAX_ROW_FBLOCK
);
"invalid db option maxRowsPerBlock: %"
PRId64
" valid range: [%d, %d]"
,
val
,
TSDB_MIN_MAX_ROW_FBLOCK
,
TSDB_MAX_MAX_ROW_FBLOCK
);
pCxt
->
valid
=
false
;
pCxt
->
valid
=
false
;
return
pOptions
;
return
pOptions
;
}
}
...
@@ -128,7 +128,7 @@ static SDatabaseOptions* setDbMinRows(SAstCreateContext* pCxt, SDatabaseOptions*
...
@@ -128,7 +128,7 @@ static SDatabaseOptions* setDbMinRows(SAstCreateContext* pCxt, SDatabaseOptions*
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
if
(
val
<
TSDB_MIN_MIN_ROW_FBLOCK
||
val
>
TSDB_MAX_MIN_ROW_FBLOCK
)
{
if
(
val
<
TSDB_MIN_MIN_ROW_FBLOCK
||
val
>
TSDB_MAX_MIN_ROW_FBLOCK
)
{
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
"invalid db option minRowsPerBlock: %"
PRId64
" valid range: [%d, %d]"
,
val
,
TSDB_MIN_MIN_ROW_FBLOCK
,
TSDB_MAX_MIN_ROW_FBLOCK
);
"invalid db option minRowsPerBlock: %"
PRId64
" valid range: [%d, %d]"
,
val
,
TSDB_MIN_MIN_ROW_FBLOCK
,
TSDB_MAX_MIN_ROW_FBLOCK
);
pCxt
->
valid
=
false
;
pCxt
->
valid
=
false
;
return
pOptions
;
return
pOptions
;
}
}
...
@@ -140,7 +140,7 @@ static SDatabaseOptions* setDbKeep(SAstCreateContext* pCxt, SDatabaseOptions* pO
...
@@ -140,7 +140,7 @@ static SDatabaseOptions* setDbKeep(SAstCreateContext* pCxt, SDatabaseOptions* pO
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
if
(
val
<
TSDB_MIN_KEEP
||
val
>
TSDB_MAX_KEEP
)
{
if
(
val
<
TSDB_MIN_KEEP
||
val
>
TSDB_MAX_KEEP
)
{
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
"invalid db option keep: %"
PRId64
" valid range: [%d, %d]"
,
val
,
TSDB_MIN_KEEP
,
TSDB_MAX_KEEP
);
"invalid db option keep: %"
PRId64
" valid range: [%d, %d]"
,
val
,
TSDB_MIN_KEEP
,
TSDB_MAX_KEEP
);
pCxt
->
valid
=
false
;
pCxt
->
valid
=
false
;
return
pOptions
;
return
pOptions
;
}
}
...
@@ -168,7 +168,7 @@ static SDatabaseOptions* setDbQuorum(SAstCreateContext* pCxt, SDatabaseOptions*
...
@@ -168,7 +168,7 @@ static SDatabaseOptions* setDbQuorum(SAstCreateContext* pCxt, SDatabaseOptions*
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
if
(
val
<
TSDB_MIN_DB_QUORUM_OPTION
||
val
>
TSDB_MAX_DB_QUORUM_OPTION
)
{
if
(
val
<
TSDB_MIN_DB_QUORUM_OPTION
||
val
>
TSDB_MAX_DB_QUORUM_OPTION
)
{
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
"invalid db option quorum: %"
PRId64
" valid range: [%d, %d]"
,
val
,
TSDB_MIN_DB_QUORUM_OPTION
,
TSDB_MAX_DB_QUORUM_OPTION
);
"invalid db option quorum: %"
PRId64
" valid range: [%d, %d]"
,
val
,
TSDB_MIN_DB_QUORUM_OPTION
,
TSDB_MAX_DB_QUORUM_OPTION
);
pCxt
->
valid
=
false
;
pCxt
->
valid
=
false
;
return
pOptions
;
return
pOptions
;
}
}
...
@@ -180,7 +180,7 @@ static SDatabaseOptions* setDbReplica(SAstCreateContext* pCxt, SDatabaseOptions*
...
@@ -180,7 +180,7 @@ static SDatabaseOptions* setDbReplica(SAstCreateContext* pCxt, SDatabaseOptions*
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
if
(
val
<
TSDB_MIN_DB_REPLICA_OPTION
||
val
>
TSDB_MAX_DB_REPLICA_OPTION
)
{
if
(
val
<
TSDB_MIN_DB_REPLICA_OPTION
||
val
>
TSDB_MAX_DB_REPLICA_OPTION
)
{
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
"invalid db option replications: %"
PRId64
" valid range: [%d, %d]"
,
val
,
TSDB_MIN_DB_REPLICA_OPTION
,
TSDB_MAX_DB_REPLICA_OPTION
);
"invalid db option replications: %"
PRId64
" valid range: [%d, %d]"
,
val
,
TSDB_MIN_DB_REPLICA_OPTION
,
TSDB_MAX_DB_REPLICA_OPTION
);
pCxt
->
valid
=
false
;
pCxt
->
valid
=
false
;
return
pOptions
;
return
pOptions
;
}
}
...
@@ -192,7 +192,7 @@ static SDatabaseOptions* setDbTtl(SAstCreateContext* pCxt, SDatabaseOptions* pOp
...
@@ -192,7 +192,7 @@ static SDatabaseOptions* setDbTtl(SAstCreateContext* pCxt, SDatabaseOptions* pOp
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
if
(
val
<
TSDB_MIN_DB_TTL_OPTION
)
{
if
(
val
<
TSDB_MIN_DB_TTL_OPTION
)
{
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
"invalid db option ttl: %"
PRId64
", should be greater than or equal to %d"
,
val
,
TSDB_MIN_DB_TTL_OPTION
);
"invalid db option ttl: %"
PRId64
", should be greater than or equal to %d"
,
val
,
TSDB_MIN_DB_TTL_OPTION
);
pCxt
->
valid
=
false
;
pCxt
->
valid
=
false
;
return
pOptions
;
return
pOptions
;
}
}
...
@@ -203,7 +203,7 @@ static SDatabaseOptions* setDbTtl(SAstCreateContext* pCxt, SDatabaseOptions* pOp
...
@@ -203,7 +203,7 @@ static SDatabaseOptions* setDbTtl(SAstCreateContext* pCxt, SDatabaseOptions* pOp
static
SDatabaseOptions
*
setDbWal
(
SAstCreateContext
*
pCxt
,
SDatabaseOptions
*
pOptions
,
const
SToken
*
pVal
)
{
static
SDatabaseOptions
*
setDbWal
(
SAstCreateContext
*
pCxt
,
SDatabaseOptions
*
pOptions
,
const
SToken
*
pVal
)
{
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
if
(
val
<
TSDB_MIN_WAL_LEVEL
||
val
>
TSDB_MAX_WAL_LEVEL
)
{
if
(
val
<
TSDB_MIN_WAL_LEVEL
||
val
>
TSDB_MAX_WAL_LEVEL
)
{
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
"invalid db option walLevel: %"
PRId64
", only 1-2 allowed"
,
val
);
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
"invalid db option walLevel: %"
PRId64
", only 1-2 allowed"
,
val
);
pCxt
->
valid
=
false
;
pCxt
->
valid
=
false
;
return
pOptions
;
return
pOptions
;
}
}
...
@@ -215,7 +215,7 @@ static SDatabaseOptions* setDbVgroups(SAstCreateContext* pCxt, SDatabaseOptions*
...
@@ -215,7 +215,7 @@ static SDatabaseOptions* setDbVgroups(SAstCreateContext* pCxt, SDatabaseOptions*
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
if
(
val
<
TSDB_MIN_VNODES_PER_DB
||
val
>
TSDB_MAX_VNODES_PER_DB
)
{
if
(
val
<
TSDB_MIN_VNODES_PER_DB
||
val
>
TSDB_MAX_VNODES_PER_DB
)
{
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
"invalid db option vgroups: %"
PRId64
" valid range: [%d, %d]"
,
val
,
TSDB_MIN_VNODES_PER_DB
,
TSDB_MAX_VNODES_PER_DB
);
"invalid db option vgroups: %"
PRId64
" valid range: [%d, %d]"
,
val
,
TSDB_MIN_VNODES_PER_DB
,
TSDB_MAX_VNODES_PER_DB
);
pCxt
->
valid
=
false
;
pCxt
->
valid
=
false
;
return
pOptions
;
return
pOptions
;
}
}
...
@@ -226,7 +226,7 @@ static SDatabaseOptions* setDbVgroups(SAstCreateContext* pCxt, SDatabaseOptions*
...
@@ -226,7 +226,7 @@ static SDatabaseOptions* setDbVgroups(SAstCreateContext* pCxt, SDatabaseOptions*
static
SDatabaseOptions
*
setDbSingleStable
(
SAstCreateContext
*
pCxt
,
SDatabaseOptions
*
pOptions
,
const
SToken
*
pVal
)
{
static
SDatabaseOptions
*
setDbSingleStable
(
SAstCreateContext
*
pCxt
,
SDatabaseOptions
*
pOptions
,
const
SToken
*
pVal
)
{
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
if
(
val
<
TSDB_MIN_DB_SINGLE_STABLE_OPTION
||
val
>
TSDB_MAX_DB_SINGLE_STABLE_OPTION
)
{
if
(
val
<
TSDB_MIN_DB_SINGLE_STABLE_OPTION
||
val
>
TSDB_MAX_DB_SINGLE_STABLE_OPTION
)
{
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
"invalid db option singleStable: %"
PRId64
", only 0-1 allowed"
,
val
);
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
"invalid db option singleStable: %"
PRId64
", only 0-1 allowed"
,
val
);
pCxt
->
valid
=
false
;
pCxt
->
valid
=
false
;
return
pOptions
;
return
pOptions
;
}
}
...
@@ -237,7 +237,7 @@ static SDatabaseOptions* setDbSingleStable(SAstCreateContext* pCxt, SDatabaseOpt
...
@@ -237,7 +237,7 @@ static SDatabaseOptions* setDbSingleStable(SAstCreateContext* pCxt, SDatabaseOpt
static
SDatabaseOptions
*
setDbStreamMode
(
SAstCreateContext
*
pCxt
,
SDatabaseOptions
*
pOptions
,
const
SToken
*
pVal
)
{
static
SDatabaseOptions
*
setDbStreamMode
(
SAstCreateContext
*
pCxt
,
SDatabaseOptions
*
pOptions
,
const
SToken
*
pVal
)
{
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
if
(
val
<
TSDB_MIN_DB_STREAM_MODE_OPTION
||
val
>
TSDB_MAX_DB_STREAM_MODE_OPTION
)
{
if
(
val
<
TSDB_MIN_DB_STREAM_MODE_OPTION
||
val
>
TSDB_MAX_DB_STREAM_MODE_OPTION
)
{
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
"invalid db option streamMode: %"
PRId64
", only 0-1 allowed"
,
val
);
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
"invalid db option streamMode: %"
PRId64
", only 0-1 allowed"
,
val
);
pCxt
->
valid
=
false
;
pCxt
->
valid
=
false
;
return
pOptions
;
return
pOptions
;
}
}
...
@@ -269,7 +269,7 @@ static STableOptions* setTableKeep(SAstCreateContext* pCxt, STableOptions* pOpti
...
@@ -269,7 +269,7 @@ static STableOptions* setTableKeep(SAstCreateContext* pCxt, STableOptions* pOpti
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
if
(
val
<
TSDB_MIN_KEEP
||
val
>
TSDB_MAX_KEEP
)
{
if
(
val
<
TSDB_MIN_KEEP
||
val
>
TSDB_MAX_KEEP
)
{
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
"invalid table option keep: %"
PRId64
" valid range: [%d, %d]"
,
val
,
TSDB_MIN_KEEP
,
TSDB_MAX_KEEP
);
"invalid table option keep: %"
PRId64
" valid range: [%d, %d]"
,
val
,
TSDB_MIN_KEEP
,
TSDB_MAX_KEEP
);
pCxt
->
valid
=
false
;
pCxt
->
valid
=
false
;
return
pOptions
;
return
pOptions
;
}
}
...
@@ -281,7 +281,7 @@ static STableOptions* setTableTtl(SAstCreateContext* pCxt, STableOptions* pOptio
...
@@ -281,7 +281,7 @@ static STableOptions* setTableTtl(SAstCreateContext* pCxt, STableOptions* pOptio
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
int64_t
val
=
strtol
(
pVal
->
z
,
NULL
,
10
);
if
(
val
<
TSDB_MIN_DB_TTL_OPTION
)
{
if
(
val
<
TSDB_MIN_DB_TTL_OPTION
)
{
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
snprintf
(
pCxt
->
pQueryCxt
->
pMsg
,
pCxt
->
pQueryCxt
->
msgLen
,
"invalid table option ttl: %"
PRId64
", should be greater than or equal to %d"
,
val
,
TSDB_MIN_DB_TTL_OPTION
);
"invalid table option ttl: %"
PRId64
", should be greater than or equal to %d"
,
val
,
TSDB_MIN_DB_TTL_OPTION
);
pCxt
->
valid
=
false
;
pCxt
->
valid
=
false
;
return
pOptions
;
return
pOptions
;
}
}
...
@@ -714,11 +714,21 @@ SNode* createColumnDefNode(SAstCreateContext* pCxt, const SToken* pColName, SDat
...
@@ -714,11 +714,21 @@ SNode* createColumnDefNode(SAstCreateContext* pCxt, const SToken* pColName, SDat
strncpy
(
pCol
->
colName
,
pColName
->
z
,
pColName
->
n
);
strncpy
(
pCol
->
colName
,
pColName
->
z
,
pColName
->
n
);
pCol
->
dataType
=
dataType
;
pCol
->
dataType
=
dataType
;
if
(
NULL
!=
pComment
)
{
if
(
NULL
!=
pComment
)
{
strncpy
(
pCol
->
co
lName
,
pColName
->
z
,
pColName
->
n
);
strncpy
(
pCol
->
co
mments
,
pComment
->
z
,
pComment
->
n
);
}
}
return
(
SNode
*
)
pCol
;
return
(
SNode
*
)
pCol
;
}
}
SDataType
createDataType
(
uint8_t
type
)
{
SDataType
dt
=
{
.
type
=
type
,
.
precision
=
0
,
.
scale
=
0
,
.
bytes
=
tDataTypes
[
type
].
bytes
};
return
dt
;
}
SDataType
createVarLenDataType
(
uint8_t
type
,
const
SToken
*
pLen
)
{
SDataType
dt
=
{
.
type
=
type
,
.
precision
=
0
,
.
scale
=
0
,
.
bytes
=
tDataTypes
[
type
].
bytes
};
return
dt
;
}
SNode
*
createCreateTableStmt
(
SAstCreateContext
*
pCxt
,
SNode
*
createCreateTableStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
STokenPair
*
pFullTableName
,
SNodeList
*
pCols
,
STableOptions
*
pOptions
)
{
bool
ignoreExists
,
const
STokenPair
*
pFullTableName
,
SNodeList
*
pCols
,
STableOptions
*
pOptions
)
{
SCreateTableStmt
*
pStmt
=
(
SCreateTableStmt
*
)
nodesMakeNode
(
QUERY_NODE_CREATE_TABLE_STMT
);
SCreateTableStmt
*
pStmt
=
(
SCreateTableStmt
*
)
nodesMakeNode
(
QUERY_NODE_CREATE_TABLE_STMT
);
...
@@ -732,3 +742,16 @@ SNode* createCreateTableStmt(SAstCreateContext* pCxt,
...
@@ -732,3 +742,16 @@ SNode* createCreateTableStmt(SAstCreateContext* pCxt,
pStmt
->
options
=
*
pOptions
;
pStmt
->
options
=
*
pOptions
;
return
(
SNode
*
)
pStmt
;
return
(
SNode
*
)
pStmt
;
}
}
SNode
*
createUseDatabaseStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDbName
)
{
SUseDatabaseStmt
*
pStmt
=
(
SUseDatabaseStmt
*
)
nodesMakeNode
(
QUERY_NODE_USE_DATABASE_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
strncpy
(
pStmt
->
dbName
,
pDbName
->
z
,
pDbName
->
n
);
return
(
SNode
*
)
pStmt
;
}
SNode
*
createShowStmt
(
SAstCreateContext
*
pCxt
,
ENodeType
type
)
{
SNode
*
pStmt
=
nodesMakeNode
(
type
);;
CHECK_OUT_OF_MEM
(
pStmt
);
return
pStmt
;
}
source/libs/parser/src/astParse.c
浏览文件 @
21af31f4
...
@@ -26,18 +26,20 @@ extern void NewParse(void*, int, SToken, void*);
...
@@ -26,18 +26,20 @@ extern void NewParse(void*, int, SToken, void*);
extern
void
NewParseFree
(
void
*
,
FFree
);
extern
void
NewParseFree
(
void
*
,
FFree
);
extern
void
NewParseTrace
(
FILE
*
,
char
*
);
extern
void
NewParseTrace
(
FILE
*
,
char
*
);
static
bool
isCmd
(
const
SNode
*
pRootNode
)
{
static
void
setQuery
(
SAstCreateContext
*
pCxt
,
SQuery
*
pQuery
)
{
if
(
NULL
==
pRootNode
)
{
pQuery
->
pRoot
=
pCxt
->
pRootNode
;
return
true
;
ENodeType
type
=
nodeType
(
pCxt
->
pRootNode
);
if
(
QUERY_NODE_SELECT_STMT
==
type
)
{
pQuery
->
haveResultSet
=
true
;
pQuery
->
directRpc
=
false
;
}
else
if
(
QUERY_NODE_CREATE_TABLE_STMT
==
type
)
{
pQuery
->
haveResultSet
=
false
;
pQuery
->
directRpc
=
false
;
}
else
{
pQuery
->
haveResultSet
=
false
;
pQuery
->
directRpc
=
true
;
}
}
switch
(
nodeType
(
pRootNode
))
{
pQuery
->
msgType
=
(
QUERY_NODE_CREATE_TABLE_STMT
==
type
?
TDMT_VND_CREATE_TABLE
:
TDMT_VND_QUERY
);
case
QUERY_NODE_SELECT_STMT
:
case
QUERY_NODE_CREATE_TABLE_STMT
:
return
false
;
default:
break
;
}
return
true
;
}
}
int32_t
doParse
(
SParseContext
*
pParseCxt
,
SQuery
**
pQuery
)
{
int32_t
doParse
(
SParseContext
*
pParseCxt
,
SQuery
**
pQuery
)
{
...
@@ -60,6 +62,10 @@ int32_t doParse(SParseContext* pParseCxt, SQuery** pQuery) {
...
@@ -60,6 +62,10 @@ int32_t doParse(SParseContext* pParseCxt, SQuery** pQuery) {
case
TK_COMMENT
:
{
case
TK_COMMENT
:
{
break
;
break
;
}
}
case
TK_SEMI
:
{
NewParse
(
pParser
,
0
,
t0
,
&
cxt
);
goto
abort_parse
;
}
case
TK_QUESTION
:
case
TK_QUESTION
:
case
TK_ILLEGAL
:
{
case
TK_ILLEGAL
:
{
snprintf
(
cxt
.
pQueryCxt
->
pMsg
,
cxt
.
pQueryCxt
->
msgLen
,
"unrecognized token:
\"
%s
\"
"
,
t0
.
z
);
snprintf
(
cxt
.
pQueryCxt
->
pMsg
,
cxt
.
pQueryCxt
->
msgLen
,
"unrecognized token:
\"
%s
\"
"
,
t0
.
z
);
...
@@ -89,8 +95,7 @@ abort_parse:
...
@@ -89,8 +95,7 @@ abort_parse:
if
(
NULL
==
*
pQuery
)
{
if
(
NULL
==
*
pQuery
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
(
*
pQuery
)
->
isCmd
=
isCmd
(
cxt
.
pRootNode
);
setQuery
(
&
cxt
,
*
pQuery
);
(
*
pQuery
)
->
pRoot
=
cxt
.
pRootNode
;
}
}
return
cxt
.
valid
?
TSDB_CODE_SUCCESS
:
TSDB_CODE_FAILED
;
return
cxt
.
valid
?
TSDB_CODE_SUCCESS
:
TSDB_CODE_FAILED
;
}
}
source/libs/parser/src/astTranslate.c
浏览文件 @
21af31f4
...
@@ -561,6 +561,29 @@ static int32_t checkAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect)
...
@@ -561,6 +561,29 @@ static int32_t checkAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect)
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
setTableVgroupList
(
STranslateContext
*
pCxt
,
SName
*
name
,
SVgroupsInfo
**
pVgList
)
{
SArray
*
vgroupList
=
NULL
;
int32_t
code
=
catalogGetTableDistVgInfo
(
pCxt
->
pParseCxt
->
pCatalog
,
pCxt
->
pParseCxt
->
pTransporter
,
&
(
pCxt
->
pParseCxt
->
mgmtEpSet
),
name
,
&
vgroupList
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
size_t
vgroupNum
=
taosArrayGetSize
(
vgroupList
);
SVgroupsInfo
*
vgList
=
calloc
(
1
,
sizeof
(
SVgroupsInfo
)
+
sizeof
(
SVgroupInfo
)
*
vgroupNum
);
vgList
->
numOfVgroups
=
vgroupNum
;
for
(
int32_t
i
=
0
;
i
<
vgroupNum
;
++
i
)
{
SVgroupInfo
*
vg
=
taosArrayGet
(
vgroupList
,
i
);
vgList
->
vgroups
[
i
]
=
*
vg
;
}
*
pVgList
=
vgList
;
taosArrayDestroy
(
vgroupList
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
translateTable
(
STranslateContext
*
pCxt
,
SNode
*
pTable
)
{
static
int32_t
translateTable
(
STranslateContext
*
pCxt
,
SNode
*
pTable
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
switch
(
nodeType
(
pTable
))
{
switch
(
nodeType
(
pTable
))
{
...
@@ -572,6 +595,10 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
...
@@ -572,6 +595,10 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
generateSyntaxErrMsg
(
pCxt
,
TSDB_CODE_PAR_TABLE_NOT_EXIST
,
pRealTable
->
table
.
tableName
);
return
generateSyntaxErrMsg
(
pCxt
,
TSDB_CODE_PAR_TABLE_NOT_EXIST
,
pRealTable
->
table
.
tableName
);
}
}
code
=
setTableVgroupList
(
pCxt
,
&
name
,
&
(
pRealTable
->
pVgroupList
));
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
code
;
}
code
=
addNamespace
(
pCxt
,
pRealTable
);
code
=
addNamespace
(
pCxt
,
pRealTable
);
break
;
break
;
}
}
...
@@ -829,7 +856,73 @@ static int32_t translateCreateDatabase(STranslateContext* pCxt, SCreateDatabaseS
...
@@ -829,7 +856,73 @@ static int32_t translateCreateDatabase(STranslateContext* pCxt, SCreateDatabaseS
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
translateCreateTable
(
STranslateContext
*
pCxt
,
SCreateTableStmt
*
pStmt
)
{
static
int32_t
translateUseDatabase
(
STranslateContext
*
pCxt
,
SUseDatabaseStmt
*
pStmt
)
{
SName
name
=
{
0
};
tNameSetDbName
(
&
name
,
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
strlen
(
pStmt
->
dbName
));
SUseDbReq
usedbReq
=
{
0
};
tNameExtractFullName
(
&
name
,
usedbReq
.
db
);
pCxt
->
pCmdMsg
=
malloc
(
sizeof
(
SCmdMsgInfo
));
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pCxt
->
pCmdMsg
->
epSet
=
pCxt
->
pParseCxt
->
mgmtEpSet
;
pCxt
->
pCmdMsg
->
msgType
=
TDMT_MND_USE_DB
;
pCxt
->
pCmdMsg
->
msgLen
=
tSerializeSUseDbReq
(
NULL
,
0
,
&
usedbReq
);
pCxt
->
pCmdMsg
->
pMsg
=
malloc
(
pCxt
->
pCmdMsg
->
msgLen
);
if
(
NULL
==
pCxt
->
pCmdMsg
->
pMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
tSerializeSUseDbReq
(
pCxt
->
pCmdMsg
->
pMsg
,
pCxt
->
pCmdMsg
->
msgLen
,
&
usedbReq
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
translateShowDatabases
(
STranslateContext
*
pCxt
)
{
SShowReq
showReq
=
{
.
type
=
TSDB_MGMT_TABLE_DB
};
pCxt
->
pCmdMsg
=
malloc
(
sizeof
(
SCmdMsgInfo
));
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pCxt
->
pCmdMsg
->
epSet
=
pCxt
->
pParseCxt
->
mgmtEpSet
;
pCxt
->
pCmdMsg
->
msgType
=
TDMT_MND_SHOW
;
pCxt
->
pCmdMsg
->
msgLen
=
tSerializeSShowReq
(
NULL
,
0
,
&
showReq
);
pCxt
->
pCmdMsg
->
pMsg
=
malloc
(
pCxt
->
pCmdMsg
->
msgLen
);
if
(
NULL
==
pCxt
->
pCmdMsg
->
pMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
tSerializeSShowReq
(
pCxt
->
pCmdMsg
->
pMsg
,
pCxt
->
pCmdMsg
->
msgLen
,
&
showReq
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
translateShowTables
(
STranslateContext
*
pCxt
)
{
SName
name
=
{
0
};
SVShowTablesReq
*
pShowReq
=
calloc
(
1
,
sizeof
(
SVShowTablesReq
));
tNameSetDbName
(
&
name
,
pCxt
->
pParseCxt
->
acctId
,
pCxt
->
pParseCxt
->
db
,
strlen
(
pCxt
->
pParseCxt
->
db
));
char
dbFname
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
tNameGetFullDbName
(
&
name
,
dbFname
);
SArray
*
array
=
NULL
;
int32_t
code
=
catalogGetDBVgInfo
(
pCxt
->
pParseCxt
->
pCatalog
,
pCxt
->
pParseCxt
->
pTransporter
,
&
pCxt
->
pParseCxt
->
mgmtEpSet
,
dbFname
,
false
,
&
array
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
SVgroupInfo
*
info
=
taosArrayGet
(
array
,
0
);
pShowReq
->
head
.
vgId
=
htonl
(
info
->
vgId
);
pCxt
->
pCmdMsg
=
malloc
(
sizeof
(
SCmdMsgInfo
));
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pCxt
->
pCmdMsg
->
epSet
=
info
->
epset
;
pCxt
->
pCmdMsg
->
msgType
=
TDMT_VND_SHOW_TABLES
;
pCxt
->
pCmdMsg
->
msgLen
=
sizeof
(
SVShowTablesReq
);
pCxt
->
pCmdMsg
->
pMsg
=
pShowReq
;
pCxt
->
pCmdMsg
->
pExtension
=
array
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -842,8 +935,14 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
...
@@ -842,8 +935,14 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
case
QUERY_NODE_CREATE_DATABASE_STMT
:
case
QUERY_NODE_CREATE_DATABASE_STMT
:
code
=
translateCreateDatabase
(
pCxt
,
(
SCreateDatabaseStmt
*
)
pNode
);
code
=
translateCreateDatabase
(
pCxt
,
(
SCreateDatabaseStmt
*
)
pNode
);
break
;
break
;
case
QUERY_NODE_CREATE_TABLE_STMT
:
case
QUERY_NODE_USE_DATABASE_STMT
:
code
=
translateCreateTable
(
pCxt
,
(
SCreateTableStmt
*
)
pNode
);
code
=
translateUseDatabase
(
pCxt
,
(
SUseDatabaseStmt
*
)
pNode
);
break
;
case
QUERY_NODE_SHOW_DATABASES_STMT
:
code
=
translateShowDatabases
(
pCxt
);
break
;
case
QUERY_NODE_SHOW_TABLES_STMT
:
code
=
translateShowTables
(
pCxt
);
break
;
break
;
default:
default:
break
;
break
;
...
@@ -862,7 +961,7 @@ static int32_t translateSubquery(STranslateContext* pCxt, SNode* pNode) {
...
@@ -862,7 +961,7 @@ static int32_t translateSubquery(STranslateContext* pCxt, SNode* pNode) {
return
code
;
return
code
;
}
}
int32_t
setReslutSchema
(
STranslateContext
*
pCxt
,
SQuery
*
pQuery
)
{
static
int32_t
setReslutSchema
(
STranslateContext
*
pCxt
,
SQuery
*
pQuery
)
{
if
(
QUERY_NODE_SELECT_STMT
==
nodeType
(
pQuery
->
pRoot
))
{
if
(
QUERY_NODE_SELECT_STMT
==
nodeType
(
pQuery
->
pRoot
))
{
SSelectStmt
*
pSelect
=
(
SSelectStmt
*
)
pQuery
->
pRoot
;
SSelectStmt
*
pSelect
=
(
SSelectStmt
*
)
pQuery
->
pRoot
;
pQuery
->
numOfResCols
=
LIST_LENGTH
(
pSelect
->
pProjectionList
);
pQuery
->
numOfResCols
=
LIST_LENGTH
(
pSelect
->
pProjectionList
);
...
@@ -882,7 +981,7 @@ int32_t setReslutSchema(STranslateContext* pCxt, SQuery* pQuery) {
...
@@ -882,7 +981,7 @@ int32_t setReslutSchema(STranslateContext* pCxt, SQuery* pQuery) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
void
destroyTranslateContext
(
STranslateContext
*
pCxt
)
{
static
void
destroyTranslateContext
(
STranslateContext
*
pCxt
)
{
taosArrayDestroy
(
pCxt
->
pNsLevel
);
taosArrayDestroy
(
pCxt
->
pNsLevel
);
if
(
NULL
!=
pCxt
->
pCmdMsg
)
{
if
(
NULL
!=
pCxt
->
pCmdMsg
)
{
tfree
(
pCxt
->
pCmdMsg
->
pMsg
);
tfree
(
pCxt
->
pCmdMsg
->
pMsg
);
...
@@ -890,6 +989,122 @@ void destroyTranslateContext(STranslateContext* pCxt) {
...
@@ -890,6 +989,122 @@ void destroyTranslateContext(STranslateContext* pCxt) {
}
}
}
}
typedef
struct
SVgroupTablesBatch
{
SVCreateTbBatchReq
req
;
SVgroupInfo
info
;
}
SVgroupTablesBatch
;
static
void
toSchema
(
const
SColumnDefNode
*
pCol
,
int32_t
colId
,
SSchema
*
pSchema
)
{
pSchema
->
colId
=
colId
;
pSchema
->
type
=
pCol
->
dataType
.
type
;
pSchema
->
bytes
=
pCol
->
dataType
.
bytes
;
strcpy
(
pSchema
->
name
,
pCol
->
colName
);
}
static
int32_t
doBuildSingleTableBatchReq
(
SName
*
pTableName
,
SNodeList
*
pColumns
,
SVgroupInfo
*
pVgroupInfo
,
SVgroupTablesBatch
*
pBatch
)
{
SVCreateTbReq
req
=
{
0
};
req
.
type
=
TD_NORMAL_TABLE
;
req
.
name
=
strdup
(
tNameGetTableName
(
pTableName
));
req
.
ntbCfg
.
nCols
=
LIST_LENGTH
(
pColumns
);
int32_t
num
=
req
.
ntbCfg
.
nCols
;
req
.
ntbCfg
.
pSchema
=
calloc
(
num
,
sizeof
(
SSchema
));
SNode
*
pCol
;
int32_t
index
=
0
;
FOREACH
(
pCol
,
pColumns
)
{
toSchema
((
SColumnDefNode
*
)
pCol
,
index
+
1
,
req
.
ntbCfg
.
pSchema
+
index
);
++
index
;
}
pBatch
->
info
=
*
pVgroupInfo
;
pBatch
->
req
.
pArray
=
taosArrayInit
(
1
,
sizeof
(
struct
SVCreateTbReq
));
if
(
pBatch
->
req
.
pArray
==
NULL
)
{
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
taosArrayPush
(
pBatch
->
req
.
pArray
,
&
req
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
serializeVgroupTablesBatchImpl
(
SVgroupTablesBatch
*
pTbBatch
,
SArray
*
pBufArray
)
{
int
tlen
=
sizeof
(
SMsgHead
)
+
tSerializeSVCreateTbBatchReq
(
NULL
,
&
(
pTbBatch
->
req
));
void
*
buf
=
malloc
(
tlen
);
if
(
buf
==
NULL
)
{
// TODO: handle error
}
((
SMsgHead
*
)
buf
)
->
vgId
=
htonl
(
pTbBatch
->
info
.
vgId
);
((
SMsgHead
*
)
buf
)
->
contLen
=
htonl
(
tlen
);
void
*
pBuf
=
POINTER_SHIFT
(
buf
,
sizeof
(
SMsgHead
));
tSerializeSVCreateTbBatchReq
(
&
pBuf
,
&
(
pTbBatch
->
req
));
SVgDataBlocks
*
pVgData
=
calloc
(
1
,
sizeof
(
SVgDataBlocks
));
pVgData
->
vg
=
pTbBatch
->
info
;
pVgData
->
pData
=
buf
;
pVgData
->
size
=
tlen
;
pVgData
->
numOfTables
=
(
int32_t
)
taosArrayGetSize
(
pTbBatch
->
req
.
pArray
);
taosArrayPush
(
pBufArray
,
&
pVgData
);
}
static
void
destroyCreateTbReqBatch
(
SVgroupTablesBatch
*
pTbBatch
)
{
size_t
size
=
taosArrayGetSize
(
pTbBatch
->
req
.
pArray
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SVCreateTbReq
*
pTableReq
=
taosArrayGet
(
pTbBatch
->
req
.
pArray
,
i
);
tfree
(
pTableReq
->
name
);
if
(
pTableReq
->
type
==
TSDB_NORMAL_TABLE
)
{
tfree
(
pTableReq
->
ntbCfg
.
pSchema
);
}
else
if
(
pTableReq
->
type
==
TSDB_CHILD_TABLE
)
{
tfree
(
pTableReq
->
ctbCfg
.
pTag
);
}
else
{
assert
(
0
);
}
}
taosArrayDestroy
(
pTbBatch
->
req
.
pArray
);
}
static
int32_t
rewriteQuery
(
STranslateContext
*
pCxt
,
SQuery
*
pQuery
)
{
if
(
QUERY_NODE_CREATE_TABLE_STMT
==
nodeType
(
pQuery
->
pRoot
))
{
SCreateTableStmt
*
pStmt
=
(
SCreateTableStmt
*
)
pQuery
->
pRoot
;
SName
tableName
=
{
.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
if
(
'\0'
==
pStmt
->
dbName
[
0
])
{
strcpy
(
tableName
.
dbname
,
pCxt
->
pParseCxt
->
db
);
}
else
{
strcpy
(
tableName
.
dbname
,
pStmt
->
dbName
);
}
strcpy
(
tableName
.
tname
,
pStmt
->
tableName
);
SVgroupInfo
info
=
{
0
};
catalogGetTableHashVgroup
(
pCxt
->
pParseCxt
->
pCatalog
,
pCxt
->
pParseCxt
->
pTransporter
,
&
pCxt
->
pParseCxt
->
mgmtEpSet
,
&
tableName
,
&
info
);
SVgroupTablesBatch
tbatch
=
{
0
};
int32_t
code
=
doBuildSingleTableBatchReq
(
&
tableName
,
pStmt
->
pCols
,
&
info
,
&
tbatch
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
SArray
*
pBufArray
=
taosArrayInit
(
1
,
POINTER_BYTES
);
if
(
pBufArray
==
NULL
)
{
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
serializeVgroupTablesBatchImpl
(
&
tbatch
,
pBufArray
);
destroyCreateTbReqBatch
(
&
tbatch
);
SVnodeModifOpStmt
*
pNewStmt
=
nodesMakeNode
(
QUERY_NODE_VNODE_MODIF_STMT
);
pNewStmt
->
sqlNodeType
=
nodeType
(
pQuery
->
pRoot
);
pNewStmt
->
pDataBlocks
=
pBufArray
;
pQuery
->
sqlNodeType
=
nodeType
(
pQuery
->
pRoot
);
nodesDestroyNode
(
pQuery
->
pRoot
);
pQuery
->
pRoot
=
(
SNode
*
)
pNewStmt
;
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
doTranslate
(
SParseContext
*
pParseCxt
,
SQuery
*
pQuery
)
{
int32_t
doTranslate
(
SParseContext
*
pParseCxt
,
SQuery
*
pQuery
)
{
STranslateContext
cxt
=
{
STranslateContext
cxt
=
{
.
pParseCxt
=
pParseCxt
,
.
pParseCxt
=
pParseCxt
,
...
@@ -900,14 +1115,18 @@ int32_t doTranslate(SParseContext* pParseCxt, SQuery* pQuery) {
...
@@ -900,14 +1115,18 @@ int32_t doTranslate(SParseContext* pParseCxt, SQuery* pQuery) {
.
currClause
=
0
.
currClause
=
0
};
};
int32_t
code
=
fmFuncMgtInit
();
int32_t
code
=
fmFuncMgtInit
();
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
rewriteQuery
(
&
cxt
,
pQuery
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
translateQuery
(
&
cxt
,
pQuery
->
pRoot
);
code
=
translateQuery
(
&
cxt
,
pQuery
->
pRoot
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
pQuery
->
isCmd
)
{
if
(
pQuery
->
directRpc
)
{
pQuery
->
pCmdMsg
=
cxt
.
pCmdMsg
;
pQuery
->
pCmdMsg
=
cxt
.
pCmdMsg
;
cxt
.
pCmdMsg
=
NULL
;
cxt
.
pCmdMsg
=
NULL
;
}
else
{
}
if
(
pQuery
->
haveResultSet
)
{
code
=
setReslutSchema
(
&
cxt
,
pQuery
);
code
=
setReslutSchema
(
&
cxt
,
pQuery
);
}
}
}
}
...
...
source/libs/parser/src/insertParser.c
浏览文件 @
21af31f4
...
@@ -159,12 +159,9 @@ static int32_t createSName(SName* pName, SToken* pTableName, SParseContext* pPar
...
@@ -159,12 +159,9 @@ static int32_t createSName(SName* pName, SToken* pTableName, SParseContext* pPar
}
}
static
int32_t
getTableMeta
(
SInsertParseContext
*
pCxt
,
SToken
*
pTname
)
{
static
int32_t
getTableMeta
(
SInsertParseContext
*
pCxt
,
SToken
*
pTname
)
{
SName
name
=
{
0
};
createSName
(
&
name
,
pTname
,
pCxt
->
pComCxt
,
&
pCxt
->
msg
);
char
tableName
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
tNameExtractFullName
(
&
name
,
tableName
);
SParseContext
*
pBasicCtx
=
pCxt
->
pComCxt
;
SParseContext
*
pBasicCtx
=
pCxt
->
pComCxt
;
SName
name
=
{
0
};
createSName
(
&
name
,
pTname
,
pBasicCtx
,
&
pCxt
->
msg
);
CHECK_CODE
(
catalogGetTableMeta
(
pBasicCtx
->
pCatalog
,
pBasicCtx
->
pTransporter
,
&
pBasicCtx
->
mgmtEpSet
,
&
name
,
&
pCxt
->
pTableMeta
));
CHECK_CODE
(
catalogGetTableMeta
(
pBasicCtx
->
pCatalog
,
pBasicCtx
->
pTransporter
,
&
pBasicCtx
->
mgmtEpSet
,
&
name
,
&
pCxt
->
pTableMeta
));
SVgroupInfo
vg
;
SVgroupInfo
vg
;
CHECK_CODE
(
catalogGetTableHashVgroup
(
pBasicCtx
->
pCatalog
,
pBasicCtx
->
pTransporter
,
&
pBasicCtx
->
mgmtEpSet
,
&
name
,
&
vg
));
CHECK_CODE
(
catalogGetTableHashVgroup
(
pBasicCtx
->
pCatalog
,
pBasicCtx
->
pTransporter
,
&
pBasicCtx
->
mgmtEpSet
,
&
name
,
&
vg
));
...
@@ -939,6 +936,13 @@ int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery) {
...
@@ -939,6 +936,13 @@ int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery) {
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
}
*
pQuery
=
calloc
(
1
,
sizeof
(
SQuery
));
if
(
NULL
==
*
pQuery
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
(
*
pQuery
)
->
directRpc
=
false
;
(
*
pQuery
)
->
haveResultSet
=
false
;
(
*
pQuery
)
->
msgType
=
TDMT_VND_SUBMIT
;
(
*
pQuery
)
->
pRoot
=
(
SNode
*
)
context
.
pOutput
;
(
*
pQuery
)
->
pRoot
=
(
SNode
*
)
context
.
pOutput
;
context
.
pOutput
->
payloadType
=
PAYLOAD_TYPE_KV
;
context
.
pOutput
->
payloadType
=
PAYLOAD_TYPE_KV
;
...
...
source/libs/parser/src/new_sql.c
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/parser/src/ttokenizer.c
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/parser/test/mockCatalog.cpp
浏览文件 @
21af31f4
...
@@ -13,19 +13,17 @@
...
@@ -13,19 +13,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "mockCatalog.h"
#include <iostream>
#include <iostream>
#include "stub.h"
#include "stub.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat"
#pragma GCC diagnostic ignored "-Wformat"
#include
"addr_any.h"
#include
<addr_any.h>
#pragma GCC diagnostic pop
#pragma GCC diagnostic pop
#include "mockCatalog.h"
namespace
{
namespace
{
void
generateTestT1
(
MockCatalogService
*
mcs
)
{
void
generateTestT1
(
MockCatalogService
*
mcs
)
{
...
@@ -60,6 +58,10 @@ int32_t __catalogGetTableHashVgroup(struct SCatalog* pCatalog, void *pRpc, const
...
@@ -60,6 +58,10 @@ int32_t __catalogGetTableHashVgroup(struct SCatalog* pCatalog, void *pRpc, const
return
mockCatalogService
->
catalogGetTableHashVgroup
(
pTableName
,
vgInfo
);
return
mockCatalogService
->
catalogGetTableHashVgroup
(
pTableName
,
vgInfo
);
}
}
int32_t
__catalogGetTableDistVgInfo
(
SCatalog
*
pCtg
,
void
*
pRpc
,
const
SEpSet
*
pMgmtEps
,
const
SName
*
pTableName
,
SArray
**
pVgList
)
{
return
mockCatalogService
->
catalogGetTableDistVgInfo
(
pTableName
,
pVgList
);
}
void
initMetaDataEnv
()
{
void
initMetaDataEnv
()
{
mockCatalogService
.
reset
(
new
MockCatalogService
());
mockCatalogService
.
reset
(
new
MockCatalogService
());
...
@@ -67,6 +69,8 @@ void initMetaDataEnv() {
...
@@ -67,6 +69,8 @@ void initMetaDataEnv() {
stub
.
set
(
catalogGetHandle
,
__catalogGetHandle
);
stub
.
set
(
catalogGetHandle
,
__catalogGetHandle
);
stub
.
set
(
catalogGetTableMeta
,
__catalogGetTableMeta
);
stub
.
set
(
catalogGetTableMeta
,
__catalogGetTableMeta
);
stub
.
set
(
catalogGetTableHashVgroup
,
__catalogGetTableHashVgroup
);
stub
.
set
(
catalogGetTableHashVgroup
,
__catalogGetTableHashVgroup
);
stub
.
set
(
catalogGetTableDistVgInfo
,
__catalogGetTableDistVgInfo
);
{
{
AddrAny
any
(
"libcatalog.so"
);
AddrAny
any
(
"libcatalog.so"
);
std
::
map
<
std
::
string
,
void
*>
result
;
std
::
map
<
std
::
string
,
void
*>
result
;
...
...
source/libs/parser/test/mockCatalogService.cpp
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/parser/test/mockCatalogService.h
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/parser/test/parserTest.cpp
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/planner/inc/plannerInt.h
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/planner/src/logicPlan.c
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/planner/src/physicalPlan.c
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/planner/src/planner.c
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/planner/test/plannerTest.cpp
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/qworker/test/qworkerTests.cpp
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/scalar/test/filter/filterTests.cpp
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/scalar/test/scalar/scalarTests.cpp
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/scheduler/test/schedulerTests.cpp
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/sync/inc/syncInt.h
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/sync/inc/syncMessage.h
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/sync/inc/syncVoteMgr.h
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/sync/src/syncIO.c
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/sync/src/syncMain.c
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/sync/src/syncMessage.c
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/sync/test/syncEncodeTest.cpp
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/sync/test/syncIOSendMsgClientTest.cpp
浏览文件 @
21af31f4
#include <stdio.h>
#include <stdio.h>
#include
"gtest/gtest.h"
#include
<gtest/gtest.h>
#include "syncIO.h"
#include "syncIO.h"
#include "syncInt.h"
#include "syncInt.h"
#include "syncRaftStore.h"
#include "syncRaftStore.h"
...
...
source/libs/sync/test/syncIOSendMsgServerTest.cpp
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/sync/test/syncIOSendMsgTest.cpp
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/sync/test/syncIOTickPingTest.cpp
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/sync/test/syncIOTickQTest.cpp
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/sync/test/syncPingTest.cpp
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/sync/test/syncRaftStoreTest.cpp
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/sync/test/syncTest.cpp
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/tdb/src/db/tdb.c
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/tdb/src/db/tdbUtil.c
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/tdb/src/inc/tdbUtil.h
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/tdb/test/tdbTest.cpp
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/tfs/CMakeLists.txt
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/tfs/src/tfs.c
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/tfs/test/tfsTest.cpp
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/transport/src/transSrv.c
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/libs/wal/src/walMeta.c
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/os/src/osDir.c
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/os/src/osEnv.c
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/os/src/osFile.c
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/os/src/osSysinfo.c
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/util/src/tjson.c
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/util/test/cacheTest.cpp
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/util/test/encodeTest.cpp
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/util/test/freelistTest.cpp
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
source/util/test/hashTest.cpp
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
tools/shell/src/backup/shellImport.c
浏览文件 @
21af31f4
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录