Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
29fab2e3
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
29fab2e3
编写于
3月 05, 2022
作者:
M
Minghao Li
浏览文件
操作
浏览文件
下载
差异文件
Merge branch '3.0' of
https://github.com/taosdata/TDengine
into feature/3.0_mhli
上级
b7e22154
9f33b3ea
变更
150
展开全部
隐藏空白更改
内联
并排
Showing
150 changed file
with
4079 addition
and
2624 deletion
+4079
-2624
contrib/test/craft/CMakeLists.txt
contrib/test/craft/CMakeLists.txt
+1
-1
contrib/test/traft/single_node/CMakeLists.txt
contrib/test/traft/single_node/CMakeLists.txt
+1
-1
include/common/tcommon.h
include/common/tcommon.h
+3
-20
include/common/tdatablock.h
include/common/tdatablock.h
+0
-0
include/common/tmsg.h
include/common/tmsg.h
+1
-1
include/libs/executor/executor.h
include/libs/executor/executor.h
+0
-19
include/libs/monitor/monitor.h
include/libs/monitor/monitor.h
+17
-22
include/libs/qcom/query.h
include/libs/qcom/query.h
+7
-9
include/libs/scalar/filter.h
include/libs/scalar/filter.h
+3
-2
include/libs/sync/sync.h
include/libs/sync/sync.h
+1
-1
include/libs/tfs/tfs.h
include/libs/tfs/tfs.h
+9
-0
include/libs/wal/wal.h
include/libs/wal/wal.h
+30
-32
include/os/os.h
include/os/os.h
+1
-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
+22
-8
include/os/osSysinfo.h
include/os/osSysinfo.h
+12
-12
include/util/tcache.h
include/util/tcache.h
+17
-50
include/util/thash.h
include/util/thash.h
+27
-78
include/util/tlog.h
include/util/tlog.h
+32
-24
include/util/tpagedbuf.h
include/util/tpagedbuf.h
+1
-1
source/client/inc/clientInt.h
source/client/inc/clientInt.h
+14
-18
source/client/inc/clientLog.h
source/client/inc/clientLog.h
+7
-7
source/client/src/clientHb.c
source/client/src/clientHb.c
+24
-16
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+1
-1
source/client/src/tmq.c
source/client/src/tmq.c
+263
-115
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+1
-1
source/common/src/tglobal.c
source/common/src/tglobal.c
+45
-35
source/common/src/ttszip.c
source/common/src/ttszip.c
+2
-2
source/common/test/commonTests.cpp
source/common/test/commonTests.cpp
+3
-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
-3
source/dnode/mgmt/impl/inc/dndInt.h
source/dnode/mgmt/impl/inc/dndInt.h
+9
-11
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
+8
-1
source/dnode/mgmt/impl/src/dndMgmt.c
source/dnode/mgmt/impl/src/dndMgmt.c
+36
-10
source/dnode/mgmt/impl/src/dndMnode.c
source/dnode/mgmt/impl/src/dndMnode.c
+7
-0
source/dnode/mgmt/impl/src/dndVnodes.c
source/dnode/mgmt/impl/src/dndVnodes.c
+8
-1
source/dnode/mgmt/impl/test/sut/src/client.cpp
source/dnode/mgmt/impl/test/sut/src/client.cpp
+1
-1
source/dnode/mgmt/impl/test/sut/src/sut.cpp
source/dnode/mgmt/impl/test/sut/src/sut.cpp
+1
-1
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+0
-40
source/dnode/mnode/impl/inc/mndInt.h
source/dnode/mnode/impl/inc/mndInt.h
+15
-2
source/dnode/mnode/impl/inc/mndProfile.h
source/dnode/mnode/impl/inc/mndProfile.h
+1
-0
source/dnode/mnode/impl/src/mndMnode.c
source/dnode/mnode/impl/src/mndMnode.c
+4
-0
source/dnode/mnode/impl/src/mndProfile.c
source/dnode/mnode/impl/src/mndProfile.c
+41
-29
source/dnode/mnode/impl/src/mndTelem.c
source/dnode/mnode/impl/src/mndTelem.c
+8
-11
source/dnode/mnode/impl/src/mnode.c
source/dnode/mnode/impl/src/mnode.c
+129
-20
source/dnode/mnode/sdb/inc/sdbInt.h
source/dnode/mnode/sdb/inc/sdbInt.h
+6
-6
source/dnode/vnode/inc/meta.h
source/dnode/vnode/inc/meta.h
+6
-6
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+21
-0
source/dnode/vnode/src/inc/metaDef.h
source/dnode/vnode/src/inc/metaDef.h
+1
-1
source/dnode/vnode/src/inc/tqInt.h
source/dnode/vnode/src/inc/tqInt.h
+30
-32
source/dnode/vnode/src/inc/tsdbLog.h
source/dnode/vnode/src/inc/tsdbLog.h
+6
-6
source/dnode/vnode/src/inc/vnd.h
source/dnode/vnode/src/inc/vnd.h
+30
-33
source/dnode/vnode/src/meta/metaBDBImpl.c
source/dnode/vnode/src/meta/metaBDBImpl.c
+17
-17
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+3
-1
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
+3
-3
source/dnode/vnode/src/tsdb/tsdbFS.c
source/dnode/vnode/src/tsdb/tsdbFS.c
+5
-5
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/src/catalog.c
source/libs/catalog/src/catalog.c
+30
-30
source/libs/catalog/test/catalogTests.cpp
source/libs/catalog/test/catalogTests.cpp
+5
-5
source/libs/executor/inc/executil.h
source/libs/executor/inc/executil.h
+1
-1
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+26
-24
source/libs/executor/inc/tsimplehash.h
source/libs/executor/inc/tsimplehash.h
+104
-0
source/libs/executor/src/executor.c
source/libs/executor/src/executor.c
+4
-4
source/libs/executor/src/executorMain.c
source/libs/executor/src/executorMain.c
+2
-39
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+81
-94
source/libs/executor/src/tlinearhash.c
source/libs/executor/src/tlinearhash.c
+4
-3
source/libs/executor/src/tsimplehash.c
source/libs/executor/src/tsimplehash.c
+309
-0
source/libs/executor/src/tsort.c
source/libs/executor/src/tsort.c
+2
-2
source/libs/executor/test/executorTests.cpp
source/libs/executor/test/executorTests.cpp
+607
-105
source/libs/executor/test/sortTests.cpp
source/libs/executor/test/sortTests.cpp
+2
-2
source/libs/function/src/taggfunction.c
source/libs/function/src/taggfunction.c
+1
-1
source/libs/function/src/tpercentile.c
source/libs/function/src/tpercentile.c
+1
-1
source/libs/index/inc/indexInt.h
source/libs/index/inc/indexInt.h
+31
-31
source/libs/index/inc/index_util.h
source/libs/index/inc/index_util.h
+15
-0
source/libs/index/src/index.c
source/libs/index/src/index.c
+90
-31
source/libs/index/src/index_cache.c
source/libs/index/src/index_cache.c
+4
-9
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_tfile.c
source/libs/index/src/index_tfile.c
+1
-1
source/libs/index/src/index_util.c
source/libs/index/src/index_util.c
+22
-1
source/libs/index/test/fstTest.cc
source/libs/index/test/fstTest.cc
+1
-1
source/libs/index/test/jsonUT.cc
source/libs/index/test/jsonUT.cc
+16
-0
source/libs/index/test/utilUT.cc
source/libs/index/test/utilUT.cc
+81
-0
source/libs/monitor/inc/monInt.h
source/libs/monitor/inc/monInt.h
+12
-6
source/libs/monitor/src/monitor.c
source/libs/monitor/src/monitor.c
+41
-21
source/libs/monitor/test/monTest.cpp
source/libs/monitor/test/monTest.cpp
+5
-28
source/libs/parser/src/insertParser.c
source/libs/parser/src/insertParser.c
+1
-1
source/libs/parser/test/mockCatalog.cpp
source/libs/parser/test/mockCatalog.cpp
+2
-4
source/libs/parser/test/mockCatalogService.cpp
source/libs/parser/test/mockCatalogService.cpp
+1
-1
source/libs/parser/test/parserTests.cpp
source/libs/parser/test/parserTests.cpp
+2
-2
source/libs/parser/test/plannerTest.cpp
source/libs/parser/test/plannerTest.cpp
+1
-1
source/libs/qcom/src/queryUtil.c
source/libs/qcom/src/queryUtil.c
+40
-26
source/libs/qworker/test/qworkerTests.cpp
source/libs/qworker/test/qworkerTests.cpp
+3
-3
source/libs/scalar/inc/filterInt.h
source/libs/scalar/inc/filterInt.h
+5
-5
source/libs/scalar/src/filter.c
source/libs/scalar/src/filter.c
+3
-3
source/libs/scalar/src/scalar.c
source/libs/scalar/src/scalar.c
+5
-5
source/libs/scalar/src/sclvector.c
source/libs/scalar/src/sclvector.c
+6
-6
source/libs/scalar/test/filter/filterTests.cpp
source/libs/scalar/test/filter/filterTests.cpp
+10
-4
source/libs/scalar/test/scalar/scalarTests.cpp
source/libs/scalar/test/scalar/scalarTests.cpp
+3
-3
source/libs/scheduler/test/schedulerTests.cpp
source/libs/scheduler/test/schedulerTests.cpp
+15
-3
source/libs/sync/inc/syncInt.h
source/libs/sync/inc/syncInt.h
+30
-32
source/libs/sync/src/syncIO.c
source/libs/sync/src/syncIO.c
+1
-1
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/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/inc/tfsInt.h
source/libs/tfs/inc/tfsInt.h
+6
-8
source/libs/tfs/src/tfs.c
source/libs/tfs/src/tfs.c
+24
-10
source/libs/tfs/test/tfsTest.cpp
source/libs/tfs/test/tfsTest.cpp
+49
-49
source/libs/transport/inc/rpcLog.h
source/libs/transport/inc/rpcLog.h
+30
-33
source/libs/transport/test/pushClient.c
source/libs/transport/test/pushClient.c
+1
-1
source/libs/transport/test/pushServer.c
source/libs/transport/test/pushServer.c
+1
-1
source/libs/transport/test/rclient.c
source/libs/transport/test/rclient.c
+1
-1
source/libs/transport/test/rserver.c
source/libs/transport/test/rserver.c
+1
-1
source/libs/transport/test/syncClient.c
source/libs/transport/test/syncClient.c
+1
-1
source/libs/transport/test/transUT.cc
source/libs/transport/test/transUT.cc
+3
-3
source/libs/wal/src/walMeta.c
source/libs/wal/src/walMeta.c
+12
-12
source/libs/wal/src/walWrite.c
source/libs/wal/src/walWrite.c
+12
-9
source/libs/wal/test/walMetaTest.cpp
source/libs/wal/test/walMetaTest.cpp
+2
-2
source/os/src/osDir.c
source/os/src/osDir.c
+3
-3
source/os/src/osEnv.c
source/os/src/osEnv.c
+8
-3
source/os/src/osFile.c
source/os/src/osFile.c
+42
-1
source/os/src/osSysinfo.c
source/os/src/osSysinfo.c
+232
-295
source/util/src/tcache.c
source/util/src/tcache.c
+421
-202
source/util/src/tconfig.c
source/util/src/tconfig.c
+2
-9
source/util/src/terror.c
source/util/src/terror.c
+3
-0
source/util/src/thash.c
source/util/src/thash.c
+336
-442
source/util/src/thttp.c
source/util/src/thttp.c
+1
-1
source/util/src/tlog.c
source/util/src/tlog.c
+93
-90
source/util/src/tpagedbuf.c
source/util/src/tpagedbuf.c
+25
-20
source/util/src/ttimer.c
source/util/src/ttimer.c
+35
-35
source/util/test/arrayTest.cpp
source/util/test/arrayTest.cpp
+5
-0
source/util/test/cacheTest.cpp
source/util/test/cacheTest.cpp
+22
-4
source/util/test/encodeTest.cpp
source/util/test/encodeTest.cpp
+5
-5
source/util/test/freelistTest.cpp
source/util/test/freelistTest.cpp
+1
-1
source/util/test/hashTest.cpp
source/util/test/hashTest.cpp
+9
-4
source/util/test/pageBufferTest.cpp
source/util/test/pageBufferTest.cpp
+59
-54
tests
tests
+1
-1
tools/shell/src/backup/shellImport.c
tools/shell/src/backup/shellImport.c
+3
-5
未找到文件。
contrib/test/craft/CMakeLists.txt
浏览文件 @
29fab2e3
add_executable
(
simulate_vnode
"simulate_vnode.c"
)
add_executable
(
simulate_vnode
"simulate_vnode.c"
)
target_link_libraries
(
simulate_vnode craft lz4 uv_a
)
target_link_libraries
(
simulate_vnode PUBLIC craft lz4 uv_a
)
\ No newline at end of file
\ No newline at end of file
contrib/test/traft/single_node/CMakeLists.txt
浏览文件 @
29fab2e3
...
@@ -3,4 +3,4 @@ target_sources(singleNode
...
@@ -3,4 +3,4 @@ target_sources(singleNode
PRIVATE
PRIVATE
"singleNode.c"
"singleNode.c"
)
)
target_link_libraries
(
singleNode traft lz4 uv_a
)
target_link_libraries
(
singleNode
PUBLIC
traft lz4 uv_a
)
include/common/tcommon.h
浏览文件 @
29fab2e3
...
@@ -25,24 +25,6 @@
...
@@ -25,24 +25,6 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
// typedef struct STimeWindow {
// TSKEY skey;
// TSKEY ekey;
// } STimeWindow;
// typedef struct {
// int32_t dataLen;
// char name[TSDB_TABLE_FNAME_LEN];
// char *data;
// } STagData;
// typedef struct SSchema {
// uint8_t type;
// char name[TSDB_COL_NAME_LEN];
// int16_t colId;
// int16_t bytes;
// } SSchema;
enum
{
enum
{
TMQ_CONF__RESET_OFFSET__LATEST
=
-
1
,
TMQ_CONF__RESET_OFFSET__LATEST
=
-
1
,
TMQ_CONF__RESET_OFFSET__EARLIEAST
=
-
2
,
TMQ_CONF__RESET_OFFSET__EARLIEAST
=
-
2
,
...
@@ -50,7 +32,8 @@ enum {
...
@@ -50,7 +32,8 @@ enum {
};
};
enum
{
enum
{
TMQ_MSG_TYPE__POLL_RSP
=
0
,
TMQ_MSG_TYPE__DUMMY
=
0
,
TMQ_MSG_TYPE__POLL_RSP
,
TMQ_MSG_TYPE__EP_RSP
,
TMQ_MSG_TYPE__EP_RSP
,
};
};
...
@@ -285,4 +268,4 @@ typedef struct SSessionWindow {
...
@@ -285,4 +268,4 @@ typedef struct SSessionWindow {
}
}
#endif
#endif
#endif
/*_TD_COMMON_DEF_H_*/
#endif
/*_TD_COMMON_DEF_H_*/
include/common/t
ep
.h
→
include/common/t
datablock
.h
浏览文件 @
29fab2e3
文件已移动
include/common/tmsg.h
浏览文件 @
29fab2e3
...
@@ -70,7 +70,7 @@ typedef uint16_t tmsg_t;
...
@@ -70,7 +70,7 @@ typedef uint16_t tmsg_t;
typedef
enum
{
typedef
enum
{
HEARTBEAT_TYPE_MQ
=
0
,
HEARTBEAT_TYPE_MQ
=
0
,
HEARTBEAT_TYPE_QUERY
=
1
,
HEARTBEAT_TYPE_QUERY
,
// types can be added here
// types can be added here
//
//
HEARTBEAT_TYPE_MAX
HEARTBEAT_TYPE_MAX
...
...
include/libs/executor/executor.h
浏览文件 @
29fab2e3
...
@@ -89,25 +89,6 @@ int32_t qExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t *useconds);
...
@@ -89,25 +89,6 @@ int32_t qExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t *useconds);
*/
*/
int32_t
qRetrieveQueryResultInfo
(
qTaskInfo_t
tinfo
,
bool
*
buildRes
,
void
*
pRspContext
);
int32_t
qRetrieveQueryResultInfo
(
qTaskInfo_t
tinfo
,
bool
*
buildRes
,
void
*
pRspContext
);
/**
*
* Retrieve the actual results to fill the response message payload.
* Note that this function must be executed after qRetrieveQueryResultInfo is invoked.
*
* @param tinfo tinfo object
* @param pRsp response message
* @param contLen payload length
* @return
*/
//int32_t qDumpRetrieveResult(qTaskInfo_t tinfo, SRetrieveTableRsp** pRsp, int32_t* contLen, bool* continueExec);
/**
* return the transporter context (RPC)
* @param tinfo
* @return
*/
void
*
qGetResultRetrieveMsg
(
qTaskInfo_t
tinfo
);
/**
/**
* kill the ongoing query and free the query handle and corresponding resources automatically
* kill the ongoing query and free the query handle and corresponding resources automatically
* @param tinfo qhandle
* @param tinfo qhandle
...
...
include/libs/monitor/monitor.h
浏览文件 @
29fab2e3
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
#include "tarray.h"
#include "tarray.h"
#include "tdef.h"
#include "tdef.h"
#include "tlog.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
...
@@ -85,21 +86,21 @@ typedef struct {
...
@@ -85,21 +86,21 @@ typedef struct {
typedef
struct
{
typedef
struct
{
float
uptime
;
// day
float
uptime
;
// day
float
cpu_engine
;
double
cpu_engine
;
float
cpu_system
;
double
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
int64_t
disk_engine
;
// Byte
float
disk_used
;
// GB
int64_t
disk_used
;
// Byte
float
disk_total
;
// GB
int64_t
disk_total
;
// Byte
float
net_in
;
// Kb/s
double
net_in
;
// bytes per second
float
net_out
;
// Kb/s
double
net_out
;
// bytes per second
float
io_read
;
// Mb/s
double
io_read
;
float
io_write
;
// Mb/s
double
io_write
;
float
io_read_disk
;
// Mb/s
double
io_read_disk
;
float
io_write_disk
;
// Mb/s
double
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
;
...
@@ -116,7 +117,7 @@ typedef struct {
...
@@ -116,7 +117,7 @@ typedef struct {
typedef
struct
{
typedef
struct
{
char
name
[
TSDB_FILENAME_LEN
];
char
name
[
TSDB_FILENAME_LEN
];
int
32_t
level
;
int
8_t
level
;
SDiskSize
size
;
SDiskSize
size
;
}
SMonDiskDesc
;
}
SMonDiskDesc
;
...
@@ -126,12 +127,6 @@ typedef struct {
...
@@ -126,12 +127,6 @@ typedef struct {
SMonDiskDesc
tempdir
;
SMonDiskDesc
tempdir
;
}
SMonDiskInfo
;
}
SMonDiskInfo
;
typedef
struct
{
int64_t
ts
;
int8_t
level
;
char
content
[
MON_LOG_LEN
];
}
SMonLogItem
;
typedef
struct
SMonInfo
SMonInfo
;
typedef
struct
SMonInfo
SMonInfo
;
typedef
struct
{
typedef
struct
{
...
@@ -142,7 +137,7 @@ typedef struct {
...
@@ -142,7 +137,7 @@ typedef struct {
int32_t
monInit
(
const
SMonCfg
*
pCfg
);
int32_t
monInit
(
const
SMonCfg
*
pCfg
);
void
monCleanup
();
void
monCleanup
();
void
mon
AddLogItem
(
SMonLogItem
*
pItem
);
void
mon
RecordLog
(
int64_t
ts
,
ELogLevel
level
,
const
char
*
content
);
SMonInfo
*
monCreateMonitorInfo
();
SMonInfo
*
monCreateMonitorInfo
();
void
monSetBasicInfo
(
SMonInfo
*
pMonitor
,
SMonBasicInfo
*
pInfo
);
void
monSetBasicInfo
(
SMonInfo
*
pMonitor
,
SMonBasicInfo
*
pInfo
);
...
...
include/libs/qcom/query.h
浏览文件 @
29fab2e3
...
@@ -168,20 +168,18 @@ int32_t queryCreateTableMetaFromMsg(STableMetaRsp* msg, bool isSuperTable, STabl
...
@@ -168,20 +168,18 @@ int32_t queryCreateTableMetaFromMsg(STableMetaRsp* msg, bool isSuperTable, STabl
extern
int32_t
(
*
queryBuildMsg
[
TDMT_MAX
])(
void
*
input
,
char
**
msg
,
int32_t
msgSize
,
int32_t
*
msgLen
);
extern
int32_t
(
*
queryBuildMsg
[
TDMT_MAX
])(
void
*
input
,
char
**
msg
,
int32_t
msgSize
,
int32_t
*
msgLen
);
extern
int32_t
(
*
queryProcessMsgRsp
[
TDMT_MAX
])(
void
*
output
,
char
*
msg
,
int32_t
msgSize
);
extern
int32_t
(
*
queryProcessMsgRsp
[
TDMT_MAX
])(
void
*
output
,
char
*
msg
,
int32_t
msgSize
);
#define SET_META_TYPE_NULL(t) (t) = META_TYPE_NULL_TABLE
#define SET_META_TYPE_NULL(t) (t) = META_TYPE_NULL_TABLE
#define SET_META_TYPE_CTABLE(t) (t) = META_TYPE_CTABLE
#define SET_META_TYPE_CTABLE(t) (t) = META_TYPE_CTABLE
#define SET_META_TYPE_TABLE(t) (t) = META_TYPE_TABLE
#define SET_META_TYPE_TABLE(t) (t) = META_TYPE_TABLE
#define SET_META_TYPE_BOTH_TABLE(t) (t) = META_TYPE_BOTH_TABLE
#define SET_META_TYPE_BOTH_TABLE(t) (t) = META_TYPE_BOTH_TABLE
#define qFatal(...) do { if (qDebugFlag & DEBUG_FATAL) { taosPrintLog("QRY FATAL ", qDebugFlag, __VA_ARGS__); }} while(0)
#define qFatal(...) do { if (qDebugFlag & DEBUG_FATAL) { taosPrintLog("QRY FATAL ", DEBUG_FATAL, qDebugFlag, __VA_ARGS__); }} while(0)
#define qError(...) do { if (qDebugFlag & DEBUG_ERROR) { taosPrintLog("QRY ERROR ", qDebugFlag, __VA_ARGS__); }} while(0)
#define qError(...) do { if (qDebugFlag & DEBUG_ERROR) { taosPrintLog("QRY ERROR ", DEBUG_ERROR, qDebugFlag, __VA_ARGS__); }} while(0)
#define qWarn(...) do { if (qDebugFlag & DEBUG_WARN) { taosPrintLog("QRY WARN ", qDebugFlag, __VA_ARGS__); }} while(0)
#define qWarn(...) do { if (qDebugFlag & DEBUG_WARN) { taosPrintLog("QRY WARN ", DEBUG_WARN, qDebugFlag, __VA_ARGS__); }} while(0)
#define qInfo(...) do { if (qDebugFlag & DEBUG_INFO) { taosPrintLog("QRY ", qDebugFlag, __VA_ARGS__); }} while(0)
#define qInfo(...) do { if (qDebugFlag & DEBUG_INFO) { taosPrintLog("QRY ", DEBUG_INFO, qDebugFlag, __VA_ARGS__); }} while(0)
#define qDebug(...) do { if (qDebugFlag & DEBUG_DEBUG) { taosPrintLog("QRY ", qDebugFlag, __VA_ARGS__); }} while(0)
#define qDebug(...) do { if (qDebugFlag & DEBUG_DEBUG) { taosPrintLog("QRY ", DEBUG_DEBUG, qDebugFlag, __VA_ARGS__); }} while(0)
#define qTrace(...) do { if (qDebugFlag & DEBUG_TRACE) { taosPrintLog("QRY ", qDebugFlag, __VA_ARGS__); }} while(0)
#define qTrace(...) do { if (qDebugFlag & DEBUG_TRACE) { taosPrintLog("QRY ", DEBUG_TRACE, qDebugFlag, __VA_ARGS__); }} while(0)
#define qDebugL(...) do { if (qDebugFlag & DEBUG_DEBUG) { taosPrintLongString("QRY ", qDebugFlag, __VA_ARGS__); }} while(0)
#define qDebugL(...) do { if (qDebugFlag & DEBUG_DEBUG) { taosPrintLongString("QRY ", DEBUG_DEBUG, qDebugFlag, __VA_ARGS__); }} while(0)
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
include/libs/scalar/filter.h
浏览文件 @
29fab2e3
...
@@ -19,10 +19,12 @@
...
@@ -19,10 +19,12 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
#include "tcommon.h"
#include "nodes.h"
typedef
struct
SFilterInfo
SFilterInfo
;
typedef
struct
SFilterInfo
SFilterInfo
;
typedef
int32_t
(
*
filer_get_col_from_id
)(
void
*
,
int32_t
,
void
**
);
typedef
int32_t
(
*
filer_get_col_from_id
)(
void
*
,
int32_t
,
void
**
);
enum
{
enum
{
FLT_OPTION_NO_REWRITE
=
1
,
FLT_OPTION_NO_REWRITE
=
1
,
FLT_OPTION_TIMESTAMP
=
2
,
FLT_OPTION_TIMESTAMP
=
2
,
...
@@ -34,7 +36,6 @@ typedef struct SFilterColumnParam{
...
@@ -34,7 +36,6 @@ typedef struct SFilterColumnParam{
SArray
*
pDataBlock
;
SArray
*
pDataBlock
;
}
SFilterColumnParam
;
}
SFilterColumnParam
;
extern
int32_t
filterInitFromNode
(
SNode
*
pNode
,
SFilterInfo
**
pinfo
,
uint32_t
options
);
extern
int32_t
filterInitFromNode
(
SNode
*
pNode
,
SFilterInfo
**
pinfo
,
uint32_t
options
);
extern
bool
filterExecute
(
SFilterInfo
*
info
,
SSDataBlock
*
pSrc
,
int8_t
**
p
,
SColumnDataAgg
*
statis
,
int16_t
numOfCols
);
extern
bool
filterExecute
(
SFilterInfo
*
info
,
SSDataBlock
*
pSrc
,
int8_t
**
p
,
SColumnDataAgg
*
statis
,
int16_t
numOfCols
);
extern
int32_t
filterSetDataFromSlotId
(
SFilterInfo
*
info
,
void
*
param
);
extern
int32_t
filterSetDataFromSlotId
(
SFilterInfo
*
info
,
void
*
param
);
...
...
include/libs/sync/sync.h
浏览文件 @
29fab2e3
...
@@ -21,7 +21,7 @@ extern "C" {
...
@@ -21,7 +21,7 @@ extern "C" {
#endif
#endif
#include <stdint.h>
#include <stdint.h>
#include <t
ep
.h>
#include <t
datablock
.h>
#include "taosdef.h"
#include "taosdef.h"
#include "trpc.h"
#include "trpc.h"
...
...
include/libs/tfs/tfs.h
浏览文件 @
29fab2e3
...
@@ -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/libs/wal/wal.h
浏览文件 @
29fab2e3
...
@@ -24,43 +24,41 @@
...
@@ -24,43 +24,41 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
extern
int32_t
wDebugFlag
;
#define wFatal(...) \
{ \
#define wFatal(...) \
if (wDebugFlag & DEBUG_FATAL) { \
{ \
taosPrintLog("WAL FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); \
if (wDebugFlag & DEBUG_FATAL) { \
} \
taosPrintLog("WAL FATAL ", 255, __VA_ARGS__); \
} \
}
}
#define wError(...) \
#define wError(...)
\
{ \
{
\
if (wDebugFlag & DEBUG_ERROR) { \
if (wDebugFlag & DEBUG_ERROR) {
\
taosPrintLog("WAL ERROR ", 255, __VA_ARGS__); \
taosPrintLog("WAL ERROR ",
DEBUG_ERROR,
255, __VA_ARGS__); \
} \
}
\
}
}
#define wWarn(...) \
#define wWarn(...)
\
{ \
{
\
if (wDebugFlag & DEBUG_WARN) { \
if (wDebugFlag & DEBUG_WARN) {
\
taosPrintLog("WAL WARN ", 255, __VA_ARGS__); \
taosPrintLog("WAL WARN ",
DEBUG_WARN,
255, __VA_ARGS__); \
} \
}
\
}
}
#define wInfo(...) \
#define wInfo(...)
\
{ \
{
\
if (wDebugFlag & DEBUG_INFO) { \
if (wDebugFlag & DEBUG_INFO) {
\
taosPrintLog("WAL ", 255, __VA_ARGS__); \
taosPrintLog("WAL ",
DEBUG_INFO,
255, __VA_ARGS__); \
} \
}
\
}
}
#define wDebug(...) \
#define wDebug(...)
\
{ \
{
\
if (wDebugFlag & DEBUG_DEBUG) { \
if (wDebugFlag & DEBUG_DEBUG) {
\
taosPrintLog("WAL ", wDebugFlag, __VA_ARGS__); \
taosPrintLog("WAL ",
DEBUG_DEBUG,
wDebugFlag, __VA_ARGS__); \
} \
}
\
}
}
#define wTrace(...) \
#define wTrace(...)
\
{ \
{
\
if (wDebugFlag & DEBUG_TRACE) { \
if (wDebugFlag & DEBUG_TRACE) {
\
taosPrintLog("WAL ", wDebugFlag, __VA_ARGS__); \
taosPrintLog("WAL ",
DEBUG_TRACE,
wDebugFlag, __VA_ARGS__); \
} \
}
\
}
}
#define WAL_HEAD_VER 0
#define WAL_HEAD_VER 0
...
...
include/os/os.h
浏览文件 @
29fab2e3
...
@@ -44,6 +44,7 @@ extern "C" {
...
@@ -44,6 +44,7 @@ extern "C" {
#include <sys/stat.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <sys/utsname.h>
#include <sys/param.h>
#include <unistd.h>
#include <unistd.h>
#include <wchar.h>
#include <wchar.h>
#include <wctype.h>
#include <wctype.h>
...
...
include/os/osDir.h
浏览文件 @
29fab2e3
...
@@ -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
浏览文件 @
29fab2e3
...
@@ -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
浏览文件 @
29fab2e3
...
@@ -22,11 +22,18 @@ extern "C" {
...
@@ -22,11 +22,18 @@ extern "C" {
#include "osSocket.h"
#include "osSocket.h"
// If the error is in a third-party library, place this header file under the third-party library header file.
#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
#define fsync FSYNC_FUNC_TAOS_FORBID
// #define fflush FFLUSH_FUNC_TAOS_FORBID
#endif
#endif
#ifndef PATH_MAX
#ifndef PATH_MAX
...
@@ -43,7 +50,13 @@ typedef struct TdFile *TdFilePtr;
...
@@ -43,7 +50,13 @@ typedef struct TdFile *TdFilePtr;
#define TD_FILE_TEXT 0x0020
#define TD_FILE_TEXT 0x0020
#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, 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 +64,9 @@ int32_t taosUnLockFile(TdFilePtr pFile);
...
@@ -51,9 +64,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 +75,7 @@ int32_t taosFsyncFile(TdFilePtr pFile);
...
@@ -62,7 +75,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
);
...
@@ -70,8 +83,9 @@ int64_t taosCloseFile(TdFilePtr *ppFile);
...
@@ -70,8 +83,9 @@ 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
);
int32_t
taosRemoveFile
(
const
char
*
path
);
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 +93,7 @@ int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, in
...
@@ -79,7 +93,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
浏览文件 @
29fab2e3
...
@@ -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
(
double
*
cpu_system
,
double
*
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
*
wchar
s
);
int32_t
taosReadProcIO
(
int64_t
*
rchars
,
int64_t
*
wchars
,
int64_t
*
read_bytes
,
int64_t
*
write_byte
s
);
bool
taosGetProcIO
(
float
*
readKB
,
float
*
write
KB
);
int32_t
taosGetIOSpeed
(
double
*
readKB
,
double
*
writeKB
,
double
*
readDiskKB
,
double
*
writeDisk
KB
);
bool
taosGetCardInfo
(
int64_t
*
bytes
,
int64_t
*
rbytes
,
int64_t
*
t
bytes
);
int32_t
taosGetCardInfo
(
int64_t
*
receive_bytes
,
int64_t
*
transmit_
bytes
);
bool
taosGetBandSpeed
(
float
*
bandSpeedKb
);
int32_t
taosGetBandSpeed
(
double
*
receive_bytes_per_sec
,
double
*
transmit_bytes_per_sec
);
int32_t
taosSystem
(
const
char
*
cmd
);
int32_t
taosSystem
(
const
char
*
cmd
);
void
taosKillSystem
();
void
taosKillSystem
();
...
...
include/util/tcache.h
浏览文件 @
29fab2e3
...
@@ -40,55 +40,9 @@ typedef struct SCacheStatis {
...
@@ -40,55 +40,9 @@ typedef struct SCacheStatis {
int64_t
refreshCount
;
int64_t
refreshCount
;
}
SCacheStatis
;
}
SCacheStatis
;
struct
STrashElem
;
typedef
struct
SCacheObj
SCacheObj
;
typedef
struct
SCacheIter
SCacheIter
;
typedef
struct
SCacheDataNode
{
typedef
struct
STrashElem
STrashElem
;
uint64_t
addedTime
;
// the added time when this element is added or updated into cache
uint64_t
lifespan
;
// life duration when this element should be remove from cache
uint64_t
expireTime
;
// expire time
uint64_t
signature
;
struct
STrashElem
*
pTNodeHeader
;
// point to trash node head
uint16_t
keySize
:
15
;
// max key size: 32kb
bool
inTrashcan
:
1
;
// denote if it is in trash or not
uint32_t
size
;
// allocated size for current SCacheDataNode
T_REF_DECLARE
()
char
*
key
;
char
data
[];
}
SCacheDataNode
;
typedef
struct
STrashElem
{
struct
STrashElem
*
prev
;
struct
STrashElem
*
next
;
SCacheDataNode
*
pData
;
}
STrashElem
;
/*
* to accommodate the old data which has the same key value of new one in hashList
* when an new node is put into cache, if an existed one with the same key:
* 1. if the old one does not be referenced, update it.
* 2. otherwise, move the old one to pTrash, addedTime the new one.
*
* when the node in pTrash does not be referenced, it will be release at the expired expiredTime
*/
typedef
struct
{
int64_t
totalSize
;
// total allocated buffer in this hash table, SCacheObj is not included.
int64_t
refreshTime
;
STrashElem
*
pTrash
;
char
*
name
;
SCacheStatis
statistics
;
SHashObj
*
pHashTable
;
__cache_free_fn_t
freeFp
;
uint32_t
numOfElemsInTrash
;
// number of element in trash
uint8_t
deleting
;
// set the deleting flag to stop refreshing ASAP.
pthread_t
refreshWorker
;
bool
extendLifespan
;
// auto extend life span when one item is accessed.
int64_t
checkTick
;
// tick used to record the check times of the refresh threads
#if defined(LINUX)
pthread_rwlock_t
lock
;
#else
pthread_mutex_t
lock
;
#endif
}
SCacheObj
;
/**
/**
* initialize the cache object
* initialize the cache object
...
@@ -141,7 +95,7 @@ void *taosCacheAcquireByData(SCacheObj *pCacheObj, void *data);
...
@@ -141,7 +95,7 @@ void *taosCacheAcquireByData(SCacheObj *pCacheObj, void *data);
* @param data
* @param data
* @return
* @return
*/
*/
void
*
taosCacheTransfer
(
SCacheObj
*
pCacheObj
,
void
**
data
);
void
*
taosCacheTransfer
Data
(
SCacheObj
*
pCacheObj
,
void
**
data
);
/**
/**
* remove data in cache, the data will not be removed immediately.
* remove data in cache, the data will not be removed immediately.
...
@@ -152,6 +106,13 @@ void *taosCacheTransfer(SCacheObj *pCacheObj, void **data);
...
@@ -152,6 +106,13 @@ void *taosCacheTransfer(SCacheObj *pCacheObj, void **data);
*/
*/
void
taosCacheRelease
(
SCacheObj
*
pCacheObj
,
void
**
data
,
bool
_remove
);
void
taosCacheRelease
(
SCacheObj
*
pCacheObj
,
void
**
data
,
bool
_remove
);
/**
*
* @param pCacheObj
* @return
*/
size_t
taosCacheGetNumOfObj
(
const
SCacheObj
*
pCacheObj
);
/**
/**
* move all data node into trash, clear node in trash can if it is not referenced by any clients
* move all data node into trash, clear node in trash can if it is not referenced by any clients
* @param handle
* @param handle
...
@@ -184,6 +145,12 @@ void taosCacheRefresh(SCacheObj *pCacheObj, __cache_trav_fn_t fp, void *param1);
...
@@ -184,6 +145,12 @@ void taosCacheRefresh(SCacheObj *pCacheObj, __cache_trav_fn_t fp, void *param1);
*/
*/
void
taosStopCacheRefreshWorker
();
void
taosStopCacheRefreshWorker
();
SCacheIter
*
taosCacheCreateIter
(
const
SCacheObj
*
pCacheObj
);
bool
taosCacheIterNext
(
SCacheIter
*
pIter
);
void
*
taosCacheIterGetData
(
const
SCacheIter
*
pIter
,
size_t
*
dataLen
);
void
*
taosCacheIterGetKey
(
const
SCacheIter
*
pIter
,
size_t
*
keyLen
);
void
taosCacheDestroyIter
(
SCacheIter
*
pIter
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
include/util/thash.h
浏览文件 @
29fab2e3
...
@@ -28,12 +28,8 @@ typedef int32_t (*_equal_fn_t)(const void *, const void *, size_t len);
...
@@ -28,12 +28,8 @@ typedef int32_t (*_equal_fn_t)(const void *, const void *, size_t len);
typedef
void
(
*
_hash_before_fn_t
)(
void
*
);
typedef
void
(
*
_hash_before_fn_t
)(
void
*
);
typedef
void
(
*
_hash_free_fn_t
)(
void
*
);
typedef
void
(
*
_hash_free_fn_t
)(
void
*
);
#define HASH_MAX_CAPACITY (1024 * 1024 * 16)
#define HASH_KEY_ALREADY_EXISTS (-2)
#define HASH_DEFAULT_LOAD_FACTOR (0.75)
#define HASH_NODE_EXIST(code) (code == HASH_KEY_ALREADY_EXISTS)
#define HASH_INDEX(v, c) ((v) & ((c)-1))
#define HASH_NODE_EXIST(code) (code == -2)
/**
/**
* murmur hash algorithm
* murmur hash algorithm
...
@@ -54,49 +50,15 @@ uint32_t taosIntHash_32(const char *key, uint32_t len);
...
@@ -54,49 +50,15 @@ uint32_t taosIntHash_32(const char *key, uint32_t len);
uint32_t
taosIntHash_64
(
const
char
*
key
,
uint32_t
len
);
uint32_t
taosIntHash_64
(
const
char
*
key
,
uint32_t
len
);
_hash_fn_t
taosGetDefaultHashFunction
(
int32_t
type
);
_hash_fn_t
taosGetDefaultHashFunction
(
int32_t
type
);
_equal_fn_t
taosGetDefaultEqualFunction
(
int32_t
type
);
_equal_fn_t
taosGetDefaultEqualFunction
(
int32_t
type
);
typedef
struct
SHashNode
{
struct
SHashNode
*
next
;
uint32_t
hashVal
;
// the hash value of key
uint32_t
dataLen
;
// length of data
uint32_t
keyLen
;
// length of the key
uint16_t
count
;
// reference count
int8_t
removed
;
// flag to indicate removed
char
data
[];
}
SHashNode
;
#define GET_HASH_NODE_KEY(_n) ((char *)(_n) + sizeof(SHashNode) + (_n)->dataLen)
#define GET_HASH_NODE_DATA(_n) ((char *)(_n) + sizeof(SHashNode))
#define GET_HASH_PNODE(_n) ((SHashNode *)((char *)(_n) - sizeof(SHashNode)))
typedef
enum
SHashLockTypeE
{
typedef
enum
SHashLockTypeE
{
HASH_NO_LOCK
=
0
,
HASH_NO_LOCK
=
0
,
HASH_ENTRY_LOCK
=
1
,
HASH_ENTRY_LOCK
=
1
,
}
SHashLockTypeE
;
}
SHashLockTypeE
;
typedef
struct
SHashEntry
{
typedef
struct
SHashNode
SHashNode
;
int32_t
num
;
// number of elements in current entry
typedef
struct
SHashObj
SHashObj
;
SRWLatch
latch
;
// entry latch
SHashNode
*
next
;
}
SHashEntry
;
typedef
struct
SHashObj
{
SHashEntry
**
hashList
;
uint32_t
capacity
;
// number of slots
uint32_t
size
;
// number of elements in hash table
_hash_fn_t
hashFp
;
// hash function
_hash_free_fn_t
freeFp
;
// hash node free callback function
_equal_fn_t
equalFp
;
// equal function
_hash_before_fn_t
callbackFp
;
// function invoked before return the value to caller
SRWLatch
lock
;
// read-write spin lock
SHashLockTypeE
type
;
// lock type
bool
enableUpdate
;
// enable update
SArray
*
pMemBlock
;
// memory block allocated for SHashEntry
}
SHashObj
;
/**
/**
* init the hash table
* init the hash table
...
@@ -126,8 +88,6 @@ int32_t taosHashGetSize(const SHashObj *pHashObj);
...
@@ -126,8 +88,6 @@ int32_t taosHashGetSize(const SHashObj *pHashObj);
*/
*/
int32_t
taosHashPut
(
SHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
,
void
*
data
,
size_t
size
);
int32_t
taosHashPut
(
SHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
,
void
*
data
,
size_t
size
);
int32_t
taosHashPutExt
(
SHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
,
void
*
data
,
size_t
size
,
bool
*
newAdded
);
/**
/**
* return the payload data with the specified key
* return the payload data with the specified key
*
*
...
@@ -146,17 +106,18 @@ void *taosHashGet(SHashObj *pHashObj, const void *key, size_t keyLen);
...
@@ -146,17 +106,18 @@ void *taosHashGet(SHashObj *pHashObj, const void *key, size_t keyLen);
* @param destBuf
* @param destBuf
* @return
* @return
*/
*/
void
*
taosHashGetClone
(
SHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
,
void
*
destBuf
);
int32_t
taosHashGetDup
(
SHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
,
void
*
destBuf
);
/**
/**
*
Clone the result to interval allocated buffer
*
* @param pHashObj
* @param pHashObj
* @param key
* @param key
* @param keyLen
* @param keyLen
* @param destBuf
* @param destBuf
* @param size
* @return
* @return
*/
*/
void
*
taosHashGetCloneExt
(
SHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
,
void
(
*
fp
)(
void
*
),
void
**
d
,
size_t
*
sz
);
int32_t
taosHashGetDup_m
(
SHashObj
*
pHashObj
,
const
void
*
key
,
size_t
keyLen
,
void
**
destBuf
,
int32_t
*
size
);
/**
/**
* remove item with the specified key
* remove item with the specified key
...
@@ -207,37 +168,13 @@ void *taosHashIterate(SHashObj *pHashObj, void *p);
...
@@ -207,37 +168,13 @@ void *taosHashIterate(SHashObj *pHashObj, void *p);
*/
*/
void
taosHashCancelIterate
(
SHashObj
*
pHashObj
,
void
*
p
);
void
taosHashCancelIterate
(
SHashObj
*
pHashObj
,
void
*
p
);
/**
/**
* Get the corresponding key information for a given data in hash table
* Get the corresponding key information for a given data in hash table
* @param data
* @param data
* @return
* @param keyLen
*/
* @return
int32_t
taosHashGetKey
(
void
*
data
,
void
**
key
,
size_t
*
keyLen
);
*/
void
*
taosHashGetKey
(
void
*
data
,
size_t
*
keyLen
);
/**
* Get the corresponding key information for a given data in hash table, using memcpy
* @param data
* @param dst
* @return
*/
static
FORCE_INLINE
int32_t
taosHashCopyKey
(
void
*
data
,
void
*
dst
)
{
if
(
NULL
==
data
||
NULL
==
dst
)
{
return
-
1
;
}
SHashNode
*
node
=
GET_HASH_PNODE
(
data
);
void
*
key
=
GET_HASH_NODE_KEY
(
node
);
memcpy
(
dst
,
key
,
node
->
keyLen
);
return
0
;
}
/**
* Get the corresponding data length for a given data in hash table
* @param data
* @return
*/
int32_t
taosHashGetDataLen
(
void
*
data
);
/**
/**
* return the payload data with the specified key(reference number added)
* return the payload data with the specified key(reference number added)
...
@@ -258,8 +195,20 @@ void *taosHashAcquire(SHashObj *pHashObj, const void *key, size_t keyLen);
...
@@ -258,8 +195,20 @@ void *taosHashAcquire(SHashObj *pHashObj, const void *key, size_t keyLen);
*/
*/
void
taosHashRelease
(
SHashObj
*
pHashObj
,
void
*
p
);
void
taosHashRelease
(
SHashObj
*
pHashObj
,
void
*
p
);
/**
*
* @param pHashObj
* @param fp
*/
void
taosHashSetEqualFp
(
SHashObj
*
pHashObj
,
_equal_fn_t
fp
);
void
taosHashSetEqualFp
(
SHashObj
*
pHashObj
,
_equal_fn_t
fp
);
/**
*
* @param pHashObj
* @param fp
*/
void
taosHashSetFreeFp
(
SHashObj
*
pHashObj
,
_hash_free_fn_t
fp
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
include/util/tlog.h
浏览文件 @
29fab2e3
...
@@ -22,9 +22,29 @@
...
@@ -22,9 +22,29 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
typedef
enum
{
DEBUG_FATAL
=
1
,
DEBUG_ERROR
=
1
,
DEBUG_WARN
=
2
,
DEBUG_INFO
=
2
,
DEBUG_DEBUG
=
4
,
DEBUG_TRACE
=
8
,
DEBUG_DUMP
=
16
,
DEBUG_SCREEN
=
64
,
DEBUG_FILE
=
128
}
ELogLevel
;
typedef
void
(
*
LogFp
)(
int64_t
ts
,
ELogLevel
level
,
const
char
*
content
);
extern
bool
tsLogEmbedded
;
extern
bool
tsAsyncLog
;
extern
bool
tsAsyncLog
;
extern
int32_t
tsNumOfLogLines
;
extern
int32_t
tsNumOfLogLines
;
extern
int32_t
tsLogKeepDays
;
extern
int32_t
tsLogKeepDays
;
extern
LogFp
tsLogFp
;
extern
int64_t
tsNumOfErrorLogs
;
extern
int64_t
tsNumOfInfoLogs
;
extern
int64_t
tsNumOfDebugLogs
;
extern
int64_t
tsNumOfTraceLogs
;
extern
int32_t
dDebugFlag
;
extern
int32_t
dDebugFlag
;
extern
int32_t
vDebugFlag
;
extern
int32_t
vDebugFlag
;
extern
int32_t
mDebugFlag
;
extern
int32_t
mDebugFlag
;
...
@@ -40,45 +60,33 @@ extern int32_t tsdbDebugFlag;
...
@@ -40,45 +60,33 @@ extern int32_t tsdbDebugFlag;
extern
int32_t
tqDebugFlag
;
extern
int32_t
tqDebugFlag
;
extern
int32_t
fsDebugFlag
;
extern
int32_t
fsDebugFlag
;
#define DEBUG_FATAL 1U
#define DEBUG_ERROR DEBUG_FATAL
#define DEBUG_WARN 2U
#define DEBUG_INFO DEBUG_WARN
#define DEBUG_DEBUG 4U
#define DEBUG_TRACE 8U
#define DEBUG_DUMP 16U
#define DEBUG_SCREEN 64U
#define DEBUG_FILE 128U
int32_t
taosInitLog
(
const
char
*
logName
,
int32_t
maxFiles
);
int32_t
taosInitLog
(
const
char
*
logName
,
int32_t
maxFiles
);
void
taosCloseLog
();
void
taosCloseLog
();
void
taosResetLog
();
void
taosResetLog
();
void
taosSetAllDebugFlag
(
int32_t
flag
);
void
taosSetAllDebugFlag
(
int32_t
flag
);
void
taosDumpData
(
uint8_t
*
msg
,
int32_t
len
);
void
taosDumpData
(
uint8_t
*
msg
,
int32_t
len
);
void
taosPrintLog
(
const
char
*
flags
,
int32_t
dflag
,
const
char
*
format
,
...)
void
taosPrintLog
(
const
char
*
flags
,
ELogLevel
level
,
int32_t
dflag
,
const
char
*
format
,
...)
#ifdef __GNUC__
#ifdef __GNUC__
__attribute__
((
format
(
printf
,
3
,
4
)))
__attribute__
((
format
(
printf
,
4
,
5
)))
#endif
#endif
;
;
void
taosPrintLongString
(
const
char
*
flags
,
int32_t
dflag
,
const
char
*
format
,
...)
void
taosPrintLongString
(
const
char
*
flags
,
ELogLevel
level
,
int32_t
dflag
,
const
char
*
format
,
...)
#ifdef __GNUC__
#ifdef __GNUC__
__attribute__
((
format
(
printf
,
3
,
4
)))
__attribute__
((
format
(
printf
,
4
,
5
)))
#endif
#endif
;
;
extern
int8_t
tscEmbeddedInUtil
;
#define uFatal(...) { if (uDebugFlag & DEBUG_FATAL) { taosPrintLog("UTL FATAL", DEBUG_FATAL, tsLogEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
#define uError(...) { if (uDebugFlag & DEBUG_ERROR) { taosPrintLog("UTL ERROR ", DEBUG_ERROR, tsLogEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
#define uFatal(...) { if (uDebugFlag & DEBUG_FATAL) { taosPrintLog("UTL FATAL", tscEmbeddedInUtil ? 255 : uDebugFlag, __VA_ARGS__); }}
#define uWarn(...) { if (uDebugFlag & DEBUG_WARN) { taosPrintLog("UTL WARN ", DEBUG_WARN, tsLogEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
#define uError(...) { if (uDebugFlag & DEBUG_ERROR) { taosPrintLog("UTL ERROR ", tscEmbeddedInUtil ? 255 : uDebugFlag, __VA_ARGS__); }}
#define uInfo(...) { if (uDebugFlag & DEBUG_INFO) { taosPrintLog("UTL ", DEBUG_INFO, tsLogEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }}
#define uWarn(...) { if (uDebugFlag & DEBUG_WARN) { taosPrintLog("UTL WARN ", tscEmbeddedInUtil ? 255 : uDebugFlag, __VA_ARGS__); }}
#define uDebug(...) { if (uDebugFlag & DEBUG_DEBUG) { taosPrintLog("UTL ", DEBUG_DEBUG, uDebugFlag, __VA_ARGS__); }}
#define uInfo(...) { if (uDebugFlag & DEBUG_INFO) { taosPrintLog("UTL ", tscEmbeddedInUtil ? 255 : uDebugFlag, __VA_ARGS__); }}
#define uTrace(...) { if (uDebugFlag & DEBUG_TRACE) { taosPrintLog("UTL ", DEBUG_TRACE, uDebugFlag, __VA_ARGS__); }}
#define uDebug(...) { if (uDebugFlag & DEBUG_DEBUG) { taosPrintLog("UTL ", uDebugFlag, __VA_ARGS__); }}
#define uTrace(...) { if (uDebugFlag & DEBUG_TRACE) { taosPrintLog("UTL ", uDebugFlag, __VA_ARGS__); }}
#define pError(...) { taosPrintLog("APP ERROR ", 255, __VA_ARGS__); }
#define pError(...) { taosPrintLog("APP ERROR ",
DEBUG_ERROR,
255, __VA_ARGS__); }
#define pPrint(...) { taosPrintLog("APP ", 255, __VA_ARGS__); }
#define pPrint(...) { taosPrintLog("APP ",
DEBUG_INFO,
255, __VA_ARGS__); }
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
include/util/tpagedbuf.h
浏览文件 @
29fab2e3
...
@@ -53,7 +53,7 @@ typedef struct SDiskbasedBufStatis {
...
@@ -53,7 +53,7 @@ typedef struct SDiskbasedBufStatis {
* @param handle
* @param handle
* @return
* @return
*/
*/
int32_t
createDiskbasedBuf
(
SDiskbasedBuf
**
pBuf
,
int32_t
pagesize
,
int32_t
inMemBufSize
,
uint64_t
qI
d
,
const
char
*
dir
);
int32_t
createDiskbasedBuf
(
SDiskbasedBuf
**
pBuf
,
int32_t
pagesize
,
int32_t
inMemBufSize
,
const
char
*
i
d
,
const
char
*
dir
);
/**
/**
*
*
...
...
source/client/inc/clientInt.h
浏览文件 @
29fab2e3
...
@@ -20,12 +20,12 @@
...
@@ -20,12 +20,12 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
#include "tcommon.h"
#include "parser.h"
#include "parser.h"
#include "query.h"
#include "query.h"
#include "taos.h"
#include "taos.h"
#include "tcommon.h"
#include "tdatablock.h"
#include "tdef.h"
#include "tdef.h"
#include "tep.h"
#include "thash.h"
#include "thash.h"
#include "tlist.h"
#include "tlist.h"
#include "tmsg.h"
#include "tmsg.h"
...
@@ -47,12 +47,12 @@ extern "C" {
...
@@ -47,12 +47,12 @@ extern "C" {
typedef
struct
SAppInstInfo
SAppInstInfo
;
typedef
struct
SAppInstInfo
SAppInstInfo
;
typedef
struct
SHbConnInfo
{
typedef
struct
{
void
*
param
;
void
*
param
;
SClientHbReq
*
req
;
SClientHbReq
*
req
;
}
SHbConnInfo
;
}
SHbConnInfo
;
typedef
struct
SAppHbMgr
{
typedef
struct
{
char
*
key
;
char
*
key
;
// statistics
// statistics
int32_t
reportCnt
;
int32_t
reportCnt
;
...
@@ -68,11 +68,11 @@ typedef struct SAppHbMgr {
...
@@ -68,11 +68,11 @@ typedef struct SAppHbMgr {
SHashObj
*
connInfo
;
// hash<SClientHbKey, SHbConnInfo>
SHashObj
*
connInfo
;
// hash<SClientHbKey, SHbConnInfo>
}
SAppHbMgr
;
}
SAppHbMgr
;
typedef
int32_t
(
*
FHbRspHandle
)(
struct
SAppHbMgr
*
pAppHbMgr
,
SClientHbRsp
*
pRsp
);
typedef
int32_t
(
*
FHbRspHandle
)(
SAppHbMgr
*
pAppHbMgr
,
SClientHbRsp
*
pRsp
);
typedef
int32_t
(
*
FHbReqHandle
)(
SClientHbKey
*
connKey
,
void
*
param
,
SClientHbReq
*
req
);
typedef
int32_t
(
*
FHbReqHandle
)(
SClientHbKey
*
connKey
,
void
*
param
,
SClientHbReq
*
req
);
typedef
struct
SClientHbMgr
{
typedef
struct
{
int8_t
inited
;
int8_t
inited
;
// ctl
// ctl
int8_t
threadStop
;
int8_t
threadStop
;
...
@@ -108,13 +108,13 @@ typedef struct SHeartBeatInfo {
...
@@ -108,13 +108,13 @@ typedef struct SHeartBeatInfo {
}
SHeartBeatInfo
;
}
SHeartBeatInfo
;
struct
SAppInstInfo
{
struct
SAppInstInfo
{
int64_t
numOfConns
;
int64_t
numOfConns
;
SCorEpSet
mgmtEp
;
SCorEpSet
mgmtEp
;
SInstanceSummary
summary
;
SInstanceSummary
summary
;
SList
*
pConnList
;
// STscObj linked list
SList
*
pConnList
;
// STscObj linked list
int64_t
clusterId
;
int64_t
clusterId
;
void
*
pTransporter
;
void
*
pTransporter
;
struct
SAppHbMgr
*
pAppHbMgr
;
SAppHbMgr
*
pAppHbMgr
;
};
};
typedef
struct
SAppInfo
{
typedef
struct
SAppInfo
{
...
@@ -141,10 +141,6 @@ typedef struct STscObj {
...
@@ -141,10 +141,6 @@ typedef struct STscObj {
SAppInstInfo
*
pAppInfo
;
SAppInstInfo
*
pAppInfo
;
}
STscObj
;
}
STscObj
;
typedef
struct
SMqConsumer
{
STscObj
*
pTscObj
;
}
SMqConsumer
;
typedef
struct
SReqResultInfo
{
typedef
struct
SReqResultInfo
{
const
char
*
pRspMsg
;
const
char
*
pRspMsg
;
const
char
*
pData
;
const
char
*
pData
;
...
@@ -172,7 +168,7 @@ typedef struct SRequestSendRecvBody {
...
@@ -172,7 +168,7 @@ typedef struct SRequestSendRecvBody {
SShowReqInfo
showInfo
;
// todo this attribute will be removed after the query framework being completed.
SShowReqInfo
showInfo
;
// todo this attribute will be removed after the query framework being completed.
SDataBuf
requestMsg
;
SDataBuf
requestMsg
;
int64_t
queryJob
;
// query job, created according to sql query DAG.
int64_t
queryJob
;
// query job, created according to sql query DAG.
struct
SQueryDag
*
pDag
;
// the query dag, generated according to the sql statement.
struct
SQueryDag
*
pDag
;
// the query dag, generated according to the sql statement.
SReqResultInfo
resInfo
;
SReqResultInfo
resInfo
;
}
SRequestSendRecvBody
;
}
SRequestSendRecvBody
;
...
...
source/client/inc/clientLog.h
浏览文件 @
29fab2e3
...
@@ -22,13 +22,13 @@ extern "C" {
...
@@ -22,13 +22,13 @@ extern "C" {
#include "tlog.h"
#include "tlog.h"
#define tscFatal(...) do { if (cDebugFlag & DEBUG_FATAL) { taosPrintLog("TSC FATAL ", cDebugFlag, __VA_ARGS__); }} while(0)
#define tscFatal(...) do { if (cDebugFlag & DEBUG_FATAL) { taosPrintLog("TSC FATAL ",
DEBUG_FATAL,
cDebugFlag, __VA_ARGS__); }} while(0)
#define tscError(...) do { if (cDebugFlag & DEBUG_ERROR) { taosPrintLog("TSC ERROR ", cDebugFlag, __VA_ARGS__); }} while(0)
#define tscError(...) do { if (cDebugFlag & DEBUG_ERROR) { taosPrintLog("TSC ERROR ",
DEBUG_ERROR,
cDebugFlag, __VA_ARGS__); }} while(0)
#define tscWarn(...) do { if (cDebugFlag & DEBUG_WARN) { taosPrintLog("TSC WARN ", cDebugFlag, __VA_ARGS__); }} while(0)
#define tscWarn(...) do { if (cDebugFlag & DEBUG_WARN) { taosPrintLog("TSC WARN ",
DEBUG_WARN,
cDebugFlag, __VA_ARGS__); }} while(0)
#define tscInfo(...) do { if (cDebugFlag & DEBUG_INFO) { taosPrintLog("TSC ", cDebugFlag, __VA_ARGS__); }} while(0)
#define tscInfo(...) do { if (cDebugFlag & DEBUG_INFO) { taosPrintLog("TSC ",
DEBUG_INFO,
cDebugFlag, __VA_ARGS__); }} while(0)
#define tscDebug(...) do { if (cDebugFlag & DEBUG_DEBUG) { taosPrintLog("TSC ", cDebugFlag, __VA_ARGS__); }} while(0)
#define tscDebug(...) do { if (cDebugFlag & DEBUG_DEBUG) { taosPrintLog("TSC ",
DEBUG_DEBUG,
cDebugFlag, __VA_ARGS__); }} while(0)
#define tscTrace(...) do { if (cDebugFlag & DEBUG_TRACE) { taosPrintLog("TSC ", cDebugFlag, __VA_ARGS__); }} while(0)
#define tscTrace(...) do { if (cDebugFlag & DEBUG_TRACE) { taosPrintLog("TSC ",
DEBUG_TRACE,
cDebugFlag, __VA_ARGS__); }} while(0)
#define tscDebugL(...) do { if (cDebugFlag & DEBUG_DEBUG) { taosPrintLongString("TSC ", cDebugFlag, __VA_ARGS__); }} while(0)
#define tscDebugL(...) do { if (cDebugFlag & DEBUG_DEBUG) { taosPrintLongString("TSC ",
DEBUG_DEBUG,
cDebugFlag, __VA_ARGS__); }} while(0)
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/client/src/clientHb.c
浏览文件 @
29fab2e3
...
@@ -23,7 +23,7 @@ static SClientHbMgr clientHbMgr = {0};
...
@@ -23,7 +23,7 @@ static SClientHbMgr clientHbMgr = {0};
static
int32_t
hbCreateThread
();
static
int32_t
hbCreateThread
();
static
void
hbStopThread
();
static
void
hbStopThread
();
static
int32_t
hbMqHbRspHandle
(
struct
SAppHbMgr
*
pAppHbMgr
,
SClientHbRsp
*
pRsp
)
{
return
0
;
}
static
int32_t
hbMqHbRspHandle
(
SAppHbMgr
*
pAppHbMgr
,
SClientHbRsp
*
pRsp
)
{
return
0
;
}
static
int32_t
hbProcessDBInfoRsp
(
void
*
value
,
int32_t
valueLen
,
struct
SCatalog
*
pCatalog
)
{
static
int32_t
hbProcessDBInfoRsp
(
void
*
value
,
int32_t
valueLen
,
struct
SCatalog
*
pCatalog
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
...
@@ -104,7 +104,7 @@ static int32_t hbProcessStbInfoRsp(void *value, int32_t valueLen, struct SCatalo
...
@@ -104,7 +104,7 @@ static int32_t hbProcessStbInfoRsp(void *value, int32_t valueLen, struct SCatalo
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
hbQueryHbRspHandle
(
struct
SAppHbMgr
*
pAppHbMgr
,
SClientHbRsp
*
pRsp
)
{
static
int32_t
hbQueryHbRspHandle
(
SAppHbMgr
*
pAppHbMgr
,
SClientHbRsp
*
pRsp
)
{
SHbConnInfo
*
info
=
taosHashGet
(
pAppHbMgr
->
connInfo
,
&
pRsp
->
connKey
,
sizeof
(
SClientHbKey
));
SHbConnInfo
*
info
=
taosHashGet
(
pAppHbMgr
->
connInfo
,
&
pRsp
->
connKey
,
sizeof
(
SClientHbKey
));
if
(
NULL
==
info
)
{
if
(
NULL
==
info
)
{
tscWarn
(
"fail to get connInfo, may be dropped, connId:%d, type:%d"
,
pRsp
->
connKey
.
connId
,
pRsp
->
connKey
.
hbType
);
tscWarn
(
"fail to get connInfo, may be dropped, connId:%d, type:%d"
,
pRsp
->
connKey
.
connId
,
pRsp
->
connKey
.
hbType
);
...
@@ -163,7 +163,7 @@ static int32_t hbQueryHbRspHandle(struct SAppHbMgr *pAppHbMgr, SClientHbRsp *pRs
...
@@ -163,7 +163,7 @@ static int32_t hbQueryHbRspHandle(struct SAppHbMgr *pAppHbMgr, SClientHbRsp *pRs
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
hb
Mq
AsyncCallBack
(
void
*
param
,
const
SDataBuf
*
pMsg
,
int32_t
code
)
{
static
int32_t
hbAsyncCallBack
(
void
*
param
,
const
SDataBuf
*
pMsg
,
int32_t
code
)
{
static
int32_t
emptyRspNum
=
0
;
static
int32_t
emptyRspNum
=
0
;
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
tfree
(
param
);
tfree
(
param
);
...
@@ -226,7 +226,11 @@ int32_t hbGetExpiredDBInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, SCl
...
@@ -226,7 +226,11 @@ int32_t hbGetExpiredDBInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, SCl
db
->
vgVersion
=
htonl
(
db
->
vgVersion
);
db
->
vgVersion
=
htonl
(
db
->
vgVersion
);
}
}
SKv
kv
=
{.
key
=
HEARTBEAT_KEY_DBINFO
,
.
valueLen
=
sizeof
(
SDbVgVersion
)
*
dbNum
,
.
value
=
dbs
};
SKv
kv
=
{
.
key
=
HEARTBEAT_KEY_DBINFO
,
.
valueLen
=
sizeof
(
SDbVgVersion
)
*
dbNum
,
.
value
=
dbs
,
};
tscDebug
(
"hb got %d expired db, valueLen:%d"
,
dbNum
,
kv
.
valueLen
);
tscDebug
(
"hb got %d expired db, valueLen:%d"
,
dbNum
,
kv
.
valueLen
);
...
@@ -256,7 +260,11 @@ int32_t hbGetExpiredStbInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, SC
...
@@ -256,7 +260,11 @@ int32_t hbGetExpiredStbInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, SC
stb
->
tversion
=
htons
(
stb
->
tversion
);
stb
->
tversion
=
htons
(
stb
->
tversion
);
}
}
SKv
kv
=
{.
key
=
HEARTBEAT_KEY_STBINFO
,
.
valueLen
=
sizeof
(
SSTableMetaVersion
)
*
stbNum
,
.
value
=
stbs
};
SKv
kv
=
{
.
key
=
HEARTBEAT_KEY_STBINFO
,
.
valueLen
=
sizeof
(
SSTableMetaVersion
)
*
stbNum
,
.
value
=
stbs
,
};
tscDebug
(
"hb got %d expired stb, valueLen:%d"
,
stbNum
,
kv
.
valueLen
);
tscDebug
(
"hb got %d expired stb, valueLen:%d"
,
stbNum
,
kv
.
valueLen
);
...
@@ -288,7 +296,7 @@ int32_t hbQueryHbReqHandle(SClientHbKey *connKey, void *param, SClientHbReq *req
...
@@ -288,7 +296,7 @@ int32_t hbQueryHbReqHandle(SClientHbKey *connKey, void *param, SClientHbReq *req
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
hbMqHbReqHandle
(
SClientHbKey
*
connKey
,
void
*
param
,
SClientHbReq
*
req
)
{}
int32_t
hbMqHbReqHandle
(
SClientHbKey
*
connKey
,
void
*
param
,
SClientHbReq
*
req
)
{
return
0
;
}
void
hbMgrInitMqHbHandle
()
{
void
hbMgrInitMqHbHandle
()
{
clientHbMgr
.
reqHandle
[
HEARTBEAT_TYPE_QUERY
]
=
hbQueryHbReqHandle
;
clientHbMgr
.
reqHandle
[
HEARTBEAT_TYPE_QUERY
]
=
hbQueryHbReqHandle
;
...
@@ -396,7 +404,7 @@ static void *hbThreadFunc(void *param) {
...
@@ -396,7 +404,7 @@ static void *hbThreadFunc(void *param) {
free
(
buf
);
free
(
buf
);
break
;
break
;
}
}
pInfo
->
fp
=
hb
Mq
AsyncCallBack
;
pInfo
->
fp
=
hbAsyncCallBack
;
pInfo
->
msgInfo
.
pData
=
buf
;
pInfo
->
msgInfo
.
pData
=
buf
;
pInfo
->
msgInfo
.
len
=
tlen
;
pInfo
->
msgInfo
.
len
=
tlen
;
pInfo
->
msgType
=
TDMT_MND_HEARTBEAT
;
pInfo
->
msgType
=
TDMT_MND_HEARTBEAT
;
...
@@ -448,7 +456,6 @@ static void hbStopThread() {
...
@@ -448,7 +456,6 @@ static void hbStopThread() {
}
}
SAppHbMgr
*
appHbMgrInit
(
SAppInstInfo
*
pAppInstInfo
,
char
*
key
)
{
SAppHbMgr
*
appHbMgrInit
(
SAppInstInfo
*
pAppInstInfo
,
char
*
key
)
{
/*return NULL;*/
hbMgrInit
();
hbMgrInit
();
SAppHbMgr
*
pAppHbMgr
=
malloc
(
sizeof
(
SAppHbMgr
));
SAppHbMgr
*
pAppHbMgr
=
malloc
(
sizeof
(
SAppHbMgr
));
if
(
pAppHbMgr
==
NULL
)
{
if
(
pAppHbMgr
==
NULL
)
{
...
@@ -473,7 +480,8 @@ SAppHbMgr *appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key) {
...
@@ -473,7 +480,8 @@ SAppHbMgr *appHbMgrInit(SAppInstInfo *pAppInstInfo, char *key) {
free
(
pAppHbMgr
);
free
(
pAppHbMgr
);
return
NULL
;
return
NULL
;
}
}
pAppHbMgr
->
activeInfo
->
freeFp
=
tFreeClientHbReq
;
taosHashSetFreeFp
(
pAppHbMgr
->
activeInfo
,
tFreeClientHbReq
);
// init getInfoFunc
// init getInfoFunc
pAppHbMgr
->
connInfo
=
taosHashInit
(
64
,
hbKeyHashFunc
,
1
,
HASH_ENTRY_LOCK
);
pAppHbMgr
->
connInfo
=
taosHashInit
(
64
,
hbKeyHashFunc
,
1
,
HASH_ENTRY_LOCK
);
...
@@ -506,7 +514,6 @@ void appHbMgrCleanup(void) {
...
@@ -506,7 +514,6 @@ void appHbMgrCleanup(void) {
}
}
int
hbMgrInit
()
{
int
hbMgrInit
()
{
/*return 0;*/
// init once
// init once
int8_t
old
=
atomic_val_compare_exchange_8
(
&
clientHbMgr
.
inited
,
0
,
1
);
int8_t
old
=
atomic_val_compare_exchange_8
(
&
clientHbMgr
.
inited
,
0
,
1
);
if
(
old
==
1
)
return
0
;
if
(
old
==
1
)
return
0
;
...
@@ -524,7 +531,7 @@ int hbMgrInit() {
...
@@ -524,7 +531,7 @@ int hbMgrInit() {
}
}
void
hbMgrCleanUp
()
{
void
hbMgrCleanUp
()
{
return
;
#if 0
hbStopThread();
hbStopThread();
// destroy all appHbMgr
// destroy all appHbMgr
...
@@ -537,6 +544,7 @@ void hbMgrCleanUp() {
...
@@ -537,6 +544,7 @@ void hbMgrCleanUp() {
pthread_mutex_unlock(&clientHbMgr.lock);
pthread_mutex_unlock(&clientHbMgr.lock);
clientHbMgr.appHbMgrs = NULL;
clientHbMgr.appHbMgrs = NULL;
#endif
}
}
int
hbRegisterConnImpl
(
SAppHbMgr
*
pAppHbMgr
,
SClientHbKey
connKey
,
SHbConnInfo
*
info
)
{
int
hbRegisterConnImpl
(
SAppHbMgr
*
pAppHbMgr
,
SClientHbKey
connKey
,
SHbConnInfo
*
info
)
{
...
@@ -563,9 +571,11 @@ int hbRegisterConnImpl(SAppHbMgr *pAppHbMgr, SClientHbKey connKey, SHbConnInfo *
...
@@ -563,9 +571,11 @@ int hbRegisterConnImpl(SAppHbMgr *pAppHbMgr, SClientHbKey connKey, SHbConnInfo *
}
}
int
hbRegisterConn
(
SAppHbMgr
*
pAppHbMgr
,
int32_t
connId
,
int64_t
clusterId
,
int32_t
hbType
)
{
int
hbRegisterConn
(
SAppHbMgr
*
pAppHbMgr
,
int32_t
connId
,
int64_t
clusterId
,
int32_t
hbType
)
{
/*return 0;*/
SClientHbKey
connKey
=
{
SClientHbKey
connKey
=
{.
connId
=
connId
,
.
hbType
=
HEARTBEAT_TYPE_QUERY
};
.
connId
=
connId
,
SHbConnInfo
info
=
{
0
};
.
hbType
=
HEARTBEAT_TYPE_QUERY
,
};
SHbConnInfo
info
=
{
0
};
switch
(
hbType
)
{
switch
(
hbType
)
{
case
HEARTBEAT_TYPE_QUERY
:
{
case
HEARTBEAT_TYPE_QUERY
:
{
...
@@ -586,7 +596,6 @@ int hbRegisterConn(SAppHbMgr *pAppHbMgr, int32_t connId, int64_t clusterId, int3
...
@@ -586,7 +596,6 @@ int hbRegisterConn(SAppHbMgr *pAppHbMgr, int32_t connId, int64_t clusterId, int3
}
}
void
hbDeregisterConn
(
SAppHbMgr
*
pAppHbMgr
,
SClientHbKey
connKey
)
{
void
hbDeregisterConn
(
SAppHbMgr
*
pAppHbMgr
,
SClientHbKey
connKey
)
{
/*return;*/
int32_t
code
=
0
;
int32_t
code
=
0
;
code
=
taosHashRemove
(
pAppHbMgr
->
activeInfo
,
&
connKey
,
sizeof
(
SClientHbKey
));
code
=
taosHashRemove
(
pAppHbMgr
->
activeInfo
,
&
connKey
,
sizeof
(
SClientHbKey
));
code
=
taosHashRemove
(
pAppHbMgr
->
connInfo
,
&
connKey
,
sizeof
(
SClientHbKey
));
code
=
taosHashRemove
(
pAppHbMgr
->
connInfo
,
&
connKey
,
sizeof
(
SClientHbKey
));
...
@@ -598,7 +607,6 @@ void hbDeregisterConn(SAppHbMgr *pAppHbMgr, SClientHbKey connKey) {
...
@@ -598,7 +607,6 @@ void hbDeregisterConn(SAppHbMgr *pAppHbMgr, SClientHbKey connKey) {
int
hbAddConnInfo
(
SAppHbMgr
*
pAppHbMgr
,
SClientHbKey
connKey
,
void
*
key
,
void
*
value
,
int32_t
keyLen
,
int
hbAddConnInfo
(
SAppHbMgr
*
pAppHbMgr
,
SClientHbKey
connKey
,
void
*
key
,
void
*
value
,
int32_t
keyLen
,
int32_t
valueLen
)
{
int32_t
valueLen
)
{
return
0
;
// find req by connection id
// find req by connection id
SClientHbReq
*
pReq
=
taosHashGet
(
pAppHbMgr
->
activeInfo
,
&
connKey
,
sizeof
(
SClientHbKey
));
SClientHbReq
*
pReq
=
taosHashGet
(
pAppHbMgr
->
activeInfo
,
&
connKey
,
sizeof
(
SClientHbKey
));
ASSERT
(
pReq
!=
NULL
);
ASSERT
(
pReq
!=
NULL
);
...
...
source/client/src/clientImpl.c
浏览文件 @
29fab2e3
...
@@ -4,8 +4,8 @@
...
@@ -4,8 +4,8 @@
#include "parser.h"
#include "parser.h"
#include "planner.h"
#include "planner.h"
#include "scheduler.h"
#include "scheduler.h"
#include "tdatablock.h"
#include "tdef.h"
#include "tdef.h"
#include "tep.h"
#include "tglobal.h"
#include "tglobal.h"
#include "tmsgtype.h"
#include "tmsgtype.h"
#include "tpagedbuf.h"
#include "tpagedbuf.h"
...
...
source/client/src/tmq.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/common/src/t
ep
.c
→
source/common/src/t
datablock
.c
浏览文件 @
29fab2e3
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
*/
*/
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "t
ep
.h"
#include "t
datablock
.h"
#include "tcompare.h"
#include "tcompare.h"
#include "tglobal.h"
#include "tglobal.h"
...
...
source/common/src/tglobal.c
浏览文件 @
29fab2e3
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
#include "tglobal.h"
#include "tglobal.h"
#include "tcompare.h"
#include "tcompare.h"
#include "tconfig.h"
#include "tconfig.h"
#include "t
ep
.h"
#include "t
datablock
.h"
#include "tlog.h"
#include "tlog.h"
SConfig
*
tsCfg
=
NULL
;
SConfig
*
tsCfg
=
NULL
;
...
@@ -155,21 +155,40 @@ static void taosAddDataDir(int32_t index, char *v1, int32_t level, int32_t prima
...
@@ -155,21 +155,40 @@ static void taosAddDataDir(int32_t index, char *v1, int32_t level, int32_t prima
uTrace
(
"dataDir:%s, level:%d primary:%d is configured"
,
v1
,
level
,
primary
);
uTrace
(
"dataDir:%s, level:%d primary:%d is configured"
,
v1
,
level
,
primary
);
}
}
static
void
taosSetTfsCfg
(
SConfig
*
pCfg
)
{
static
int32_t
taosSetTfsCfg
(
SConfig
*
pCfg
)
{
SConfigItem
*
pItem
=
cfgGetItem
(
pCfg
,
"dataDir"
);
SConfigItem
*
pItem
=
cfgGetItem
(
pCfg
,
"dataDir"
);
if
(
pItem
==
NULL
)
return
;
memset
(
tsDataDir
,
0
,
PATH_MAX
)
;
int32_t
size
=
taosArrayGetSize
(
pItem
->
array
);
int32_t
size
=
taosArrayGetSize
(
pItem
->
array
);
if
(
size
<=
0
)
{
if
(
size
<=
0
)
{
tsDiskCfgNum
=
1
;
tsDiskCfgNum
=
1
;
taosAddDataDir
(
0
,
pItem
->
str
,
0
,
1
);
taosAddDataDir
(
0
,
pItem
->
str
,
0
,
1
);
tstrncpy
(
tsDataDir
,
pItem
->
str
,
PATH_MAX
);
if
(
taosMkDir
(
tsDataDir
)
!=
0
)
{
uError
(
"failed to create dataDir:%s since %s"
,
tsDataDir
,
terrstr
());
return
-
1
;
}
}
else
{
}
else
{
tsDiskCfgNum
=
size
<
TFS_MAX_DISKS
?
size
:
TFS_MAX_DISKS
;
tsDiskCfgNum
=
size
<
TFS_MAX_DISKS
?
size
:
TFS_MAX_DISKS
;
for
(
int32_t
index
=
0
;
index
<
tsDiskCfgNum
;
++
index
)
{
for
(
int32_t
index
=
0
;
index
<
tsDiskCfgNum
;
++
index
)
{
SDiskCfg
*
pCfg
=
taosArrayGet
(
pItem
->
array
,
index
);
SDiskCfg
*
pCfg
=
taosArrayGet
(
pItem
->
array
,
index
);
memcpy
(
&
tsDiskCfg
[
index
],
pCfg
,
sizeof
(
SDiskCfg
));
memcpy
(
&
tsDiskCfg
[
index
],
pCfg
,
sizeof
(
SDiskCfg
));
if
(
pCfg
->
level
==
0
&&
pCfg
->
primary
==
1
)
{
tstrncpy
(
tsDataDir
,
pCfg
->
dir
,
PATH_MAX
);
}
if
(
taosMkDir
(
pCfg
->
dir
)
!=
0
)
{
uError
(
"failed to create tfsDir:%s since %s"
,
tsDataDir
,
terrstr
());
return
-
1
;
}
}
}
}
}
if
(
tsDataDir
[
0
]
==
0
)
{
uError
(
"datadir not set"
);
return
-
1
;
}
return
0
;
}
}
struct
SConfig
*
taosGetCfg
()
{
struct
SConfig
*
taosGetCfg
()
{
...
@@ -279,11 +298,11 @@ static int32_t taosAddSystemCfg(SConfig *pCfg) {
...
@@ -279,11 +298,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
;
...
@@ -358,7 +377,7 @@ static void taosSetServerLogCfg(SConfig *pCfg) {
...
@@ -358,7 +377,7 @@ static void taosSetServerLogCfg(SConfig *pCfg) {
fsDebugFlag
=
cfgGetItem
(
pCfg
,
"fsDebugFlag"
)
->
i32
;
fsDebugFlag
=
cfgGetItem
(
pCfg
,
"fsDebugFlag"
)
->
i32
;
}
}
static
void
taosSetClientCfg
(
SConfig
*
pCfg
)
{
static
int32_t
taosSetClientCfg
(
SConfig
*
pCfg
)
{
tstrncpy
(
tsLocalFqdn
,
cfgGetItem
(
pCfg
,
"fqdn"
)
->
str
,
TSDB_FQDN_LEN
);
tstrncpy
(
tsLocalFqdn
,
cfgGetItem
(
pCfg
,
"fqdn"
)
->
str
,
TSDB_FQDN_LEN
);
tsServerPort
=
(
uint16_t
)
cfgGetItem
(
pCfg
,
"serverPort"
)
->
i32
;
tsServerPort
=
(
uint16_t
)
cfgGetItem
(
pCfg
,
"serverPort"
)
->
i32
;
snprintf
(
tsLocalEp
,
sizeof
(
tsLocalEp
),
"%s:%u"
,
tsLocalFqdn
,
tsServerPort
);
snprintf
(
tsLocalEp
,
sizeof
(
tsLocalEp
),
"%s:%u"
,
tsLocalFqdn
,
tsServerPort
);
...
@@ -375,9 +394,13 @@ static void taosSetClientCfg(SConfig *pCfg) {
...
@@ -375,9 +394,13 @@ static void taosSetClientCfg(SConfig *pCfg) {
snprintf
(
tsSecond
,
sizeof
(
tsSecond
),
"%s:%u"
,
secondEp
.
fqdn
,
secondEp
.
port
);
snprintf
(
tsSecond
,
sizeof
(
tsSecond
),
"%s:%u"
,
secondEp
.
fqdn
,
secondEp
.
port
);
cfgSetItem
(
pCfg
,
"secondEp"
,
tsSecond
,
pSecondpItem
->
stype
);
cfgSetItem
(
pCfg
,
"secondEp"
,
tsSecond
,
pSecondpItem
->
stype
);
tstrncpy
(
ts
Log
Dir
,
cfgGetItem
(
pCfg
,
"tempDir"
)
->
str
,
PATH_MAX
);
tstrncpy
(
ts
Temp
Dir
,
cfgGetItem
(
pCfg
,
"tempDir"
)
->
str
,
PATH_MAX
);
taosExpandDir
(
ts
LogDir
,
tsLog
Dir
,
PATH_MAX
);
taosExpandDir
(
ts
TempDir
,
tsTemp
Dir
,
PATH_MAX
);
tsTempSpace
.
reserved
=
cfgGetItem
(
pCfg
,
"minimalTempDirGB"
)
->
fval
;
tsTempSpace
.
reserved
=
cfgGetItem
(
pCfg
,
"minimalTempDirGB"
)
->
fval
;
if
(
taosMkDir
(
tsTempDir
)
!=
0
)
{
uError
(
"failed to create tempDir:%s since %s"
,
tsTempDir
,
terrstr
());
return
-
1
;
}
tsNumOfThreadsPerCore
=
cfgGetItem
(
pCfg
,
"maxTmrCtrl"
)
->
fval
;
tsNumOfThreadsPerCore
=
cfgGetItem
(
pCfg
,
"maxTmrCtrl"
)
->
fval
;
tsMaxTmrCtrl
=
cfgGetItem
(
pCfg
,
"maxTmrCtrl"
)
->
i32
;
tsMaxTmrCtrl
=
cfgGetItem
(
pCfg
,
"maxTmrCtrl"
)
->
i32
;
...
@@ -392,6 +415,8 @@ static void taosSetClientCfg(SConfig *pCfg) {
...
@@ -392,6 +415,8 @@ static void taosSetClientCfg(SConfig *pCfg) {
tsMaxNumOfOrderedResults
=
cfgGetItem
(
pCfg
,
"maxNumOfOrderedRes"
)
->
i32
;
tsMaxNumOfOrderedResults
=
cfgGetItem
(
pCfg
,
"maxNumOfOrderedRes"
)
->
i32
;
tsKeepOriginalColumnName
=
cfgGetItem
(
pCfg
,
"keepColumnName"
)
->
bval
;
tsKeepOriginalColumnName
=
cfgGetItem
(
pCfg
,
"keepColumnName"
)
->
bval
;
tsMaxBinaryDisplayWidth
=
cfgGetItem
(
pCfg
,
"maxBinaryDisplayWidth"
)
->
i32
;
tsMaxBinaryDisplayWidth
=
cfgGetItem
(
pCfg
,
"maxBinaryDisplayWidth"
)
->
i32
;
return
0
;
}
}
static
void
taosSetSystemCfg
(
SConfig
*
pCfg
)
{
static
void
taosSetSystemCfg
(
SConfig
*
pCfg
)
{
...
@@ -404,10 +429,6 @@ static void taosSetSystemCfg(SConfig *pCfg) {
...
@@ -404,10 +429,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
);
...
@@ -415,11 +436,8 @@ static void taosSetSystemCfg(SConfig *pCfg) {
...
@@ -415,11 +436,8 @@ static void taosSetSystemCfg(SConfig *pCfg) {
tsVersion
=
30000000
;
tsVersion
=
30000000
;
}
}
static
void
taosSetServerCfg
(
SConfig
*
pCfg
)
{
static
int32_t
taosSetServerCfg
(
SConfig
*
pCfg
)
{
tstrncpy
(
tsDataDir
,
cfgGetItem
(
pCfg
,
"dataDir"
)
->
str
,
PATH_MAX
);
tsDataSpace
.
reserved
=
cfgGetItem
(
pCfg
,
"minimalDataDirGB"
)
->
fval
;
taosExpandDir
(
tsDataDir
,
tsDataDir
,
PATH_MAX
);
tsTempSpace
.
reserved
=
cfgGetItem
(
pCfg
,
"minimalDataDirGB"
)
->
fval
;
tsNumOfCommitThreads
=
cfgGetItem
(
pCfg
,
"numOfCommitThreads"
)
->
i32
;
tsNumOfCommitThreads
=
cfgGetItem
(
pCfg
,
"numOfCommitThreads"
)
->
i32
;
tsRatioOfQueryCores
=
cfgGetItem
(
pCfg
,
"ratioOfQueryCores"
)
->
fval
;
tsRatioOfQueryCores
=
cfgGetItem
(
pCfg
,
"ratioOfQueryCores"
)
->
fval
;
tsMaxNumOfDistinctResults
=
cfgGetItem
(
pCfg
,
"maxNumOfDistinctRes"
)
->
i32
;
tsMaxNumOfDistinctResults
=
cfgGetItem
(
pCfg
,
"maxNumOfDistinctRes"
)
->
i32
;
...
@@ -448,6 +466,8 @@ static void taosSetServerCfg(SConfig *pCfg) {
...
@@ -448,6 +466,8 @@ static void taosSetServerCfg(SConfig *pCfg) {
if
(
tsQueryBufferSize
>=
0
)
{
if
(
tsQueryBufferSize
>=
0
)
{
tsQueryBufferSizeBytes
=
tsQueryBufferSize
*
1048576UL
;
tsQueryBufferSizeBytes
=
tsQueryBufferSize
*
1048576UL
;
}
}
return
0
;
}
}
int32_t
taosCreateLog
(
const
char
*
logname
,
int32_t
logFileNum
,
const
char
*
cfgDir
,
const
char
*
envFile
,
int32_t
taosCreateLog
(
const
char
*
logname
,
int32_t
logFileNum
,
const
char
*
cfgDir
,
const
char
*
envFile
,
...
@@ -458,10 +478,10 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi
...
@@ -458,10 +478,10 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi
if
(
pCfg
==
NULL
)
return
-
1
;
if
(
pCfg
==
NULL
)
return
-
1
;
if
(
tsc
)
{
if
(
tsc
)
{
ts
cEmbeddedInUtil
=
0
;
ts
LogEmbedded
=
0
;
if
(
taosAddClientLogCfg
(
pCfg
)
!=
0
)
return
-
1
;
if
(
taosAddClientLogCfg
(
pCfg
)
!=
0
)
return
-
1
;
}
else
{
}
else
{
ts
cEmbeddedInUtil
=
1
;
ts
LogEmbedded
=
1
;
if
(
taosAddClientLogCfg
(
pCfg
)
!=
0
)
return
-
1
;
if
(
taosAddClientLogCfg
(
pCfg
)
!=
0
)
return
-
1
;
if
(
taosAddServerLogCfg
(
pCfg
)
!=
0
)
return
-
1
;
if
(
taosAddServerLogCfg
(
pCfg
)
!=
0
)
return
-
1
;
}
}
...
@@ -508,8 +528,8 @@ int32_t taosInitCfg(const char *cfgDir, const char *envFile, const char *apolloU
...
@@ -508,8 +528,8 @@ int32_t taosInitCfg(const char *cfgDir, const char *envFile, const char *apolloU
tsCfg
=
cfgInit
();
tsCfg
=
cfgInit
();
if
(
tsc
)
{
if
(
tsc
)
{
if
(
taosAddClientLogCfg
(
tsCfg
)
!=
0
)
return
-
1
;
if
(
taosAddClientCfg
(
tsCfg
)
!=
0
)
return
-
1
;
if
(
taosAddClientCfg
(
tsCfg
)
!=
0
)
return
-
1
;
if
(
taosAddClientLogCfg
(
tsCfg
)
!=
0
)
return
-
1
;
}
else
{
}
else
{
if
(
taosAddClientCfg
(
tsCfg
)
!=
0
)
return
-
1
;
if
(
taosAddClientCfg
(
tsCfg
)
!=
0
)
return
-
1
;
if
(
taosAddServerCfg
(
tsCfg
)
!=
0
)
return
-
1
;
if
(
taosAddServerCfg
(
tsCfg
)
!=
0
)
return
-
1
;
...
@@ -532,24 +552,14 @@ int32_t taosInitCfg(const char *cfgDir, const char *envFile, const char *apolloU
...
@@ -532,24 +552,14 @@ int32_t taosInitCfg(const char *cfgDir, const char *envFile, const char *apolloU
}
}
if
(
tsc
)
{
if
(
tsc
)
{
taosSetClientCfg
(
tsCfg
)
;
if
(
taosSetClientCfg
(
tsCfg
))
return
-
1
;
}
else
{
}
else
{
taosSetClientCfg
(
tsCfg
)
;
if
(
taosSetClientCfg
(
tsCfg
))
return
-
1
;
taosSetServerCfg
(
tsCfg
)
;
if
(
taosSetServerCfg
(
tsCfg
))
return
-
1
;
taosSetTfsCfg
(
tsCfg
)
;
if
(
taosSetTfsCfg
(
tsCfg
)
!=
0
)
return
-
1
;
}
}
taosSetSystemCfg
(
tsCfg
);
taosSetSystemCfg
(
tsCfg
);
if
(
taosMkDir
(
tsTempDir
)
!=
0
)
{
uError
(
"failed to create dir:%s since %s"
,
tsTempDir
,
terrstr
());
return
-
1
;
}
if
(
!
tsc
&&
taosMkDir
(
tsDataDir
)
!=
0
)
{
uError
(
"failed to create dir:%s since %s"
,
tsDataDir
,
terrstr
());
return
-
1
;
}
cfgDumpCfg
(
tsCfg
,
tsc
,
false
);
cfgDumpCfg
(
tsCfg
,
tsc
,
false
);
return
0
;
return
0
;
}
}
...
...
source/common/src/ttszip.c
浏览文件 @
29fab2e3
...
@@ -46,7 +46,7 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
...
@@ -46,7 +46,7 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
}
}
if
(
!
autoDelete
)
{
if
(
!
autoDelete
)
{
remov
e
(
pTSBuf
->
path
);
taosRemoveFil
e
(
pTSBuf
->
path
);
}
}
if
(
NULL
==
allocResForTSBuf
(
pTSBuf
))
{
if
(
NULL
==
allocResForTSBuf
(
pTSBuf
))
{
...
@@ -178,7 +178,7 @@ void* tsBufDestroy(STSBuf* pTSBuf) {
...
@@ -178,7 +178,7 @@ void* tsBufDestroy(STSBuf* pTSBuf) {
if
(
pTSBuf
->
autoDelete
)
{
if
(
pTSBuf
->
autoDelete
)
{
// ("tsBuf %p destroyed, delete tmp file:%s", pTSBuf, pTSBuf->path);
// ("tsBuf %p destroyed, delete tmp file:%s", pTSBuf, pTSBuf->path);
remov
e
(
pTSBuf
->
path
);
taosRemoveFil
e
(
pTSBuf
->
path
);
}
else
{
}
else
{
// tscDebug("tsBuf %p destroyed, tmp file:%s, remains", pTSBuf, pTSBuf->path);
// tscDebug("tsBuf %p destroyed, tmp file:%s, remains", pTSBuf, pTSBuf->path);
}
}
...
...
source/common/test/commonTests.cpp
浏览文件 @
29fab2e3
#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,9 @@
...
@@ -10,6 +8,9 @@
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "os.h"
#include "os.h"
#include "tcommon.h"
#include "tdatablock.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
浏览文件 @
29fab2e3
#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
浏览文件 @
29fab2e3
...
@@ -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
;
...
@@ -108,6 +108,7 @@ typedef struct {
...
@@ -108,6 +108,7 @@ typedef struct {
SHashObj
*
hash
;
SHashObj
*
hash
;
int32_t
openVnodes
;
int32_t
openVnodes
;
int32_t
totalVnodes
;
int32_t
totalVnodes
;
int32_t
masterNum
;
SRWLatch
latch
;
SRWLatch
latch
;
SQWorkerPool
queryPool
;
SQWorkerPool
queryPool
;
SFWorkerPool
fetchPool
;
SFWorkerPool
fetchPool
;
...
@@ -137,8 +138,7 @@ typedef struct SDnode {
...
@@ -137,8 +138,7 @@ typedef struct SDnode {
SStartupReq
startup
;
SStartupReq
startup
;
}
SDnode
;
}
SDnode
;
int32_t
dndGetMonitorDiskInfo
(
SDnode
*
pDnode
,
SMonDiskInfo
*
pInfo
);
int32_t
dndGetDiskInfo
(
SDnode
*
pDnode
,
SMonDiskInfo
*
pInfo
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/dnode/mgmt/impl/inc/dndInt.h
浏览文件 @
29fab2e3
...
@@ -23,9 +23,11 @@ extern "C" {
...
@@ -23,9 +23,11 @@ extern "C" {
#include "os.h"
#include "os.h"
#include "cJSON.h"
#include "cJSON.h"
#include "monitor.h"
#include "tcache.h"
#include "tcache.h"
#include "tcrc32c.h"
#include "tcrc32c.h"
#include "tep.h"
#include "tdatablock.h"
#include "tglobal.h"
#include "thash.h"
#include "thash.h"
#include "tlockfree.h"
#include "tlockfree.h"
#include "tlog.h"
#include "tlog.h"
...
@@ -35,8 +37,6 @@ extern "C" {
...
@@ -35,8 +37,6 @@ extern "C" {
#include "tthread.h"
#include "tthread.h"
#include "ttime.h"
#include "ttime.h"
#include "tworker.h"
#include "tworker.h"
#include "tglobal.h"
#include "monitor.h"
#include "dnode.h"
#include "dnode.h"
...
@@ -47,14 +47,12 @@ extern "C" {
...
@@ -47,14 +47,12 @@ extern "C" {
#include "vnode.h"
#include "vnode.h"
#include "tfs.h"
#include "tfs.h"
extern
int32_t
dDebugFlag
;
#define dFatal(...) { if (dDebugFlag & DEBUG_FATAL) { taosPrintLog("DND FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }}
#define dError(...) { if (dDebugFlag & DEBUG_ERROR) { taosPrintLog("DND ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }}
#define dFatal(...) { if (dDebugFlag & DEBUG_FATAL) { taosPrintLog("DND FATAL ", 255, __VA_ARGS__); }}
#define dWarn(...) { if (dDebugFlag & DEBUG_WARN) { taosPrintLog("DND WARN ", DEBUG_WARN, 255, __VA_ARGS__); }}
#define dError(...) { if (dDebugFlag & DEBUG_ERROR) { taosPrintLog("DND ERROR ", 255, __VA_ARGS__); }}
#define dInfo(...) { if (dDebugFlag & DEBUG_INFO) { taosPrintLog("DND ", DEBUG_INFO, 255, __VA_ARGS__); }}
#define dWarn(...) { if (dDebugFlag & DEBUG_WARN) { taosPrintLog("DND WARN ", 255, __VA_ARGS__); }}
#define dDebug(...) { if (dDebugFlag & DEBUG_DEBUG) { taosPrintLog("DND ", DEBUG_DEBUG, dDebugFlag, __VA_ARGS__); }}
#define dInfo(...) { if (dDebugFlag & DEBUG_INFO) { taosPrintLog("DND ", 255, __VA_ARGS__); }}
#define dTrace(...) { if (dDebugFlag & DEBUG_TRACE) { taosPrintLog("DND ", DEBUG_TRACE, dDebugFlag, __VA_ARGS__); }}
#define dDebug(...) { if (dDebugFlag & DEBUG_DEBUG) { taosPrintLog("DND ", dDebugFlag, __VA_ARGS__); }}
#define dTrace(...) { if (dDebugFlag & DEBUG_TRACE) { taosPrintLog("DND ", dDebugFlag, __VA_ARGS__); }}
typedef
enum
{
DND_STAT_INIT
,
DND_STAT_RUNNING
,
DND_STAT_STOPPED
}
EStat
;
typedef
enum
{
DND_STAT_INIT
,
DND_STAT_RUNNING
,
DND_STAT_STOPPED
}
EStat
;
typedef
enum
{
DND_WORKER_SINGLE
,
DND_WORKER_MULTI
}
EWorkerType
;
typedef
enum
{
DND_WORKER_SINGLE
,
DND_WORKER_MULTI
}
EWorkerType
;
...
...
source/dnode/mgmt/impl/inc/dndMnode.h
浏览文件 @
29fab2e3
...
@@ -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
浏览文件 @
29fab2e3
...
@@ -324,4 +324,11 @@ void dndCleanup() {
...
@@ -324,4 +324,11 @@ void dndCleanup() {
dInfo
(
"dnode env is cleaned up"
);
dInfo
(
"dnode env is cleaned up"
);
}
}
int32_t
dndGetDiskInfo
(
SDnode
*
pDnode
,
SMonDiskInfo
*
pInfo
)
{
return
0
;
}
int32_t
dndGetMonitorDiskInfo
(
SDnode
*
pDnode
,
SMonDiskInfo
*
pInfo
)
{
\ No newline at end of file
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
浏览文件 @
29fab2e3
...
@@ -474,13 +474,36 @@ void dndProcessStartupReq(SDnode *pDnode, SRpcMsg *pReq) {
...
@@ -474,13 +474,36 @@ void dndProcessStartupReq(SDnode *pDnode, SRpcMsg *pReq) {
rpcSendResponse
(
&
rpcRsp
);
rpcSendResponse
(
&
rpcRsp
);
}
}
static
int32_t
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
);
return
0
;
}
}
static
int32_t
dndGetDnodeInfo
(
SDnode
*
pDnode
,
SMonDnodeInfo
*
pInfo
)
{
return
0
;
}
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
;
pInfo
->
disk_total
=
tsDataSpace
.
size
.
total
;
taosGetBandSpeed
(
&
pInfo
->
net_in
,
&
pInfo
->
net_out
);
taosGetIOSpeed
(
&
pInfo
->
io_read
,
&
pInfo
->
io_write
,
&
pInfo
->
io_read_disk
,
&
pInfo
->
io_write_disk
);
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
=
tsNumOfErrorLogs
;
pInfo
->
vnodes_num
=
pDnode
->
vmgmt
.
totalVnodes
;
pInfo
->
masters
=
pDnode
->
vmgmt
.
masterNum
;
pInfo
->
has_mnode
=
dndIsMnode
(
pDnode
);
}
static
void
dndSendMonitorReport
(
SDnode
*
pDnode
)
{
static
void
dndSendMonitorReport
(
SDnode
*
pDnode
)
{
if
(
!
tsEnableMonitor
||
tsMonitorFqdn
[
0
]
==
0
||
tsMonitorPort
==
0
)
return
;
if
(
!
tsEnableMonitor
||
tsMonitorFqdn
[
0
]
==
0
||
tsMonitorPort
==
0
)
return
;
...
@@ -490,9 +513,8 @@ static void dndSendMonitorReport(SDnode *pDnode) {
...
@@ -490,9 +513,8 @@ static void dndSendMonitorReport(SDnode *pDnode) {
if
(
pMonitor
==
NULL
)
return
;
if
(
pMonitor
==
NULL
)
return
;
SMonBasicInfo
basicInfo
=
{
0
};
SMonBasicInfo
basicInfo
=
{
0
};
if
(
dndGetBasicInfo
(
pDnode
,
&
basicInfo
)
==
0
)
{
dndGetMonitorBasicInfo
(
pDnode
,
&
basicInfo
);
monSetBasicInfo
(
pMonitor
,
&
basicInfo
);
monSetBasicInfo
(
pMonitor
,
&
basicInfo
);
}
SMonClusterInfo
clusterInfo
=
{
0
};
SMonClusterInfo
clusterInfo
=
{
0
};
SMonVgroupInfo
vgroupInfo
=
{
0
};
SMonVgroupInfo
vgroupInfo
=
{
0
};
...
@@ -504,15 +526,19 @@ static void dndSendMonitorReport(SDnode *pDnode) {
...
@@ -504,15 +526,19 @@ static void dndSendMonitorReport(SDnode *pDnode) {
}
}
SMonDnodeInfo
dnodeInfo
=
{
0
};
SMonDnodeInfo
dnodeInfo
=
{
0
};
if
(
dndGetDnodeInfo
(
pDnode
,
&
dnodeInfo
)
==
0
)
{
dndGetMonitorDnodeInfo
(
pDnode
,
&
dnodeInfo
);
monSetDnodeInfo
(
pMonitor
,
&
dnodeInfo
);
monSetDnodeInfo
(
pMonitor
,
&
dnodeInfo
);
}
SMonDiskInfo
diskInfo
=
{
0
};
SMonDiskInfo
diskInfo
=
{
0
};
if
(
dndGetDiskInfo
(
pDnode
,
&
diskInfo
)
==
0
)
{
if
(
dndGet
Monitor
DiskInfo
(
pDnode
,
&
diskInfo
)
==
0
)
{
monSetDiskInfo
(
pMonitor
,
&
diskInfo
);
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
浏览文件 @
29fab2e3
...
@@ -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/mgmt/impl/src/dndVnodes.c
浏览文件 @
29fab2e3
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
#include "dndVnodes.h"
#include "dndVnodes.h"
#include "dndMgmt.h"
#include "dndMgmt.h"
#include "dndTransport.h"
#include "dndTransport.h"
#include "sync.h"
typedef
struct
{
typedef
struct
{
int32_t
vgId
;
int32_t
vgId
;
...
@@ -85,7 +86,7 @@ static SVnodeObj *dndAcquireVnode(SDnode *pDnode, int32_t vgId) {
...
@@ -85,7 +86,7 @@ static SVnodeObj *dndAcquireVnode(SDnode *pDnode, int32_t vgId) {
int32_t
refCount
=
0
;
int32_t
refCount
=
0
;
taosRLockLatch
(
&
pMgmt
->
latch
);
taosRLockLatch
(
&
pMgmt
->
latch
);
taosHashGet
Clone
(
pMgmt
->
hash
,
&
vgId
,
sizeof
(
int32_t
),
(
void
*
)
&
pVnode
);
taosHashGet
Dup
(
pMgmt
->
hash
,
&
vgId
,
sizeof
(
int32_t
),
(
void
*
)
&
pVnode
);
if
(
pVnode
==
NULL
)
{
if
(
pVnode
==
NULL
)
{
terrno
=
TSDB_CODE_VND_INVALID_VGROUP_ID
;
terrno
=
TSDB_CODE_VND_INVALID_VGROUP_ID
;
}
else
{
}
else
{
...
@@ -979,6 +980,8 @@ void dndCleanupVnodes(SDnode *pDnode) {
...
@@ -979,6 +980,8 @@ void dndCleanupVnodes(SDnode *pDnode) {
void
dndGetVnodeLoads
(
SDnode
*
pDnode
,
SArray
*
pLoads
)
{
void
dndGetVnodeLoads
(
SDnode
*
pDnode
,
SArray
*
pLoads
)
{
SVnodesMgmt
*
pMgmt
=
&
pDnode
->
vmgmt
;
SVnodesMgmt
*
pMgmt
=
&
pDnode
->
vmgmt
;
int32_t
totalVnodes
=
0
;
int32_t
masterNum
=
0
;
taosRLockLatch
(
&
pMgmt
->
latch
);
taosRLockLatch
(
&
pMgmt
->
latch
);
...
@@ -993,8 +996,12 @@ void dndGetVnodeLoads(SDnode *pDnode, SArray *pLoads) {
...
@@ -993,8 +996,12 @@ void dndGetVnodeLoads(SDnode *pDnode, SArray *pLoads) {
vnodeGetLoad
(
pVnode
->
pImpl
,
&
vload
);
vnodeGetLoad
(
pVnode
->
pImpl
,
&
vload
);
taosArrayPush
(
pLoads
,
&
vload
);
taosArrayPush
(
pLoads
,
&
vload
);
totalVnodes
++
;
if
(
vload
.
role
==
TAOS_SYNC_STATE_LEADER
)
masterNum
++
;
pIter
=
taosHashIterate
(
pMgmt
->
hash
,
pIter
);
pIter
=
taosHashIterate
(
pMgmt
->
hash
,
pIter
);
}
}
taosRUnLockLatch
(
&
pMgmt
->
latch
);
taosRUnLockLatch
(
&
pMgmt
->
latch
);
pMgmt
->
totalVnodes
=
totalVnodes
;
pMgmt
->
masterNum
=
masterNum
;
}
}
source/dnode/mgmt/impl/test/sut/src/client.cpp
浏览文件 @
29fab2e3
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
*/
*/
#include "sut.h"
#include "sut.h"
#include "t
ep
.h"
#include "t
datablock
.h"
static
void
processClientRsp
(
void
*
parent
,
SRpcMsg
*
pRsp
,
SEpSet
*
pEpSet
)
{
static
void
processClientRsp
(
void
*
parent
,
SRpcMsg
*
pRsp
,
SEpSet
*
pEpSet
)
{
TestClient
*
client
=
(
TestClient
*
)
parent
;
TestClient
*
client
=
(
TestClient
*
)
parent
;
...
...
source/dnode/mgmt/impl/test/sut/src/sut.cpp
浏览文件 @
29fab2e3
...
@@ -28,7 +28,7 @@ void Testbase::InitLog(const char* path) {
...
@@ -28,7 +28,7 @@ void Testbase::InitLog(const char* path) {
wDebugFlag
=
0
;
wDebugFlag
=
0
;
sDebugFlag
=
0
;
sDebugFlag
=
0
;
tsdbDebugFlag
=
0
;
tsdbDebugFlag
=
0
;
ts
cEmbeddedInUtil
=
1
;
ts
LogEmbedded
=
1
;
tsAsyncLog
=
0
;
tsAsyncLog
=
0
;
taosRemoveDir
(
path
);
taosRemoveDir
(
path
);
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
29fab2e3
...
@@ -34,46 +34,6 @@
...
@@ -34,46 +34,6 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
extern
int32_t
mDebugFlag
;
// mnode log function
#define mFatal(...) \
{ \
if (mDebugFlag & DEBUG_FATAL) { \
taosPrintLog("MND FATAL ", 255, __VA_ARGS__); \
} \
}
#define mError(...) \
{ \
if (mDebugFlag & DEBUG_ERROR) { \
taosPrintLog("MND ERROR ", 255, __VA_ARGS__); \
} \
}
#define mWarn(...) \
{ \
if (mDebugFlag & DEBUG_WARN) { \
taosPrintLog("MND WARN ", 255, __VA_ARGS__); \
} \
}
#define mInfo(...) \
{ \
if (mDebugFlag & DEBUG_INFO) { \
taosPrintLog("MND ", 255, __VA_ARGS__); \
} \
}
#define mDebug(...) \
{ \
if (mDebugFlag & DEBUG_DEBUG) { \
taosPrintLog("MND ", mDebugFlag, __VA_ARGS__); \
} \
}
#define mTrace(...) \
{ \
if (mDebugFlag & DEBUG_TRACE) { \
taosPrintLog("MND ", mDebugFlag, __VA_ARGS__); \
} \
}
typedef
enum
{
typedef
enum
{
MND_AUTH_ACCT_START
=
0
,
MND_AUTH_ACCT_START
=
0
,
MND_AUTH_ACCT_USER
,
MND_AUTH_ACCT_USER
,
...
...
source/dnode/mnode/impl/inc/mndInt.h
浏览文件 @
29fab2e3
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
#include "sdb.h"
#include "sdb.h"
#include "tcache.h"
#include "tcache.h"
#include "t
ep
.h"
#include "t
datablock
.h"
#include "tglobal.h"
#include "tglobal.h"
#include "tqueue.h"
#include "tqueue.h"
#include "ttime.h"
#include "ttime.h"
...
@@ -31,6 +31,13 @@
...
@@ -31,6 +31,13 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
#define mFatal(...) { if (mDebugFlag & DEBUG_FATAL) { taosPrintLog("MND FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }}
#define mError(...) { if (mDebugFlag & DEBUG_ERROR) { taosPrintLog("MND ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }}
#define mWarn(...) { if (mDebugFlag & DEBUG_WARN) { taosPrintLog("MND WARN ", DEBUG_WARN, 255, __VA_ARGS__); }}
#define mInfo(...) { if (mDebugFlag & DEBUG_INFO) { taosPrintLog("MND ", DEBUG_INFO, 255, __VA_ARGS__); }}
#define mDebug(...) { if (mDebugFlag & DEBUG_DEBUG) { taosPrintLog("MND ", DEBUG_DEBUG, mDebugFlag, __VA_ARGS__); }}
#define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", DEBUG_TRACE, mDebugFlag, __VA_ARGS__); }}
typedef
int32_t
(
*
MndMsgFp
)(
SMnodeMsg
*
pMsg
);
typedef
int32_t
(
*
MndMsgFp
)(
SMnodeMsg
*
pMsg
);
typedef
int32_t
(
*
MndInitFp
)(
SMnode
*
pMnode
);
typedef
int32_t
(
*
MndInitFp
)(
SMnode
*
pMnode
);
typedef
void
(
*
MndCleanupFp
)(
SMnode
*
pMnode
);
typedef
void
(
*
MndCleanupFp
)(
SMnode
*
pMnode
);
...
@@ -85,6 +92,11 @@ typedef struct {
...
@@ -85,6 +92,11 @@ typedef struct {
ESyncState
state
;
ESyncState
state
;
}
SSyncMgmt
;
}
SSyncMgmt
;
typedef
struct
{
int64_t
expireTimeMS
;
int64_t
timeseriesAllowed
;
}
SGrantInfo
;
typedef
struct
SMnode
{
typedef
struct
SMnode
{
int32_t
dnodeId
;
int32_t
dnodeId
;
int64_t
clusterId
;
int64_t
clusterId
;
...
@@ -105,6 +117,7 @@ typedef struct SMnode {
...
@@ -105,6 +117,7 @@ typedef struct SMnode {
STelemMgmt
telemMgmt
;
STelemMgmt
telemMgmt
;
SSyncMgmt
syncMgmt
;
SSyncMgmt
syncMgmt
;
SHashObj
*
infosMeta
;
SHashObj
*
infosMeta
;
SGrantInfo
grant
;
MndMsgFp
msgFp
[
TDMT_MAX
];
MndMsgFp
msgFp
[
TDMT_MAX
];
SendReqToDnodeFp
sendReqToDnodeFp
;
SendReqToDnodeFp
sendReqToDnodeFp
;
SendReqToMnodeFp
sendReqToMnodeFp
;
SendReqToMnodeFp
sendReqToMnodeFp
;
...
@@ -120,7 +133,7 @@ void mndSetMsgHandle(SMnode *pMnode, tmsg_t msgType, MndMsgFp fp);
...
@@ -120,7 +133,7 @@ void mndSetMsgHandle(SMnode *pMnode, tmsg_t msgType, MndMsgFp fp);
uint64_t
mndGenerateUid
(
char
*
name
,
int32_t
len
);
uint64_t
mndGenerateUid
(
char
*
name
,
int32_t
len
);
int32_t
mndGetLoad
(
SMnode
*
pMnode
,
SMnodeLoad
*
pLoad
);
void
mndGetLoad
(
SMnode
*
pMnode
,
SMnodeLoad
*
pLoad
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/dnode/mnode/impl/inc/mndProfile.h
浏览文件 @
29fab2e3
...
@@ -24,6 +24,7 @@ extern "C" {
...
@@ -24,6 +24,7 @@ extern "C" {
int32_t
mndInitProfile
(
SMnode
*
pMnode
);
int32_t
mndInitProfile
(
SMnode
*
pMnode
);
void
mndCleanupProfile
(
SMnode
*
pMnode
);
void
mndCleanupProfile
(
SMnode
*
pMnode
);
int32_t
mndGetNumOfConnections
(
SMnode
*
pMnode
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/dnode/mnode/impl/src/mndMnode.c
浏览文件 @
29fab2e3
...
@@ -99,11 +99,15 @@ void mndUpdateMnodeRole(SMnode *pMnode) {
...
@@ -99,11 +99,15 @@ void mndUpdateMnodeRole(SMnode *pMnode) {
pIter
=
sdbFetch
(
pSdb
,
SDB_MNODE
,
pIter
,
(
void
**
)
&
pObj
);
pIter
=
sdbFetch
(
pSdb
,
SDB_MNODE
,
pIter
,
(
void
**
)
&
pObj
);
if
(
pIter
==
NULL
)
break
;
if
(
pIter
==
NULL
)
break
;
ESyncState
lastRole
=
pObj
->
role
;
if
(
pObj
->
id
==
1
)
{
if
(
pObj
->
id
==
1
)
{
pObj
->
role
=
TAOS_SYNC_STATE_LEADER
;
pObj
->
role
=
TAOS_SYNC_STATE_LEADER
;
}
else
{
}
else
{
pObj
->
role
=
TAOS_SYNC_STATE_CANDIDATE
;
pObj
->
role
=
TAOS_SYNC_STATE_CANDIDATE
;
}
}
if
(
pObj
->
role
!=
lastRole
)
{
pObj
->
roleTime
=
taosGetTimestampMs
();
}
sdbRelease
(
pSdb
,
pObj
);
sdbRelease
(
pSdb
,
pObj
);
}
}
...
...
source/dnode/mnode/impl/src/mndProfile.c
浏览文件 @
29fab2e3
...
@@ -48,7 +48,7 @@ static SConnObj *mndCreateConn(SMnode *pMnode, SRpcConnInfo *pInfo, int32_t pid,
...
@@ -48,7 +48,7 @@ static SConnObj *mndCreateConn(SMnode *pMnode, SRpcConnInfo *pInfo, int32_t pid,
static
void
mndFreeConn
(
SConnObj
*
pConn
);
static
void
mndFreeConn
(
SConnObj
*
pConn
);
static
SConnObj
*
mndAcquireConn
(
SMnode
*
pMnode
,
int32_t
connId
);
static
SConnObj
*
mndAcquireConn
(
SMnode
*
pMnode
,
int32_t
connId
);
static
void
mndReleaseConn
(
SMnode
*
pMnode
,
SConnObj
*
pConn
);
static
void
mndReleaseConn
(
SMnode
*
pMnode
,
SConnObj
*
pConn
);
static
void
*
mndGetNextConn
(
SMnode
*
pMnode
,
void
*
pIter
,
SConnObj
**
pConn
);
static
void
*
mndGetNextConn
(
SMnode
*
pMnode
,
SCacheIter
*
pIter
);
static
void
mndCancelGetNextConn
(
SMnode
*
pMnode
,
void
*
pIter
);
static
void
mndCancelGetNextConn
(
SMnode
*
pMnode
,
void
*
pIter
);
static
int32_t
mndProcessHeartBeatReq
(
SMnodeMsg
*
pReq
);
static
int32_t
mndProcessHeartBeatReq
(
SMnodeMsg
*
pReq
);
static
int32_t
mndProcessConnectReq
(
SMnodeMsg
*
pReq
);
static
int32_t
mndProcessConnectReq
(
SMnodeMsg
*
pReq
);
...
@@ -158,27 +158,23 @@ static void mndReleaseConn(SMnode *pMnode, SConnObj *pConn) {
...
@@ -158,27 +158,23 @@ static void mndReleaseConn(SMnode *pMnode, SConnObj *pConn) {
taosCacheRelease
(
pMgmt
->
cache
,
(
void
**
)
&
pConn
,
false
);
taosCacheRelease
(
pMgmt
->
cache
,
(
void
**
)
&
pConn
,
false
);
}
}
static
void
*
mndGetNextConn
(
SMnode
*
pMnode
,
void
*
pIter
,
SConnObj
**
pConn
)
{
void
*
mndGetNextConn
(
SMnode
*
pMnode
,
SCacheIter
*
pIter
)
{
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SConnObj
*
pConn
=
NULL
;
bool
hasNext
=
taosCacheIterNext
(
pIter
);
*
pConn
=
NULL
;
if
(
hasNext
)
{
size_t
dataLen
=
0
;
pIter
=
taosHashIterate
(
pMgmt
->
cache
->
pHashTable
,
pIter
);
pConn
=
taosCacheIterGetData
(
pIter
,
&
dataLen
);
if
(
pIter
==
NULL
)
return
NULL
;
}
else
{
taosCacheDestroyIter
(
pIter
);
SCacheDataNode
**
pNode
=
pIter
;
if
(
pNode
==
NULL
||
*
pNode
==
NULL
)
{
taosHashCancelIterate
(
pMgmt
->
cache
->
pHashTable
,
pIter
);
return
NULL
;
}
}
*
pConn
=
(
SConnObj
*
)((
*
pNode
)
->
data
);
return
pConn
;
return
pIter
;
}
}
static
void
mndCancelGetNextConn
(
SMnode
*
pMnode
,
void
*
pIter
)
{
static
void
mndCancelGetNextConn
(
SMnode
*
pMnode
,
void
*
pIter
)
{
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
if
(
pIter
!=
NULL
)
{
taosHashCancelIterate
(
pMgmt
->
cache
->
pHashTable
,
pIter
);
taosCacheDestroyIter
(
pIter
);
}
}
}
static
int32_t
mndProcessConnectReq
(
SMnodeMsg
*
pReq
)
{
static
int32_t
mndProcessConnectReq
(
SMnodeMsg
*
pReq
)
{
...
@@ -376,8 +372,8 @@ static int32_t mndProcessHeartBeatReq(SMnodeMsg *pReq) {
...
@@ -376,8 +372,8 @@ static int32_t mndProcessHeartBeatReq(SMnodeMsg *pReq) {
int32_t
rspLen
=
0
;
int32_t
rspLen
=
0
;
mndValidateDbInfo
(
pMnode
,
kv
->
value
,
kv
->
valueLen
/
sizeof
(
SDbVgVersion
),
&
rspMsg
,
&
rspLen
);
mndValidateDbInfo
(
pMnode
,
kv
->
value
,
kv
->
valueLen
/
sizeof
(
SDbVgVersion
),
&
rspMsg
,
&
rspLen
);
if
(
rspMsg
&&
rspLen
>
0
)
{
if
(
rspMsg
&&
rspLen
>
0
)
{
SKv
kv
=
{.
key
=
HEARTBEAT_KEY_DBINFO
,
.
valueLen
=
rspLen
,
.
value
=
rspMsg
};
SKv
kv
1
=
{.
key
=
HEARTBEAT_KEY_DBINFO
,
.
valueLen
=
rspLen
,
.
value
=
rspMsg
};
taosArrayPush
(
hbRsp
.
info
,
&
kv
);
taosArrayPush
(
hbRsp
.
info
,
&
kv
1
);
}
}
break
;
break
;
}
}
...
@@ -386,8 +382,8 @@ static int32_t mndProcessHeartBeatReq(SMnodeMsg *pReq) {
...
@@ -386,8 +382,8 @@ static int32_t mndProcessHeartBeatReq(SMnodeMsg *pReq) {
int32_t
rspLen
=
0
;
int32_t
rspLen
=
0
;
mndValidateStbInfo
(
pMnode
,
kv
->
value
,
kv
->
valueLen
/
sizeof
(
SSTableMetaVersion
),
&
rspMsg
,
&
rspLen
);
mndValidateStbInfo
(
pMnode
,
kv
->
value
,
kv
->
valueLen
/
sizeof
(
SSTableMetaVersion
),
&
rspMsg
,
&
rspLen
);
if
(
rspMsg
&&
rspLen
>
0
)
{
if
(
rspMsg
&&
rspLen
>
0
)
{
SKv
kv
=
{.
key
=
HEARTBEAT_KEY_STBINFO
,
.
valueLen
=
rspLen
,
.
value
=
rspMsg
};
SKv
kv
1
=
{.
key
=
HEARTBEAT_KEY_STBINFO
,
.
valueLen
=
rspLen
,
.
value
=
rspMsg
};
taosArrayPush
(
hbRsp
.
info
,
&
kv
);
taosArrayPush
(
hbRsp
.
info
,
&
kv
1
);
}
}
break
;
break
;
}
}
...
@@ -638,7 +634,7 @@ static int32_t mndGetConnsMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp *
...
@@ -638,7 +634,7 @@ static int32_t mndGetConnsMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp *
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
pShow
->
offset
[
i
]
=
pShow
->
offset
[
i
-
1
]
+
pShow
->
bytes
[
i
-
1
];
}
}
pShow
->
numOfRows
=
taos
HashGetSize
(
pMgmt
->
cache
->
pHashTabl
e
);
pShow
->
numOfRows
=
taos
CacheGetNumOfObj
(
pMgmt
->
cach
e
);
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
tbName
,
mndShowStr
(
pShow
->
type
));
strcpy
(
pMeta
->
tbName
,
mndShowStr
(
pShow
->
type
));
...
@@ -653,8 +649,13 @@ static int32_t mndRetrieveConns(SMnodeMsg *pReq, SShowObj *pShow, char *data, in
...
@@ -653,8 +649,13 @@ static int32_t mndRetrieveConns(SMnodeMsg *pReq, SShowObj *pShow, char *data, in
char
*
pWrite
;
char
*
pWrite
;
char
ipStr
[
TSDB_IPv4ADDR_LEN
+
6
];
char
ipStr
[
TSDB_IPv4ADDR_LEN
+
6
];
if
(
pShow
->
pIter
==
NULL
)
{
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
pShow
->
pIter
=
taosCacheCreateIter
(
pMgmt
->
cache
);
}
while
(
numOfRows
<
rows
)
{
while
(
numOfRows
<
rows
)
{
p
Show
->
pIter
=
mndGetNextConn
(
pMnode
,
pShow
->
pIter
,
&
pConn
);
p
Conn
=
mndGetNextConn
(
pMnode
,
pShow
->
pIter
);
if
(
pConn
==
NULL
)
break
;
if
(
pConn
==
NULL
)
break
;
cols
=
0
;
cols
=
0
;
...
@@ -823,19 +824,24 @@ static int32_t mndRetrieveQueries(SMnodeMsg *pReq, SShowObj *pShow, char *data,
...
@@ -823,19 +824,24 @@ static int32_t mndRetrieveQueries(SMnodeMsg *pReq, SShowObj *pShow, char *data,
void
*
pIter
;
void
*
pIter
;
char
str
[
TSDB_IPv4ADDR_LEN
+
6
]
=
{
0
};
char
str
[
TSDB_IPv4ADDR_LEN
+
6
]
=
{
0
};
if
(
pShow
->
pIter
==
NULL
)
{
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
pShow
->
pIter
=
taosCacheCreateIter
(
pMgmt
->
cache
);
}
while
(
numOfRows
<
rows
)
{
while
(
numOfRows
<
rows
)
{
p
Iter
=
mndGetNextConn
(
pMnode
,
pShow
->
pIter
,
&
pConn
);
p
Conn
=
mndGetNextConn
(
pMnode
,
pShow
->
pIter
);
if
(
pConn
==
NULL
)
{
if
(
pConn
==
NULL
)
{
pShow
->
pIter
=
pIter
;
pShow
->
pIter
=
NULL
;
break
;
break
;
}
}
if
(
numOfRows
+
pConn
->
numOfQueries
>=
rows
)
{
if
(
numOfRows
+
pConn
->
numOfQueries
>=
rows
)
{
mndCancelGetNextConn
(
pMnode
,
pIter
);
taosCacheDestroyIter
(
pShow
->
pIter
);
pShow
->
pIter
=
NULL
;
break
;
break
;
}
}
pShow
->
pIter
=
pIter
;
for
(
int32_t
i
=
0
;
i
<
pConn
->
numOfQueries
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pConn
->
numOfQueries
;
++
i
)
{
SQueryDesc
*
pDesc
=
pConn
->
pQueries
+
i
;
SQueryDesc
*
pDesc
=
pConn
->
pQueries
+
i
;
cols
=
0
;
cols
=
0
;
...
@@ -913,6 +919,12 @@ static int32_t mndRetrieveQueries(SMnodeMsg *pReq, SShowObj *pShow, char *data,
...
@@ -913,6 +919,12 @@ static int32_t mndRetrieveQueries(SMnodeMsg *pReq, SShowObj *pShow, char *data,
}
}
static
void
mndCancelGetNextQuery
(
SMnode
*
pMnode
,
void
*
pIter
)
{
static
void
mndCancelGetNextQuery
(
SMnode
*
pMnode
,
void
*
pIter
)
{
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
if
(
pIter
!=
NULL
)
{
taosHashCancelIterate
(
pMgmt
->
cache
->
pHashTable
,
pIter
);
taosCacheDestroyIter
(
pIter
);
}
}
}
int32_t
mndGetNumOfConnections
(
SMnode
*
pMnode
)
{
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
return
taosCacheGetNumOfObj
(
pMgmt
->
cache
);
}
\ No newline at end of file
source/dnode/mnode/impl/src/mndTelem.c
浏览文件 @
29fab2e3
...
@@ -18,15 +18,15 @@
...
@@ -18,15 +18,15 @@
#include "mndCluster.h"
#include "mndCluster.h"
#include "mndSync.h"
#include "mndSync.h"
#include "tbuffer.h"
#include "tbuffer.h"
#include "tjson.h"
#include "thttp.h"
#include "thttp.h"
#include "tjson.h"
#define TELEMETRY_SERVER "telemetry.taosdata.com"
#define TELEMETRY_SERVER "telemetry.taosdata.com"
#define TELEMETRY_PORT 80
#define TELEMETRY_PORT 80
static
void
mndBuildRuntimeInfo
(
SMnode
*
pMnode
,
SJson
*
pJson
)
{
static
void
mndBuildRuntimeInfo
(
SMnode
*
pMnode
,
SJson
*
pJson
)
{
SMnodeLoad
load
=
{
0
};
SMnodeLoad
load
=
{
0
};
if
(
mndGetLoad
(
pMnode
,
&
load
)
!=
0
)
return
;
mndGetLoad
(
pMnode
,
&
load
)
;
tjsonAddDoubleToObject
(
pJson
,
"numOfDnode"
,
load
.
numOfDnode
);
tjsonAddDoubleToObject
(
pJson
,
"numOfDnode"
,
load
.
numOfDnode
);
tjsonAddDoubleToObject
(
pJson
,
"numOfMnode"
,
load
.
numOfMnode
);
tjsonAddDoubleToObject
(
pJson
,
"numOfMnode"
,
load
.
numOfMnode
);
...
@@ -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/mnode/impl/src/mnode.c
浏览文件 @
29fab2e3
...
@@ -359,6 +359,7 @@ SMnode *mndOpen(const char *path, const SMnodeOpt *pOption) {
...
@@ -359,6 +359,7 @@ SMnode *mndOpen(const char *path, const SMnodeOpt *pOption) {
return
NULL
;
return
NULL
;
}
}
mndUpdateMnodeRole
(
pMnode
);
mDebug
(
"mnode open successfully "
);
mDebug
(
"mnode open successfully "
);
return
pMnode
;
return
pMnode
;
}
}
...
@@ -385,26 +386,6 @@ void mndDestroy(const char *path) {
...
@@ -385,26 +386,6 @@ void mndDestroy(const char *path) {
mDebug
(
"mnode is destroyed"
);
mDebug
(
"mnode is destroyed"
);
}
}
int32_t
mndGetLoad
(
SMnode
*
pMnode
,
SMnodeLoad
*
pLoad
)
{
pLoad
->
numOfDnode
=
0
;
pLoad
->
numOfMnode
=
0
;
pLoad
->
numOfVgroup
=
0
;
pLoad
->
numOfDatabase
=
0
;
pLoad
->
numOfSuperTable
=
0
;
pLoad
->
numOfChildTable
=
0
;
pLoad
->
numOfColumn
=
0
;
pLoad
->
totalPoints
=
0
;
pLoad
->
totalStorage
=
0
;
pLoad
->
compStorage
=
0
;
return
0
;
}
int32_t
mndGetMonitorInfo
(
SMnode
*
pMnode
,
SMonClusterInfo
*
pClusterInfo
,
SMonVgroupInfo
*
pVgroupInfo
,
SMonGrantInfo
*
pGrantInfo
)
{
return
0
;
}
SMnodeMsg
*
mndInitMsg
(
SMnode
*
pMnode
,
SRpcMsg
*
pRpcMsg
)
{
SMnodeMsg
*
mndInitMsg
(
SMnode
*
pMnode
,
SRpcMsg
*
pRpcMsg
)
{
SMnodeMsg
*
pMsg
=
taosAllocateQitem
(
sizeof
(
SMnodeMsg
));
SMnodeMsg
*
pMsg
=
taosAllocateQitem
(
sizeof
(
SMnodeMsg
));
if
(
pMsg
==
NULL
)
{
if
(
pMsg
==
NULL
)
{
...
@@ -523,3 +504,131 @@ uint64_t mndGenerateUid(char *name, int32_t len) {
...
@@ -523,3 +504,131 @@ uint64_t mndGenerateUid(char *name, int32_t len) {
}
}
}
while
(
true
);
}
while
(
true
);
}
}
void
mndGetLoad
(
SMnode
*
pMnode
,
SMnodeLoad
*
pLoad
)
{
memset
(
pLoad
,
0
,
sizeof
(
SMnodeLoad
));
SSdb
*
pSdb
=
pMnode
->
pSdb
;
pLoad
->
numOfDnode
=
sdbGetSize
(
pSdb
,
SDB_DNODE
);
pLoad
->
numOfMnode
=
sdbGetSize
(
pSdb
,
SDB_MNODE
);
pLoad
->
numOfVgroup
=
sdbGetSize
(
pSdb
,
SDB_VGROUP
);
pLoad
->
numOfDatabase
=
sdbGetSize
(
pSdb
,
SDB_DB
);
pLoad
->
numOfSuperTable
=
sdbGetSize
(
pSdb
,
SDB_STB
);
void
*
pIter
=
NULL
;
while
(
1
)
{
SVgObj
*
pVgroup
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_VGROUP
,
pIter
,
(
void
**
)
&
pVgroup
);
if
(
pIter
==
NULL
)
break
;
pLoad
->
numOfChildTable
+=
pVgroup
->
numOfTables
;
pLoad
->
numOfColumn
+=
pVgroup
->
numOfTimeSeries
;
pLoad
->
totalPoints
+=
pVgroup
->
pointsWritten
;
pLoad
->
totalStorage
+=
pVgroup
->
totalStorage
;
pLoad
->
compStorage
+=
pVgroup
->
compStorage
;
sdbRelease
(
pSdb
,
pVgroup
);
}
}
int32_t
mndGetMonitorInfo
(
SMnode
*
pMnode
,
SMonClusterInfo
*
pClusterInfo
,
SMonVgroupInfo
*
pVgroupInfo
,
SMonGrantInfo
*
pGrantInfo
)
{
if
(
!
mndIsMaster
(
pMnode
))
return
-
1
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int64_t
ms
=
taosGetTimestampMs
();
pClusterInfo
->
dnodes
=
taosArrayInit
(
sdbGetSize
(
pSdb
,
SDB_DNODE
),
sizeof
(
SMonDnodeDesc
));
pClusterInfo
->
mnodes
=
taosArrayInit
(
sdbGetSize
(
pSdb
,
SDB_MNODE
),
sizeof
(
SMonMnodeDesc
));
pVgroupInfo
->
vgroups
=
taosArrayInit
(
sdbGetSize
(
pSdb
,
SDB_VGROUP
),
sizeof
(
SMonVgroupDesc
));
if
(
pClusterInfo
->
dnodes
==
NULL
||
pClusterInfo
->
mnodes
==
NULL
||
pVgroupInfo
->
vgroups
==
NULL
)
{
return
-
1
;
}
// cluster info
tstrncpy
(
pClusterInfo
->
version
,
version
,
sizeof
(
pClusterInfo
->
version
));
pClusterInfo
->
monitor_interval
=
tsMonitorInterval
;
pClusterInfo
->
connections_total
=
mndGetNumOfConnections
(
pMnode
);
void
*
pIter
=
NULL
;
while
(
1
)
{
SDnodeObj
*
pObj
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_DNODE
,
pIter
,
(
void
**
)
&
pObj
);
if
(
pIter
==
NULL
)
break
;
SMonDnodeDesc
desc
=
{
0
};
desc
.
dnode_id
=
pObj
->
id
;
tstrncpy
(
desc
.
dnode_ep
,
pObj
->
ep
,
sizeof
(
desc
.
dnode_ep
));
if
(
mndIsDnodeOnline
(
pMnode
,
pObj
,
ms
))
{
tstrncpy
(
desc
.
status
,
"ready"
,
sizeof
(
desc
.
status
));
}
else
{
tstrncpy
(
desc
.
status
,
"offline"
,
sizeof
(
desc
.
status
));
}
taosArrayPush
(
pClusterInfo
->
dnodes
,
&
desc
);
sdbRelease
(
pSdb
,
pObj
);
}
pIter
=
NULL
;
while
(
1
)
{
SMnodeObj
*
pObj
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_MNODE
,
pIter
,
(
void
**
)
&
pObj
);
if
(
pIter
==
NULL
)
break
;
SMonMnodeDesc
desc
=
{
0
};
desc
.
mnode_id
=
pObj
->
id
;
tstrncpy
(
desc
.
mnode_ep
,
pObj
->
pDnode
->
ep
,
sizeof
(
desc
.
mnode_ep
));
tstrncpy
(
desc
.
role
,
mndGetRoleStr
(
pObj
->
role
),
sizeof
(
desc
.
role
));
taosArrayPush
(
pClusterInfo
->
mnodes
,
&
desc
);
sdbRelease
(
pSdb
,
pObj
);
if
(
pObj
->
role
==
TAOS_SYNC_STATE_LEADER
)
{
pClusterInfo
->
first_ep_dnode_id
=
pObj
->
id
;
tstrncpy
(
pClusterInfo
->
first_ep
,
pObj
->
pDnode
->
ep
,
sizeof
(
pClusterInfo
->
first_ep
));
pClusterInfo
->
master_uptime
=
(
ms
-
pObj
->
roleTime
)
/
(
86400000
.
0
f
);
}
}
// vgroup info
pIter
=
NULL
;
while
(
1
)
{
SVgObj
*
pVgroup
=
NULL
;
pIter
=
sdbFetch
(
pSdb
,
SDB_VGROUP
,
pIter
,
(
void
**
)
&
pVgroup
);
if
(
pIter
==
NULL
)
break
;
pClusterInfo
->
vgroups_total
++
;
SMonVgroupDesc
desc
=
{
0
};
desc
.
vgroup_id
=
pVgroup
->
vgId
;
strncpy
(
desc
.
database_name
,
pVgroup
->
dbName
,
sizeof
(
desc
.
database_name
));
desc
.
tables_num
=
pVgroup
->
numOfTables
;
pGrantInfo
->
timeseries_used
+=
pVgroup
->
numOfTimeSeries
;
tstrncpy
(
desc
.
status
,
"unsynced"
,
sizeof
(
desc
.
status
));
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
replica
;
++
i
)
{
SVnodeGid
*
pVgid
=
&
pVgroup
->
vnodeGid
[
i
];
SMonVnodeDesc
*
pVnDesc
=
&
desc
.
vnodes
[
i
];
pVnDesc
->
dnode_id
=
pVgid
->
dnodeId
;
tstrncpy
(
pVnDesc
->
vnode_role
,
mndGetRoleStr
(
pVgid
->
role
),
sizeof
(
pVnDesc
->
vnode_role
));
if
(
pVgid
->
role
==
TAOS_SYNC_STATE_LEADER
)
{
tstrncpy
(
desc
.
status
,
"ready"
,
sizeof
(
desc
.
status
));
pClusterInfo
->
vgroups_alive
++
;
}
if
(
pVgid
->
role
==
TAOS_SYNC_STATE_LEADER
||
pVgid
->
role
==
TAOS_SYNC_STATE_CANDIDATE
)
{
pClusterInfo
->
vnodes_alive
++
;
}
pClusterInfo
->
vnodes_total
++
;
}
taosArrayPush
(
pVgroupInfo
->
vgroups
,
&
desc
);
sdbRelease
(
pSdb
,
pVgroup
);
}
// grant info
pGrantInfo
->
expire_time
=
(
pMnode
->
grant
.
expireTimeMS
-
ms
)
/
86400000
.
0
f
;
pGrantInfo
->
timeseries_total
=
pMnode
->
grant
.
timeseriesAllowed
;
if
(
pMnode
->
grant
.
expireTimeMS
==
0
)
{
pGrantInfo
->
expire_time
=
INT32_MAX
;
pGrantInfo
->
timeseries_total
=
INT32_MAX
;
}
return
0
;
}
\ No newline at end of file
source/dnode/mnode/sdb/inc/sdbInt.h
浏览文件 @
29fab2e3
...
@@ -28,12 +28,12 @@
...
@@ -28,12 +28,12 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
#define mFatal(...) { if (mDebugFlag & DEBUG_FATAL) { taosPrintLog("MND FATAL ", 255, __VA_ARGS__); }}
#define mFatal(...) { if (mDebugFlag & DEBUG_FATAL) { taosPrintLog("MND FATAL ",
DEBUG_FATAL,
255, __VA_ARGS__); }}
#define mError(...) { if (mDebugFlag & DEBUG_ERROR) { taosPrintLog("MND ERROR ", 255, __VA_ARGS__); }}
#define mError(...) { if (mDebugFlag & DEBUG_ERROR) { taosPrintLog("MND ERROR ",
DEBUG_ERROR,
255, __VA_ARGS__); }}
#define mWarn(...) { if (mDebugFlag & DEBUG_WARN) { taosPrintLog("MND WARN ", 255, __VA_ARGS__); }}
#define mWarn(...) { if (mDebugFlag & DEBUG_WARN) { taosPrintLog("MND WARN ",
DEBUG_WARN,
255, __VA_ARGS__); }}
#define mInfo(...) { if (mDebugFlag & DEBUG_INFO) { taosPrintLog("MND ", 255, __VA_ARGS__); }}
#define mInfo(...) { if (mDebugFlag & DEBUG_INFO) { taosPrintLog("MND ",
DEBUG_INFO,
255, __VA_ARGS__); }}
#define mDebug(...) { if (mDebugFlag & DEBUG_DEBUG) { taosPrintLog("MND ", mDebugFlag, __VA_ARGS__); }}
#define mDebug(...) { if (mDebugFlag & DEBUG_DEBUG) { taosPrintLog("MND ",
DEBUG_DEBUG,
mDebugFlag, __VA_ARGS__); }}
#define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", mDebugFlag, __VA_ARGS__); }}
#define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ",
DEBUG_TRACE,
mDebugFlag, __VA_ARGS__); }}
#define SDB_MAX_SIZE (32 * 1024)
#define SDB_MAX_SIZE (32 * 1024)
...
...
source/dnode/vnode/inc/meta.h
浏览文件 @
29fab2e3
...
@@ -24,8 +24,8 @@
...
@@ -24,8 +24,8 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
#define META_SUPER_TABLE TD_SUPER_TABLE
#define META_SUPER_TABLE
TD_SUPER_TABLE
#define META_CHILD_TABLE TD_CHILD_TABLE
#define META_CHILD_TABLE
TD_CHILD_TABLE
#define META_NORMAL_TABLE TD_NORMAL_TABLE
#define META_NORMAL_TABLE TD_NORMAL_TABLE
// Types exported
// Types exported
...
@@ -50,14 +50,14 @@ int metaDropTable(SMeta *pMeta, tb_uid_t uid);
...
@@ -50,14 +50,14 @@ int metaDropTable(SMeta *pMeta, tb_uid_t uid);
int
metaCommit
(
SMeta
*
pMeta
);
int
metaCommit
(
SMeta
*
pMeta
);
// For Query
// For Query
STbCfg
*
metaGetTbInfoByUid
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
STbCfg
*
metaGetTbInfoByUid
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
STbCfg
*
metaGetTbInfoByName
(
SMeta
*
pMeta
,
char
*
tbname
,
tb_uid_t
*
uid
);
STbCfg
*
metaGetTbInfoByName
(
SMeta
*
pMeta
,
char
*
tbname
,
tb_uid_t
*
uid
);
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
,
bool
isinline
);
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
,
bool
isinline
);
STSchema
*
metaGetTbTSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
);
STSchema
*
metaGetTbTSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
);
SMTbCursor
*
metaOpenTbCursor
(
SMeta
*
pMeta
);
SMTbCursor
*
metaOpenTbCursor
(
SMeta
*
pMeta
);
void
metaCloseTbCursor
(
SMTbCursor
*
pTbCur
);
void
metaCloseTbCursor
(
SMTbCursor
*
pTbCur
);
char
*
metaTbCursorNext
(
SMTbCursor
*
pTbCur
);
char
*
metaTbCursorNext
(
SMTbCursor
*
pTbCur
);
SMCtbCursor
*
metaOpenCtbCursor
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
SMCtbCursor
*
metaOpenCtbCursor
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
void
metaCloseCtbCurosr
(
SMCtbCursor
*
pCtbCur
);
void
metaCloseCtbCurosr
(
SMCtbCursor
*
pCtbCur
);
...
...
source/dnode/vnode/inc/vnode.h
浏览文件 @
29fab2e3
...
@@ -213,6 +213,10 @@ static FORCE_INLINE void tqReadHandleSetColIdList(STqReadHandle *pReadHandle, SA
...
@@ -213,6 +213,10 @@ static FORCE_INLINE void tqReadHandleSetColIdList(STqReadHandle *pReadHandle, SA
//}
//}
static
FORCE_INLINE
int
tqReadHandleSetTbUidList
(
STqReadHandle
*
pHandle
,
const
SArray
*
tbUidList
)
{
static
FORCE_INLINE
int
tqReadHandleSetTbUidList
(
STqReadHandle
*
pHandle
,
const
SArray
*
tbUidList
)
{
if
(
pHandle
->
tbIdHash
)
{
taosHashClear
(
pHandle
->
tbIdHash
);
}
pHandle
->
tbIdHash
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
true
,
HASH_NO_LOCK
);
pHandle
->
tbIdHash
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
true
,
HASH_NO_LOCK
);
if
(
pHandle
->
tbIdHash
==
NULL
)
{
if
(
pHandle
->
tbIdHash
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
@@ -227,6 +231,23 @@ static FORCE_INLINE int tqReadHandleSetTbUidList(STqReadHandle *pHandle, const S
...
@@ -227,6 +231,23 @@ static FORCE_INLINE int tqReadHandleSetTbUidList(STqReadHandle *pHandle, const S
return
0
;
return
0
;
}
}
static
FORCE_INLINE
int
tqReadHandleAddTbUidList
(
STqReadHandle
*
pHandle
,
const
SArray
*
tbUidList
)
{
if
(
pHandle
->
tbIdHash
==
NULL
)
{
pHandle
->
tbIdHash
=
taosHashInit
(
64
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
true
,
HASH_NO_LOCK
);
if
(
pHandle
->
tbIdHash
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
}
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
tbUidList
);
i
++
)
{
int64_t
*
pKey
=
(
int64_t
*
)
taosArrayGet
(
tbUidList
,
i
);
taosHashPut
(
pHandle
->
tbIdHash
,
pKey
,
sizeof
(
int64_t
),
NULL
,
0
);
}
return
0
;
}
int32_t
tqReadHandleSetMsg
(
STqReadHandle
*
pHandle
,
SSubmitReq
*
pMsg
,
int64_t
ver
);
int32_t
tqReadHandleSetMsg
(
STqReadHandle
*
pHandle
,
SSubmitReq
*
pMsg
,
int64_t
ver
);
bool
tqNextDataBlock
(
STqReadHandle
*
pHandle
);
bool
tqNextDataBlock
(
STqReadHandle
*
pHandle
);
int
tqRetrieveDataBlockInfo
(
STqReadHandle
*
pHandle
,
SDataBlockInfo
*
pBlockInfo
);
int
tqRetrieveDataBlockInfo
(
STqReadHandle
*
pHandle
,
SDataBlockInfo
*
pBlockInfo
);
...
...
source/dnode/vnode/src/inc/metaDef.h
浏览文件 @
29fab2e3
...
@@ -76,4 +76,4 @@ struct SMeta {
...
@@ -76,4 +76,4 @@ struct SMeta {
}
}
#endif
#endif
#endif
/*_TD_META_DEF_H_*/
#endif
/*_TD_META_DEF_H_*/
\ No newline at end of file
source/dnode/vnode/src/inc/tqInt.h
浏览文件 @
29fab2e3
...
@@ -25,43 +25,41 @@
...
@@ -25,43 +25,41 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
extern
int32_t
tqDebugFlag
;
#define tqFatal(...) \
{ \
#define tqFatal(...) \
if (tqDebugFlag & DEBUG_FATAL) { \
{ \
taosPrintLog("TQ FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); \
if (tqDebugFlag & DEBUG_FATAL) { \
} \
taosPrintLog("TQ FATAL ", 255, __VA_ARGS__); \
} \
}
}
#define tqError(...) \
#define tqError(...)
\
{ \
{
\
if (tqDebugFlag & DEBUG_ERROR) { \
if (tqDebugFlag & DEBUG_ERROR) {
\
taosPrintLog("TQ ERROR ", 255, __VA_ARGS__); \
taosPrintLog("TQ ERROR ",
DEBUG_ERROR,
255, __VA_ARGS__); \
} \
}
\
}
}
#define tqWarn(...) \
#define tqWarn(...)
\
{ \
{
\
if (tqDebugFlag & DEBUG_WARN) { \
if (tqDebugFlag & DEBUG_WARN) {
\
taosPrintLog("TQ WARN ", 255, __VA_ARGS__); \
taosPrintLog("TQ WARN ",
DEBUG_WARN,
255, __VA_ARGS__); \
} \
}
\
}
}
#define tqInfo(...) \
#define tqInfo(...)
\
{ \
{
\
if (tqDebugFlag & DEBUG_INFO) { \
if (tqDebugFlag & DEBUG_INFO) {
\
taosPrintLog("TQ ", 255, __VA_ARGS__); \
taosPrintLog("TQ ",
DEBUG_INFO,
255, __VA_ARGS__); \
} \
}
\
}
}
#define tqDebug(...) \
#define tqDebug(...)
\
{ \
{
\
if (tqDebugFlag & DEBUG_DEBUG) { \
if (tqDebugFlag & DEBUG_DEBUG) {
\
taosPrintLog("TQ ", tqDebugFlag, __VA_ARGS__); \
taosPrintLog("TQ ",
DEBUG_DEBUG,
tqDebugFlag, __VA_ARGS__); \
} \
}
\
}
}
#define tqTrace(...) \
#define tqTrace(...)
\
{ \
{
\
if (tqDebugFlag & DEBUG_TRACE) { \
if (tqDebugFlag & DEBUG_TRACE) {
\
taosPrintLog("TQ ", tqDebugFlag, __VA_ARGS__); \
taosPrintLog("TQ ",
DEBUG_TRACE,
tqDebugFlag, __VA_ARGS__); \
} \
}
\
}
}
#define TQ_BUFFER_SIZE 8
#define TQ_BUFFER_SIZE 8
...
...
source/dnode/vnode/src/inc/tsdbLog.h
浏览文件 @
29fab2e3
...
@@ -20,11 +20,11 @@
...
@@ -20,11 +20,11 @@
extern
int32_t
tsdbDebugFlag
;
extern
int32_t
tsdbDebugFlag
;
#define tsdbFatal(...) do { if (tsdbDebugFlag & DEBUG_FATAL) { taosPrintLog("TDB FATAL ", 255, __VA_ARGS__); }} while(0)
#define tsdbFatal(...) do { if (tsdbDebugFlag & DEBUG_FATAL) { taosPrintLog("TDB FATAL ",
DEBUG_FATAL,
255, __VA_ARGS__); }} while(0)
#define tsdbError(...) do { if (tsdbDebugFlag & DEBUG_ERROR) { taosPrintLog("TDB ERROR ", 255, __VA_ARGS__); }} while(0)
#define tsdbError(...) do { if (tsdbDebugFlag & DEBUG_ERROR) { taosPrintLog("TDB ERROR ",
DEBUG_ERROR,
255, __VA_ARGS__); }} while(0)
#define tsdbWarn(...) do { if (tsdbDebugFlag & DEBUG_WARN) { taosPrintLog("TDB WARN ", 255, __VA_ARGS__); }} while(0)
#define tsdbWarn(...) do { if (tsdbDebugFlag & DEBUG_WARN) { taosPrintLog("TDB WARN ",
DEBUG_WARN,
255, __VA_ARGS__); }} while(0)
#define tsdbInfo(...) do { if (tsdbDebugFlag & DEBUG_INFO) { taosPrintLog("TDB ", 255, __VA_ARGS__); }} while(0)
#define tsdbInfo(...) do { if (tsdbDebugFlag & DEBUG_INFO) { taosPrintLog("TDB ",
DEBUG_INFO,
255, __VA_ARGS__); }} while(0)
#define tsdbDebug(...) do { if (tsdbDebugFlag & DEBUG_DEBUG) { taosPrintLog("TDB ", tsdbDebugFlag, __VA_ARGS__); }} while(0)
#define tsdbDebug(...) do { if (tsdbDebugFlag & DEBUG_DEBUG) { taosPrintLog("TDB ",
DEBUG_DEBUG,
tsdbDebugFlag, __VA_ARGS__); }} while(0)
#define tsdbTrace(...) do { if (tsdbDebugFlag & DEBUG_TRACE) { taosPrintLog("TDB ", tsdbDebugFlag, __VA_ARGS__); }} while(0)
#define tsdbTrace(...) do { if (tsdbDebugFlag & DEBUG_TRACE) { taosPrintLog("TDB ",
DEBUG_TRACE,
tsdbDebugFlag, __VA_ARGS__); }} while(0)
#endif
/* _TD_TSDB_LOG_H_ */
#endif
/* _TD_TSDB_LOG_H_ */
\ No newline at end of file
source/dnode/vnode/src/inc/vnd.h
浏览文件 @
29fab2e3
...
@@ -88,44 +88,41 @@ int vnodeScheduleTask(SVnodeTask* task);
...
@@ -88,44 +88,41 @@ int vnodeScheduleTask(SVnodeTask* task);
int32_t
vnodePutReqToVQueryQ
(
SVnode
*
pVnode
,
struct
SRpcMsg
*
pReq
);
int32_t
vnodePutReqToVQueryQ
(
SVnode
*
pVnode
,
struct
SRpcMsg
*
pReq
);
void
vnodeSendReqToDnode
(
SVnode
*
pVnode
,
struct
SEpSet
*
epSet
,
struct
SRpcMsg
*
pReq
);
void
vnodeSendReqToDnode
(
SVnode
*
pVnode
,
struct
SEpSet
*
epSet
,
struct
SRpcMsg
*
pReq
);
// For Log
#define vFatal(...) \
extern
int32_t
vDebugFlag
;
do { \
if (vDebugFlag & DEBUG_FATAL) { \
#define vFatal(...) \
taosPrintLog("VND FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); \
do { \
} \
if (vDebugFlag & DEBUG_FATAL) { \
taosPrintLog("VND FATAL ", 255, __VA_ARGS__); \
} \
} while (0)
} while (0)
#define vError(...) \
#define vError(...)
\
do { \
do {
\
if (vDebugFlag & DEBUG_ERROR) { \
if (vDebugFlag & DEBUG_ERROR) {
\
taosPrintLog("VND ERROR ", 255, __VA_ARGS__); \
taosPrintLog("VND ERROR ",
DEBUG_ERROR,
255, __VA_ARGS__); \
} \
}
\
} while (0)
} while (0)
#define vWarn(...) \
#define vWarn(...)
\
do { \
do {
\
if (vDebugFlag & DEBUG_WARN) { \
if (vDebugFlag & DEBUG_WARN) {
\
taosPrintLog("VND WARN ", 255, __VA_ARGS__); \
taosPrintLog("VND WARN ",
DEBUG_WARN,
255, __VA_ARGS__); \
} \
}
\
} while (0)
} while (0)
#define vInfo(...) \
#define vInfo(...)
\
do { \
do {
\
if (vDebugFlag & DEBUG_INFO) { \
if (vDebugFlag & DEBUG_INFO) {
\
taosPrintLog("VND ", 255, __VA_ARGS__); \
taosPrintLog("VND ",
DEBUG_INFO,
255, __VA_ARGS__); \
} \
}
\
} while (0)
} while (0)
#define vDebug(...) \
#define vDebug(...)
\
do { \
do {
\
if (vDebugFlag & DEBUG_DEBUG) { \
if (vDebugFlag & DEBUG_DEBUG) {
\
taosPrintLog("VND ", tsdbDebugFlag, __VA_ARGS__); \
taosPrintLog("VND ",
DEBUG_DEBUG,
tsdbDebugFlag, __VA_ARGS__); \
} \
}
\
} while (0)
} while (0)
#define vTrace(...) \
#define vTrace(...)
\
do { \
do {
\
if (vDebugFlag & DEBUG_TRACE) { \
if (vDebugFlag & DEBUG_TRACE) {
\
taosPrintLog("VND ", tsdbDebugFlag, __VA_ARGS__); \
taosPrintLog("VND ",
DEBUG_TRACE,
tsdbDebugFlag, __VA_ARGS__); \
} \
}
\
} while (0)
} while (0)
// vnodeCfg.h
// vnodeCfg.h
...
...
source/dnode/vnode/src/meta/metaBDBImpl.c
浏览文件 @
29fab2e3
...
@@ -62,10 +62,10 @@ static int metaStbIdxCb(DB *pIdx, const DBT *pKey, const DBT *pValue, DBT *
...
@@ -62,10 +62,10 @@ static int metaStbIdxCb(DB *pIdx, const DBT *pKey, const DBT *pValue, DBT *
static
int
metaNtbIdxCb
(
DB
*
pIdx
,
const
DBT
*
pKey
,
const
DBT
*
pValue
,
DBT
*
pSKey
);
static
int
metaNtbIdxCb
(
DB
*
pIdx
,
const
DBT
*
pKey
,
const
DBT
*
pValue
,
DBT
*
pSKey
);
static
int
metaCtbIdxCb
(
DB
*
pIdx
,
const
DBT
*
pKey
,
const
DBT
*
pValue
,
DBT
*
pSKey
);
static
int
metaCtbIdxCb
(
DB
*
pIdx
,
const
DBT
*
pKey
,
const
DBT
*
pValue
,
DBT
*
pSKey
);
static
int
metaEncodeTbInfo
(
void
**
buf
,
STbCfg
*
pTbCfg
);
static
int
metaEncodeTbInfo
(
void
**
buf
,
STbCfg
*
pTbCfg
);
static
void
*
metaDecodeTbInfo
(
void
*
buf
,
STbCfg
*
pTbCfg
);
static
void
*
metaDecodeTbInfo
(
void
*
buf
,
STbCfg
*
pTbCfg
);
static
void
metaClearTbCfg
(
STbCfg
*
pTbCfg
);
static
void
metaClearTbCfg
(
STbCfg
*
pTbCfg
);
static
int
metaEncodeSchema
(
void
**
buf
,
SSchemaWrapper
*
pSW
);
static
int
metaEncodeSchema
(
void
**
buf
,
SSchemaWrapper
*
pSW
);
static
void
*
metaDecodeSchema
(
void
*
buf
,
SSchemaWrapper
*
pSW
);
static
void
*
metaDecodeSchema
(
void
*
buf
,
SSchemaWrapper
*
pSW
);
static
void
metaDBWLock
(
SMetaDB
*
pDB
);
static
void
metaDBWLock
(
SMetaDB
*
pDB
);
static
void
metaDBRLock
(
SMetaDB
*
pDB
);
static
void
metaDBRLock
(
SMetaDB
*
pDB
);
static
void
metaDBULock
(
SMetaDB
*
pDB
);
static
void
metaDBULock
(
SMetaDB
*
pDB
);
...
@@ -142,7 +142,7 @@ int metaSaveTableToDB(SMeta *pMeta, STbCfg *pTbCfg) {
...
@@ -142,7 +142,7 @@ int metaSaveTableToDB(SMeta *pMeta, STbCfg *pTbCfg) {
tb_uid_t
uid
;
tb_uid_t
uid
;
char
buf
[
512
];
char
buf
[
512
];
char
buf1
[
512
];
char
buf1
[
512
];
void
*
pBuf
;
void
*
pBuf
;
DBT
key1
,
value1
;
DBT
key1
,
value1
;
DBT
key2
,
value2
;
DBT
key2
,
value2
;
SSchema
*
pSchema
=
NULL
;
SSchema
*
pSchema
=
NULL
;
...
@@ -394,7 +394,7 @@ static int metaNtbIdxCb(DB *pIdx, const DBT *pKey, const DBT *pValue, DBT *pSKey
...
@@ -394,7 +394,7 @@ static int metaNtbIdxCb(DB *pIdx, const DBT *pKey, const DBT *pValue, DBT *pSKey
static
int
metaCtbIdxCb
(
DB
*
pIdx
,
const
DBT
*
pKey
,
const
DBT
*
pValue
,
DBT
*
pSKey
)
{
static
int
metaCtbIdxCb
(
DB
*
pIdx
,
const
DBT
*
pKey
,
const
DBT
*
pValue
,
DBT
*
pSKey
)
{
STbCfg
*
pTbCfg
=
(
STbCfg
*
)(
pValue
->
app_data
);
STbCfg
*
pTbCfg
=
(
STbCfg
*
)(
pValue
->
app_data
);
DBT
*
pDbt
;
DBT
*
pDbt
;
if
(
pTbCfg
->
type
==
META_CHILD_TABLE
)
{
if
(
pTbCfg
->
type
==
META_CHILD_TABLE
)
{
// pDbt = calloc(2, sizeof(DBT));
// pDbt = calloc(2, sizeof(DBT));
...
@@ -479,7 +479,7 @@ static void metaClearTbCfg(STbCfg *pTbCfg) {
...
@@ -479,7 +479,7 @@ static void metaClearTbCfg(STbCfg *pTbCfg) {
/* ------------------------ FOR QUERY ------------------------ */
/* ------------------------ FOR QUERY ------------------------ */
STbCfg
*
metaGetTbInfoByUid
(
SMeta
*
pMeta
,
tb_uid_t
uid
)
{
STbCfg
*
metaGetTbInfoByUid
(
SMeta
*
pMeta
,
tb_uid_t
uid
)
{
STbCfg
*
pTbCfg
=
NULL
;
STbCfg
*
pTbCfg
=
NULL
;
SMetaDB
*
pDB
=
pMeta
->
pDB
;
SMetaDB
*
pDB
=
pMeta
->
pDB
;
DBT
key
=
{
0
};
DBT
key
=
{
0
};
DBT
value
=
{
0
};
DBT
value
=
{
0
};
...
@@ -509,7 +509,7 @@ STbCfg *metaGetTbInfoByUid(SMeta *pMeta, tb_uid_t uid) {
...
@@ -509,7 +509,7 @@ STbCfg *metaGetTbInfoByUid(SMeta *pMeta, tb_uid_t uid) {
}
}
STbCfg
*
metaGetTbInfoByName
(
SMeta
*
pMeta
,
char
*
tbname
,
tb_uid_t
*
uid
)
{
STbCfg
*
metaGetTbInfoByName
(
SMeta
*
pMeta
,
char
*
tbname
,
tb_uid_t
*
uid
)
{
STbCfg
*
pTbCfg
=
NULL
;
STbCfg
*
pTbCfg
=
NULL
;
SMetaDB
*
pDB
=
pMeta
->
pDB
;
SMetaDB
*
pDB
=
pMeta
->
pDB
;
DBT
key
=
{
0
};
DBT
key
=
{
0
};
DBT
pkey
=
{
0
};
DBT
pkey
=
{
0
};
...
@@ -543,10 +543,10 @@ STbCfg *metaGetTbInfoByName(SMeta *pMeta, char *tbname, tb_uid_t *uid) {
...
@@ -543,10 +543,10 @@ STbCfg *metaGetTbInfoByName(SMeta *pMeta, char *tbname, tb_uid_t *uid) {
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
,
bool
isinline
)
{
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
,
bool
isinline
)
{
uint32_t
nCols
;
uint32_t
nCols
;
SSchemaWrapper
*
pSW
=
NULL
;
SSchemaWrapper
*
pSW
=
NULL
;
SMetaDB
*
pDB
=
pMeta
->
pDB
;
SMetaDB
*
pDB
=
pMeta
->
pDB
;
int
ret
;
int
ret
;
void
*
pBuf
;
void
*
pBuf
;
SSchema
*
pSchema
;
SSchema
*
pSchema
;
SSchemaKey
schemaKey
=
{
uid
,
sver
,
0
};
SSchemaKey
schemaKey
=
{
uid
,
sver
,
0
};
DBT
key
=
{
0
};
DBT
key
=
{
0
};
DBT
value
=
{
0
};
DBT
value
=
{
0
};
...
@@ -578,7 +578,7 @@ struct SMTbCursor {
...
@@ -578,7 +578,7 @@ struct SMTbCursor {
SMTbCursor
*
metaOpenTbCursor
(
SMeta
*
pMeta
)
{
SMTbCursor
*
metaOpenTbCursor
(
SMeta
*
pMeta
)
{
SMTbCursor
*
pTbCur
=
NULL
;
SMTbCursor
*
pTbCur
=
NULL
;
SMetaDB
*
pDB
=
pMeta
->
pDB
;
SMetaDB
*
pDB
=
pMeta
->
pDB
;
pTbCur
=
(
SMTbCursor
*
)
calloc
(
1
,
sizeof
(
*
pTbCur
));
pTbCur
=
(
SMTbCursor
*
)
calloc
(
1
,
sizeof
(
*
pTbCur
));
if
(
pTbCur
==
NULL
)
{
if
(
pTbCur
==
NULL
)
{
...
@@ -609,7 +609,7 @@ char *metaTbCursorNext(SMTbCursor *pTbCur) {
...
@@ -609,7 +609,7 @@ char *metaTbCursorNext(SMTbCursor *pTbCur) {
DBT
key
=
{
0
};
DBT
key
=
{
0
};
DBT
value
=
{
0
};
DBT
value
=
{
0
};
STbCfg
tbCfg
;
STbCfg
tbCfg
;
void
*
pBuf
;
void
*
pBuf
;
for
(;;)
{
for
(;;)
{
if
(
pTbCur
->
pCur
->
get
(
pTbCur
->
pCur
,
&
key
,
&
value
,
DB_NEXT
)
==
0
)
{
if
(
pTbCur
->
pCur
->
get
(
pTbCur
->
pCur
,
&
key
,
&
value
,
DB_NEXT
)
==
0
)
{
...
@@ -631,10 +631,10 @@ char *metaTbCursorNext(SMTbCursor *pTbCur) {
...
@@ -631,10 +631,10 @@ char *metaTbCursorNext(SMTbCursor *pTbCur) {
STSchema
*
metaGetTbTSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
)
{
STSchema
*
metaGetTbTSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
)
{
STSchemaBuilder
sb
;
STSchemaBuilder
sb
;
STSchema
*
pTSchema
=
NULL
;
STSchema
*
pTSchema
=
NULL
;
SSchema
*
pSchema
;
SSchema
*
pSchema
;
SSchemaWrapper
*
pSW
;
SSchemaWrapper
*
pSW
;
STbCfg
*
pTbCfg
;
STbCfg
*
pTbCfg
;
tb_uid_t
quid
;
tb_uid_t
quid
;
pTbCfg
=
metaGetTbInfoByUid
(
pMeta
,
uid
);
pTbCfg
=
metaGetTbInfoByUid
(
pMeta
,
uid
);
...
@@ -662,13 +662,13 @@ STSchema *metaGetTbTSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver) {
...
@@ -662,13 +662,13 @@ STSchema *metaGetTbTSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver) {
}
}
struct
SMCtbCursor
{
struct
SMCtbCursor
{
DBC
*
pCur
;
DBC
*
pCur
;
tb_uid_t
suid
;
tb_uid_t
suid
;
};
};
SMCtbCursor
*
metaOpenCtbCursor
(
SMeta
*
pMeta
,
tb_uid_t
uid
)
{
SMCtbCursor
*
metaOpenCtbCursor
(
SMeta
*
pMeta
,
tb_uid_t
uid
)
{
SMCtbCursor
*
pCtbCur
=
NULL
;
SMCtbCursor
*
pCtbCur
=
NULL
;
SMetaDB
*
pDB
=
pMeta
->
pDB
;
SMetaDB
*
pDB
=
pMeta
->
pDB
;
int
ret
;
int
ret
;
pCtbCur
=
(
SMCtbCursor
*
)
calloc
(
1
,
sizeof
(
*
pCtbCur
));
pCtbCur
=
(
SMCtbCursor
*
)
calloc
(
1
,
sizeof
(
*
pCtbCur
));
...
@@ -700,7 +700,7 @@ tb_uid_t metaCtbCursorNext(SMCtbCursor *pCtbCur) {
...
@@ -700,7 +700,7 @@ tb_uid_t metaCtbCursorNext(SMCtbCursor *pCtbCur) {
DBT
skey
=
{
0
};
DBT
skey
=
{
0
};
DBT
pkey
=
{
0
};
DBT
pkey
=
{
0
};
DBT
pval
=
{
0
};
DBT
pval
=
{
0
};
void
*
pBuf
;
void
*
pBuf
;
STbCfg
tbCfg
;
STbCfg
tbCfg
;
// Set key
// Set key
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
29fab2e3
...
@@ -72,6 +72,8 @@ void tqClose(STQ* pTq) {
...
@@ -72,6 +72,8 @@ void tqClose(STQ* pTq) {
}
}
int
tqPushMsg
(
STQ
*
pTq
,
void
*
msg
,
tmsg_t
msgType
,
int64_t
version
)
{
int
tqPushMsg
(
STQ
*
pTq
,
void
*
msg
,
tmsg_t
msgType
,
int64_t
version
)
{
// if waiting
// memcpy and send msg to fetch thread
// TODO: add reference
// TODO: add reference
// if handle waiting, launch query and response to consumer
// if handle waiting, launch query and response to consumer
//
//
...
@@ -210,7 +212,7 @@ int32_t tqProcessConsumeReq(STQ* pTq, SRpcMsg* pMsg) {
...
@@ -210,7 +212,7 @@ int32_t tqProcessConsumeReq(STQ* pTq, SRpcMsg* pMsg) {
SMqConsumeReq
*
pReq
=
pMsg
->
pCont
;
SMqConsumeReq
*
pReq
=
pMsg
->
pCont
;
int64_t
consumerId
=
pReq
->
consumerId
;
int64_t
consumerId
=
pReq
->
consumerId
;
int64_t
fetchOffset
;
int64_t
fetchOffset
;
/*int64_t blockingTime = pReq->blockingTime;*/
int64_t
blockingTime
=
pReq
->
blockingTime
;
if
(
pReq
->
currentOffset
==
TMQ_CONF__RESET_OFFSET__EARLIEAST
)
{
if
(
pReq
->
currentOffset
==
TMQ_CONF__RESET_OFFSET__EARLIEAST
)
{
fetchOffset
=
0
;
fetchOffset
=
0
;
...
...
source/dnode/vnode/src/tq/tqMetaStore.c
浏览文件 @
29fab2e3
...
@@ -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
浏览文件 @
29fab2e3
...
@@ -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
),
...
@@ -1054,7 +1054,7 @@ int tsdbWriteBlockIdx(SDFile *pHeadf, SArray *pIdxA, void **ppBuf) {
...
@@ -1054,7 +1054,7 @@ int tsdbWriteBlockIdx(SDFile *pHeadf, SArray *pIdxA, void **ppBuf) {
// pfs->metaCacheComp = NULL;
// pfs->metaCacheComp = NULL;
// } else {
// } else {
// // remove meta.tmp file
// // remove meta.tmp file
//
remov
e(mf.f.aname);
//
taosRemoveFil
e(mf.f.aname);
// taosHashCleanup(pfs->metaCacheComp);
// taosHashCleanup(pfs->metaCacheComp);
// pfs->metaCacheComp = NULL;
// pfs->metaCacheComp = NULL;
// }
// }
...
...
source/dnode/vnode/src/tsdb/tsdbFS.c
浏览文件 @
29fab2e3
...
@@ -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
;
...
@@ -439,7 +439,7 @@ static int tsdbSaveFSStatus(STsdb *pRepo, SFSStatus *pStatus) {
...
@@ -439,7 +439,7 @@ static int tsdbSaveFSStatus(STsdb *pRepo, SFSStatus *pStatus) {
if
(
taosWriteFile
(
pFile
,
hbuf
,
TSDB_FILE_HEAD_SIZE
)
<
TSDB_FILE_HEAD_SIZE
)
{
if
(
taosWriteFile
(
pFile
,
hbuf
,
TSDB_FILE_HEAD_SIZE
)
<
TSDB_FILE_HEAD_SIZE
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
remov
e
(
tfname
);
taosRemoveFil
e
(
tfname
);
return
-
1
;
return
-
1
;
}
}
...
@@ -447,7 +447,7 @@ static int tsdbSaveFSStatus(STsdb *pRepo, SFSStatus *pStatus) {
...
@@ -447,7 +447,7 @@ static int tsdbSaveFSStatus(STsdb *pRepo, SFSStatus *pStatus) {
if
(
fsheader
.
len
>
0
)
{
if
(
fsheader
.
len
>
0
)
{
if
(
tsdbMakeRoom
(
&
(
pBuf
),
fsheader
.
len
)
<
0
)
{
if
(
tsdbMakeRoom
(
&
(
pBuf
),
fsheader
.
len
)
<
0
)
{
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
remov
e
(
tfname
);
taosRemoveFil
e
(
tfname
);
return
-
1
;
return
-
1
;
}
}
...
@@ -458,7 +458,7 @@ static int tsdbSaveFSStatus(STsdb *pRepo, SFSStatus *pStatus) {
...
@@ -458,7 +458,7 @@ static int tsdbSaveFSStatus(STsdb *pRepo, SFSStatus *pStatus) {
if
(
taosWriteFile
(
pFile
,
pBuf
,
fsheader
.
len
)
<
fsheader
.
len
)
{
if
(
taosWriteFile
(
pFile
,
pBuf
,
fsheader
.
len
)
<
fsheader
.
len
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
(
void
)
remov
e
(
tfname
);
(
void
)
taosRemoveFil
e
(
tfname
);
taosTZfree
(
pBuf
);
taosTZfree
(
pBuf
);
return
-
1
;
return
-
1
;
}
}
...
@@ -468,7 +468,7 @@ static int tsdbSaveFSStatus(STsdb *pRepo, SFSStatus *pStatus) {
...
@@ -468,7 +468,7 @@ static int tsdbSaveFSStatus(STsdb *pRepo, SFSStatus *pStatus) {
if
(
taosFsyncFile
(
pFile
)
<
0
)
{
if
(
taosFsyncFile
(
pFile
)
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
remov
e
(
tfname
);
taosRemoveFil
e
(
tfname
);
taosTZfree
(
pBuf
);
taosTZfree
(
pBuf
);
return
-
1
;
return
-
1
;
}
}
...
...
source/dnode/vnode/src/tsdb/tsdbFile.c
浏览文件 @
29fab2e3
...
@@ -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
浏览文件 @
29fab2e3
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/src/catalog.c
浏览文件 @
29fab2e3
...
@@ -168,7 +168,7 @@ void ctgDbgShowTableMeta(SCatalog* pCtg, const char *tbName, STableMeta* p) {
...
@@ -168,7 +168,7 @@ void ctgDbgShowTableMeta(SCatalog* pCtg, const char *tbName, STableMeta* p) {
ctgDebug
(
"table [%s] meta: type:%d, vgId:%d, uid:%"
PRIx64
",suid:%"
PRIx64
",sv:%d, tv:%d, tagNum:%d, precision:%d, colNum:%d, rowSize:%d"
,
ctgDebug
(
"table [%s] meta: type:%d, vgId:%d, uid:%"
PRIx64
",suid:%"
PRIx64
",sv:%d, tv:%d, tagNum:%d, precision:%d, colNum:%d, rowSize:%d"
,
tbName
,
p
->
tableType
,
p
->
vgId
,
p
->
uid
,
p
->
suid
,
p
->
sversion
,
p
->
tversion
,
c
->
numOfTags
,
c
->
precision
,
c
->
numOfColumns
,
c
->
rowSize
);
tbName
,
p
->
tableType
,
p
->
vgId
,
p
->
uid
,
p
->
suid
,
p
->
sversion
,
p
->
tversion
,
c
->
numOfTags
,
c
->
precision
,
c
->
numOfColumns
,
c
->
rowSize
);
}
}
int32_t
colNum
=
c
->
numOfColumns
+
c
->
numOfTags
;
int32_t
colNum
=
c
->
numOfColumns
+
c
->
numOfTags
;
for
(
int32_t
i
=
0
;
i
<
colNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
colNum
;
++
i
)
{
SSchema
*
s
=
&
p
->
schema
[
i
];
SSchema
*
s
=
&
p
->
schema
[
i
];
...
@@ -190,7 +190,7 @@ void ctgDbgShowDBCache(SCatalog* pCtg, SHashObj *dbHash) {
...
@@ -190,7 +190,7 @@ void ctgDbgShowDBCache(SCatalog* pCtg, SHashObj *dbHash) {
dbCache
=
(
SCtgDBCache
*
)
pIter
;
dbCache
=
(
SCtgDBCache
*
)
pIter
;
taosHashGetKey
(
dbCache
,
(
void
**
)
&
dbFName
,
&
len
);
taosHashGetKey
((
void
**
)
&
dbFName
,
&
len
);
int32_t
metaNum
=
dbCache
->
tbCache
.
metaCache
?
taosHashGetSize
(
dbCache
->
tbCache
.
metaCache
)
:
0
;
int32_t
metaNum
=
dbCache
->
tbCache
.
metaCache
?
taosHashGetSize
(
dbCache
->
tbCache
.
metaCache
)
:
0
;
int32_t
stbNum
=
dbCache
->
tbCache
.
stbCache
?
taosHashGetSize
(
dbCache
->
tbCache
.
stbCache
)
:
0
;
int32_t
stbNum
=
dbCache
->
tbCache
.
stbCache
?
taosHashGetSize
(
dbCache
->
tbCache
.
stbCache
)
:
0
;
...
@@ -204,9 +204,9 @@ void ctgDbgShowDBCache(SCatalog* pCtg, SHashObj *dbHash) {
...
@@ -204,9 +204,9 @@ void ctgDbgShowDBCache(SCatalog* pCtg, SHashObj *dbHash) {
if
(
dbCache
->
vgInfo
->
vgHash
)
{
if
(
dbCache
->
vgInfo
->
vgHash
)
{
vgNum
=
taosHashGetSize
(
dbCache
->
vgInfo
->
vgHash
);
vgNum
=
taosHashGetSize
(
dbCache
->
vgInfo
->
vgHash
);
}
}
}
}
ctgDebug
(
"[%d] db [%.*s][%"
PRIx64
"] %s: metaNum:%d, stbNum:%d, vgVersion:%d, hashMethod:%d, vgNum:%d"
,
ctgDebug
(
"[%d] db [%.*s][%"
PRIx64
"] %s: metaNum:%d, stbNum:%d, vgVersion:%d, hashMethod:%d, vgNum:%d"
,
i
,
(
int32_t
)
len
,
dbFName
,
dbCache
->
dbId
,
dbCache
->
deleted
?
"deleted"
:
""
,
metaNum
,
stbNum
,
vgVersion
,
hashMethod
,
vgNum
);
i
,
(
int32_t
)
len
,
dbFName
,
dbCache
->
dbId
,
dbCache
->
deleted
?
"deleted"
:
""
,
metaNum
,
stbNum
,
vgVersion
,
hashMethod
,
vgNum
);
pIter
=
taosHashIterate
(
dbHash
,
pIter
);
pIter
=
taosHashIterate
(
dbHash
,
pIter
);
...
@@ -222,7 +222,7 @@ void ctgDbgShowClusterCache(SCatalog* pCtg) {
...
@@ -222,7 +222,7 @@ void ctgDbgShowClusterCache(SCatalog* pCtg) {
}
}
ctgDebug
(
"## cluster %"
PRIx64
" %p cache Info ##"
,
pCtg
->
clusterId
,
pCtg
);
ctgDebug
(
"## cluster %"
PRIx64
" %p cache Info ##"
,
pCtg
->
clusterId
,
pCtg
);
ctgDebug
(
"db:%d meta:%d stb:%d dbRent:%d stbRent:%d"
,
ctgDbgGetClusterCacheNum
(
pCtg
,
CTG_DBG_DB_NUM
),
ctgDbgGetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
),
ctgDebug
(
"db:%d meta:%d stb:%d dbRent:%d stbRent:%d"
,
ctgDbgGetClusterCacheNum
(
pCtg
,
CTG_DBG_DB_NUM
),
ctgDbgGetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
),
ctgDbgGetClusterCacheNum
(
pCtg
,
CTG_DBG_STB_NUM
),
ctgDbgGetClusterCacheNum
(
pCtg
,
CTG_DBG_DB_RENT_NUM
),
ctgDbgGetClusterCacheNum
(
pCtg
,
CTG_DBG_STB_RENT_NUM
));
ctgDbgGetClusterCacheNum
(
pCtg
,
CTG_DBG_STB_NUM
),
ctgDbgGetClusterCacheNum
(
pCtg
,
CTG_DBG_DB_RENT_NUM
),
ctgDbgGetClusterCacheNum
(
pCtg
,
CTG_DBG_STB_RENT_NUM
));
ctgDbgShowDBCache
(
pCtg
,
pCtg
->
dbCache
);
ctgDbgShowDBCache
(
pCtg
,
pCtg
->
dbCache
);
...
@@ -306,9 +306,9 @@ int32_t ctgPushRmDBMsgInQueue(SCatalog* pCtg, const char *dbFName, int64_t dbId)
...
@@ -306,9 +306,9 @@ int32_t ctgPushRmDBMsgInQueue(SCatalog* pCtg, const char *dbFName, int64_t dbId)
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
_return:
_return:
tfree
(
action
.
data
);
tfree
(
action
.
data
);
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
...
@@ -336,9 +336,9 @@ int32_t ctgPushRmStbMsgInQueue(SCatalog* pCtg, const char *dbFName, int64_t dbId
...
@@ -336,9 +336,9 @@ int32_t ctgPushRmStbMsgInQueue(SCatalog* pCtg, const char *dbFName, int64_t dbId
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
_return:
_return:
tfree
(
action
.
data
);
tfree
(
action
.
data
);
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
...
@@ -366,9 +366,9 @@ int32_t ctgPushRmTblMsgInQueue(SCatalog* pCtg, const char *dbFName, int64_t dbId
...
@@ -366,9 +366,9 @@ int32_t ctgPushRmTblMsgInQueue(SCatalog* pCtg, const char *dbFName, int64_t dbId
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
_return:
_return:
tfree
(
action
.
data
);
tfree
(
action
.
data
);
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
...
@@ -657,9 +657,9 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable
...
@@ -657,9 +657,9 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
size_t
sz
=
0
;
int32_t
sz
=
0
;
CTG_LOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
metaLock
);
CTG_LOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
metaLock
);
STableMeta
*
tbMeta
=
taosHashGetCloneExt
(
dbCache
->
tbCache
.
metaCache
,
pTableName
->
tname
,
strlen
(
pTableName
->
tname
),
NULL
,
(
void
**
)
pTableMeta
,
&
sz
);
int32_t
code
=
taosHashGetDup_m
(
dbCache
->
tbCache
.
metaCache
,
pTableName
->
tname
,
strlen
(
pTableName
->
tname
)
,
(
void
**
)
pTableMeta
,
&
sz
);
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
metaLock
);
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
metaLock
);
if
(
NULL
==
*
pTableMeta
)
{
if
(
NULL
==
*
pTableMeta
)
{
...
@@ -673,8 +673,8 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable
...
@@ -673,8 +673,8 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable
if
(
dbId
)
{
if
(
dbId
)
{
*
dbId
=
dbCache
->
dbId
;
*
dbId
=
dbCache
->
dbId
;
}
}
tbMeta
=
*
pTableMeta
;
STableMeta
*
tbMeta
=
*
pTableMeta
;
if
(
tbMeta
->
tableType
!=
TSDB_CHILD_TABLE
)
{
if
(
tbMeta
->
tableType
!=
TSDB_CHILD_TABLE
)
{
ctgReleaseDBCache
(
pCtg
,
dbCache
);
ctgReleaseDBCache
(
pCtg
,
dbCache
);
...
@@ -1076,7 +1076,7 @@ _return:
...
@@ -1076,7 +1076,7 @@ _return:
}
}
int32_t
ctgMetaRentRemove
(
SCtgRentMgmt
*
mgmt
,
int64_t
id
,
__compar_fn_t
compare
)
{
int32_t
ctgMetaRentRemove
(
SCtgRentMgmt
*
mgmt
,
int64_t
id
,
__compar_fn_t
compare
)
{
int16_t
widx
=
abs
(
id
%
mgmt
->
slotNum
);
int16_t
widx
=
l
abs
(
id
%
mgmt
->
slotNum
);
SCtgRentSlot
*
slot
=
&
mgmt
->
slots
[
widx
];
SCtgRentSlot
*
slot
=
&
mgmt
->
slots
[
widx
];
int32_t
code
=
0
;
int32_t
code
=
0
;
...
@@ -1238,7 +1238,7 @@ void ctgRemoveStbRent(SCatalog* pCtg, SCtgTbMetaCache *cache) {
...
@@ -1238,7 +1238,7 @@ void ctgRemoveStbRent(SCatalog* pCtg, SCtgTbMetaCache *cache) {
void
*
pIter
=
taosHashIterate
(
cache
->
stbCache
,
NULL
);
void
*
pIter
=
taosHashIterate
(
cache
->
stbCache
,
NULL
);
while
(
pIter
)
{
while
(
pIter
)
{
uint64_t
*
suid
=
NULL
;
uint64_t
*
suid
=
NULL
;
taosHashGetKey
(
pIter
,
(
void
**
)
&
suid
,
NULL
);
suid
=
taosHashGetKey
(
pIter
,
NULL
);
if
(
TSDB_CODE_SUCCESS
==
ctgMetaRentRemove
(
&
pCtg
->
stbRent
,
*
suid
,
ctgStbVersionCompare
))
{
if
(
TSDB_CODE_SUCCESS
==
ctgMetaRentRemove
(
&
pCtg
->
stbRent
,
*
suid
,
ctgStbVersionCompare
))
{
ctgDebug
(
"stb removed from rent, suid:%"
PRIx64
,
*
suid
);
ctgDebug
(
"stb removed from rent, suid:%"
PRIx64
,
*
suid
);
...
@@ -1397,7 +1397,7 @@ int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, ui
...
@@ -1397,7 +1397,7 @@ int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, ui
CTG_UNLOCK
(
CTG_WRITE
,
&
tbCache
->
stbLock
);
CTG_UNLOCK
(
CTG_WRITE
,
&
tbCache
->
stbLock
);
ctgDebug
(
"stb removed from stbCache, dbFName:%s, stb:%s, suid:%"
PRIx64
,
dbFName
,
tbName
,
orig
->
suid
);
ctgDebug
(
"stb removed from stbCache, dbFName:%s, stb:%s, suid:%"
PRIx64
,
dbFName
,
tbName
,
orig
->
suid
);
ctgMetaRentRemove
(
&
pCtg
->
stbRent
,
orig
->
suid
,
ctgStbVersionCompare
);
ctgMetaRentRemove
(
&
pCtg
->
stbRent
,
orig
->
suid
,
ctgStbVersionCompare
);
}
}
...
@@ -1437,7 +1437,7 @@ int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, ui
...
@@ -1437,7 +1437,7 @@ int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, ui
if
(
taosHashPut
(
tbCache
->
stbCache
,
&
meta
->
suid
,
sizeof
(
meta
->
suid
),
&
tbMeta
,
POINTER_BYTES
)
!=
0
)
{
if
(
taosHashPut
(
tbCache
->
stbCache
,
&
meta
->
suid
,
sizeof
(
meta
->
suid
),
&
tbMeta
,
POINTER_BYTES
)
!=
0
)
{
CTG_UNLOCK
(
CTG_WRITE
,
&
tbCache
->
stbLock
);
CTG_UNLOCK
(
CTG_WRITE
,
&
tbCache
->
stbLock
);
CTG_UNLOCK
(
CTG_READ
,
&
tbCache
->
metaLock
);
CTG_UNLOCK
(
CTG_READ
,
&
tbCache
->
metaLock
);
ctgError
(
"taosHashPut
Ext
stable to stable cache failed, suid:%"
PRIx64
,
meta
->
suid
);
ctgError
(
"taosHashPut stable to stable cache failed, suid:%"
PRIx64
,
meta
->
suid
);
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
}
...
@@ -1475,7 +1475,7 @@ int32_t ctgCloneVgInfo(SDBVgInfo *src, SDBVgInfo **dst) {
...
@@ -1475,7 +1475,7 @@ int32_t ctgCloneVgInfo(SDBVgInfo *src, SDBVgInfo **dst) {
int32_t
*
vgId
=
NULL
;
int32_t
*
vgId
=
NULL
;
void
*
pIter
=
taosHashIterate
(
src
->
vgHash
,
NULL
);
void
*
pIter
=
taosHashIterate
(
src
->
vgHash
,
NULL
);
while
(
pIter
)
{
while
(
pIter
)
{
taosHashGetKey
(
pIter
,
(
void
**
)
&
vgId
,
NULL
);
vgId
=
taosHashGetKey
(
pIter
,
NULL
);
if
(
taosHashPut
((
*
dst
)
->
vgHash
,
(
void
*
)
vgId
,
sizeof
(
int32_t
),
pIter
,
sizeof
(
SVgroupInfo
)))
{
if
(
taosHashPut
((
*
dst
)
->
vgHash
,
(
void
*
)
vgId
,
sizeof
(
int32_t
),
pIter
,
sizeof
(
SVgroupInfo
)))
{
qError
(
"taosHashPut failed, hashSize:%d"
,
(
int32_t
)
hashSize
);
qError
(
"taosHashPut failed, hashSize:%d"
,
(
int32_t
)
hashSize
);
...
@@ -1635,7 +1635,7 @@ int32_t ctgRefreshTblMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps,
...
@@ -1635,7 +1635,7 @@ int32_t ctgRefreshTblMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps,
if
(
!
CTG_FLAG_IS_FORCE_UPDATE
(
flag
))
{
if
(
!
CTG_FLAG_IS_FORCE_UPDATE
(
flag
))
{
CTG_ERR_JRET
(
ctgIsTableMetaExistInCache
(
pCtg
,
output
->
dbFName
,
output
->
tbName
,
&
exist
));
CTG_ERR_JRET
(
ctgIsTableMetaExistInCache
(
pCtg
,
output
->
dbFName
,
output
->
tbName
,
&
exist
));
}
}
if
(
0
==
exist
)
{
if
(
0
==
exist
)
{
CTG_ERR_JRET
(
ctgGetTableMetaFromMnodeImpl
(
pCtg
,
pTrans
,
pMgmtEps
,
output
->
dbFName
,
output
->
tbName
,
&
moutput
));
CTG_ERR_JRET
(
ctgGetTableMetaFromMnodeImpl
(
pCtg
,
pTrans
,
pMgmtEps
,
output
->
dbFName
,
output
->
tbName
,
&
moutput
));
...
@@ -1723,9 +1723,9 @@ int32_t ctgGetTableMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons
...
@@ -1723,9 +1723,9 @@ int32_t ctgGetTableMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons
tbType
=
(
*
pTableMeta
)
->
tableType
;
tbType
=
(
*
pTableMeta
)
->
tableType
;
suid
=
(
*
pTableMeta
)
->
suid
;
suid
=
(
*
pTableMeta
)
->
suid
;
tfree
(
*
pTableMeta
);
tfree
(
*
pTableMeta
);
}
}
if
(
CTG_FLAG_IS_UNKNOWN_STB
(
flag
))
{
if
(
CTG_FLAG_IS_UNKNOWN_STB
(
flag
))
{
CTG_FLAG_SET_STB
(
flag
,
tbType
);
CTG_FLAG_SET_STB
(
flag
,
tbType
);
}
}
...
@@ -1950,21 +1950,21 @@ int32_t ctgActRemoveTbl(SCtgMetaAction *action) {
...
@@ -1950,21 +1950,21 @@ int32_t ctgActRemoveTbl(SCtgMetaAction *action) {
ctgDebug
(
"dbId already modified, dbFName:%s, current:%"
PRIx64
", dbId:%"
PRIx64
", tbName:%s"
,
msg
->
dbFName
,
dbCache
->
dbId
,
msg
->
dbId
,
msg
->
tbName
);
ctgDebug
(
"dbId already modified, dbFName:%s, current:%"
PRIx64
", dbId:%"
PRIx64
", tbName:%s"
,
msg
->
dbFName
,
dbCache
->
dbId
,
msg
->
dbId
,
msg
->
tbName
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
CTG_LOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
metaLock
);
CTG_LOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
metaLock
);
if
(
taosHashRemove
(
dbCache
->
tbCache
.
metaCache
,
msg
->
tbName
,
strlen
(
msg
->
tbName
)))
{
if
(
taosHashRemove
(
dbCache
->
tbCache
.
metaCache
,
msg
->
tbName
,
strlen
(
msg
->
tbName
)))
{
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
metaLock
);
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
metaLock
);
ctgError
(
"stb not exist in cache, dbFName:%s, tbName:%s"
,
msg
->
dbFName
,
msg
->
tbName
);
ctgError
(
"stb not exist in cache, dbFName:%s, tbName:%s"
,
msg
->
dbFName
,
msg
->
tbName
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
}
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
metaLock
);
CTG_UNLOCK
(
CTG_READ
,
&
dbCache
->
tbCache
.
metaLock
);
ctgInfo
(
"table removed from cache, dbFName:%s, tbName:%s"
,
msg
->
dbFName
,
msg
->
tbName
);
ctgInfo
(
"table removed from cache, dbFName:%s, tbName:%s"
,
msg
->
dbFName
,
msg
->
tbName
);
_return:
_return:
tfree
(
msg
);
tfree
(
msg
);
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
...
@@ -2458,7 +2458,7 @@ int32_t catalogGetTableDistVgInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgm
...
@@ -2458,7 +2458,7 @@ int32_t catalogGetTableDistVgInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgm
CTG_ERR_JRET
(
ctgGenerateVgList
(
pCtg
,
vgHash
,
pVgList
));
CTG_ERR_JRET
(
ctgGenerateVgList
(
pCtg
,
vgHash
,
pVgList
));
}
else
{
}
else
{
int32_t
vgId
=
tbMeta
->
vgId
;
int32_t
vgId
=
tbMeta
->
vgId
;
if
(
NULL
==
taosHashGetClone
(
vgHash
,
&
vgId
,
sizeof
(
vgId
),
&
vgroupInfo
)
)
{
if
(
taosHashGetDup
(
vgHash
,
&
vgId
,
sizeof
(
vgId
),
&
vgroupInfo
)
!=
0
)
{
ctgError
(
"table's vgId not found in vgroup list, vgId:%d, tbName:%s"
,
vgId
,
tNameGetTableName
(
pTableName
));
ctgError
(
"table's vgId not found in vgroup list, vgId:%d, tbName:%s"
,
vgId
,
tNameGetTableName
(
pTableName
));
CTG_ERR_JRET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
CTG_ERR_JRET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
}
...
...
source/libs/catalog/test/catalogTests.cpp
浏览文件 @
29fab2e3
...
@@ -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,16 +22,18 @@
...
@@ -24,16 +22,18 @@
#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 "catalogInt.h"
#include "stub.h"
#include "stub.h"
#include "taos.h"
#include "taos.h"
#include "tdatablock.h"
#include "tdef.h"
#include "tdef.h"
#include "tep.h"
#include "trpc.h"
#include "trpc.h"
#include "tvariant.h"
#include "tvariant.h"
#include "catalogInt.h"
namespace
{
namespace
{
...
...
source/libs/executor/inc/executil.h
浏览文件 @
29fab2e3
...
@@ -68,7 +68,7 @@ typedef struct SResultRow {
...
@@ -68,7 +68,7 @@ typedef struct SResultRow {
}
SResultRow
;
}
SResultRow
;
typedef
struct
SResultRowInfo
{
typedef
struct
SResultRowInfo
{
S
ResultRow
*
pCurResult
;
// current active result row info
S
List
*
pRows
;
SResultRow
**
pResult
;
// result list
SResultRow
**
pResult
;
// result list
// int16_t type:8; // data type for hash key
// int16_t type:8; // data type for hash key
int32_t
size
;
// number of result set
int32_t
size
;
// number of result set
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
29fab2e3
...
@@ -15,12 +15,12 @@
...
@@ -15,12 +15,12 @@
#ifndef TDENGINE_EXECUTORIMPL_H
#ifndef TDENGINE_EXECUTORIMPL_H
#define TDENGINE_EXECUTORIMPL_H
#define TDENGINE_EXECUTORIMPL_H
#include "tsort.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#endif
#endif
#include "os.h"
#include "os.h"
#include "tsort.h"
#include "tcommon.h"
#include "tcommon.h"
#include "tlosertree.h"
#include "tlosertree.h"
#include "ttszip.h"
#include "ttszip.h"
...
@@ -157,6 +157,13 @@ typedef struct STaskCostInfo {
...
@@ -157,6 +157,13 @@ typedef struct STaskCostInfo {
SHashObj
*
operatorProfResults
;
// map<operator_type, SQueryProfEvent>
SHashObj
*
operatorProfResults
;
// map<operator_type, SQueryProfEvent>
}
STaskCostInfo
;
}
STaskCostInfo
;
typedef
struct
SOperatorCostInfo
{
uint64_t
openCost
;
uint64_t
execCost
;
uint64_t
totalRows
;
uint64_t
totalBytes
;
}
SOperatorCostInfo
;
typedef
struct
{
typedef
struct
{
int64_t
vgroupLimit
;
int64_t
vgroupLimit
;
int64_t
ts
;
int64_t
ts
;
...
@@ -233,9 +240,9 @@ typedef struct STaskAttr {
...
@@ -233,9 +240,9 @@ typedef struct STaskAttr {
SArray
*
pUdfInfo
;
// no need to free
SArray
*
pUdfInfo
;
// no need to free
}
STaskAttr
;
}
STaskAttr
;
typedef
int32_t
(
*
__optr_
prepare
_fn_t
)(
void
*
param
);
typedef
int32_t
(
*
__optr_
open
_fn_t
)(
void
*
param
);
typedef
SSDataBlock
*
(
*
__op
erato
r_fn_t
)(
void
*
param
,
bool
*
newgroup
);
typedef
SSDataBlock
*
(
*
__op
t
r_fn_t
)(
void
*
param
,
bool
*
newgroup
);
typedef
void
(
*
__optr_cl
eanup
_fn_t
)(
void
*
param
,
int32_t
num
);
typedef
void
(
*
__optr_cl
ose
_fn_t
)(
void
*
param
,
int32_t
num
);
struct
SOperatorInfo
;
struct
SOperatorInfo
;
...
@@ -306,21 +313,21 @@ enum {
...
@@ -306,21 +313,21 @@ enum {
};
};
typedef
struct
SOperatorInfo
{
typedef
struct
SOperatorInfo
{
uint8_t
operatorType
;
uint8_t
operatorType
;
bool
blockingOptr
;
// block operator or not
bool
blockingOptr
;
// block operator or not
uint8_t
status
;
// denote if current operator is completed
uint8_t
status
;
// denote if current operator is completed
int32_t
numOfOutput
;
// number of columns of the current operator results
int32_t
numOfOutput
;
// number of columns of the current operator results
char
*
name
;
// name, used to show the query execution plan
char
*
name
;
// name, used to show the query execution plan
void
*
info
;
// extension attribution
void
*
info
;
// extension attribution
SExprInfo
*
pExpr
;
SExprInfo
*
pExpr
;
STaskRuntimeEnv
*
pRuntimeEnv
;
// todo remove it
STaskRuntimeEnv
*
pRuntimeEnv
;
// todo remove it
SExecTaskInfo
*
pTaskInfo
;
SExecTaskInfo
*
pTaskInfo
;
struct
SOperatorInfo
**
pDownstream
;
// downstram pointer list
struct
SOperatorInfo
**
pDownstream
;
// downstram pointer list
int32_t
numOfDownstream
;
// number of downstream. The value is always ONE expect for join operator
int32_t
numOfDownstream
;
// number of downstream. The value is always ONE expect for join operator
__optr_
prepare_fn_t
prepare
Fn
;
__optr_
open_fn_t
open
Fn
;
__op
erator_fn_t
exec
;
__op
tr_fn_t
nextDataFn
;
__optr_cl
eanup_fn_t
cleanup
Fn
;
__optr_cl
ose_fn_t
close
Fn
;
}
SOperatorInfo
;
}
SOperatorInfo
;
typedef
struct
{
typedef
struct
{
...
@@ -479,9 +486,6 @@ typedef struct SAggOperatorInfo {
...
@@ -479,9 +486,6 @@ typedef struct SAggOperatorInfo {
typedef
struct
SProjectOperatorInfo
{
typedef
struct
SProjectOperatorInfo
{
SOptrBasicInfo
binfo
;
SOptrBasicInfo
binfo
;
int32_t
bufCapacity
;
uint32_t
seed
;
SSDataBlock
*
existDataBlock
;
SSDataBlock
*
existDataBlock
;
}
SProjectOperatorInfo
;
}
SProjectOperatorInfo
;
...
@@ -615,10 +619,10 @@ SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order,
...
@@ -615,10 +619,10 @@ SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order,
SOperatorInfo
*
createTableSeqScanOperatorInfo
(
void
*
pTsdbReadHandle
,
STaskRuntimeEnv
*
pRuntimeEnv
);
SOperatorInfo
*
createTableSeqScanOperatorInfo
(
void
*
pTsdbReadHandle
,
STaskRuntimeEnv
*
pRuntimeEnv
);
SOperatorInfo
*
createAggregateOperatorInfo
(
SOperatorInfo
*
downstream
,
SArray
*
pExprInfo
,
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
);
SOperatorInfo
*
createAggregateOperatorInfo
(
SOperatorInfo
*
downstream
,
SArray
*
pExprInfo
,
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
);
SOperatorInfo
*
createMultiTableAggOperatorInfo
(
SOperatorInfo
*
downstream
,
SArray
*
pExprInfo
,
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
);
SOperatorInfo
*
createMultiTableAggOperatorInfo
(
SOperatorInfo
*
downstream
,
SArray
*
pExprInfo
,
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
);
SOperatorInfo
*
createProjectOperatorInfo
(
S
TaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
SOperatorInfo
*
createProjectOperatorInfo
(
S
OperatorInfo
*
downstream
,
SArray
*
pExprInfo
,
SExecTaskInfo
*
pTaskInfo
);
int32_t
numOfOutput
);
SOperatorInfo
*
createLimitOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
);
SOperatorInfo
*
createLimitOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
);
SOperatorInfo
*
createIntervalOperatorInfo
(
SOperatorInfo
*
downstream
,
SArray
*
pExprInfo
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createIntervalOperatorInfo
(
SOperatorInfo
*
downstream
,
SArray
*
pExprInfo
,
S
Interval
*
pInterval
,
S
ExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createAllTimeIntervalOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SOperatorInfo
*
createAllTimeIntervalOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
...
@@ -654,8 +658,6 @@ SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pdownstream, int32_t numOf
...
@@ -654,8 +658,6 @@ SOperatorInfo* createJoinOperatorInfo(SOperatorInfo** pdownstream, int32_t numOf
SOperatorInfo
*
createOrderOperatorInfo
(
SOperatorInfo
*
downstream
,
SArray
*
pExprInfo
,
SArray
*
pOrderVal
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createOrderOperatorInfo
(
SOperatorInfo
*
downstream
,
SArray
*
pExprInfo
,
SArray
*
pOrderVal
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createSortedMergeOperatorInfo
(
SOperatorInfo
**
downstream
,
int32_t
numOfDownstream
,
SArray
*
pExprInfo
,
SArray
*
pOrderVal
,
SArray
*
pGroupInfo
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createSortedMergeOperatorInfo
(
SOperatorInfo
**
downstream
,
int32_t
numOfDownstream
,
SArray
*
pExprInfo
,
SArray
*
pOrderVal
,
SArray
*
pGroupInfo
,
SExecTaskInfo
*
pTaskInfo
);
// SSDataBlock* doGlobalAggregate(void* param, bool* newgroup);
// SSDataBlock* doMultiwayMergeSort(void* param, bool* newgroup);
// SSDataBlock* doSLimit(void* param, bool* newgroup);
// SSDataBlock* doSLimit(void* param, bool* newgroup);
// int32_t doCreateFilterInfo(SColumnInfo* pCols, int32_t numOfCols, int32_t numOfFilterCols, SSingleColumnFilterInfo** pFilterInfo, uint64_t qId);
// int32_t doCreateFilterInfo(SColumnInfo* pCols, int32_t numOfCols, int32_t numOfFilterCols, SSingleColumnFilterInfo** pFilterInfo, uint64_t qId);
...
...
source/libs/executor/inc/tsimplehash.h
0 → 100644
浏览文件 @
29fab2e3
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_TSIMPLEHASH_H
#define TDENGINE_TSIMPLEHASH_H
#include "tarray.h"
#include "tlockfree.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
uint32_t
(
*
_hash_fn_t
)(
const
char
*
,
uint32_t
);
typedef
int32_t
(
*
_equal_fn_t
)(
const
void
*
,
const
void
*
,
size_t
len
);
typedef
void
(
*
_hash_free_fn_t
)(
void
*
);
typedef
struct
SSHashObj
SSHashObj
;
/**
* init the hash table
*
* @param capacity initial capacity of the hash table
* @param fn hash function to generate the hash value
* @return
*/
SSHashObj
*
tSimpleHashInit
(
size_t
capacity
,
_hash_fn_t
fn
,
size_t
keyLen
,
size_t
dataLen
);
/**
* return the size of hash table
* @param pHashObj
* @return
*/
int32_t
tSimpleHashGetSize
(
const
SSHashObj
*
pHashObj
);
/**
* put element into hash table, if the element with the same key exists, update it
* @param pHashObj
* @param key
* @param data
* @return
*/
int32_t
tSimpleHashPut
(
SSHashObj
*
pHashObj
,
const
void
*
key
,
const
void
*
data
);
/**
* return the payload data with the specified key
*
* @param pHashObj
* @param key
* @return
*/
void
*
tSimpleHashGet
(
SSHashObj
*
pHashObj
,
const
void
*
key
);
/**
* remove item with the specified key
* @param pHashObj
* @param key
* @param keyLen
*/
int32_t
tSimpleHashRemove
(
SSHashObj
*
pHashObj
,
const
void
*
key
);
/**
* Clear the hash table.
* @param pHashObj
*/
void
tSimpleHashClear
(
SSHashObj
*
pHashObj
);
/**
* Clean up hash table and release all allocated resources.
* @param handle
*/
void
tSimpleHashCleanup
(
SSHashObj
*
pHashObj
);
/**
* Get the hash table size
* @param pHashObj
* @return
*/
size_t
tSimpleHashGetMemSize
(
const
SSHashObj
*
pHashObj
);
/**
* Get the corresponding key information for a given data in hash table
* @param data
* @param keyLen
* @return
*/
void
*
tSimpleHashGetKey
(
const
SSHashObj
*
pHashObj
,
void
*
data
,
size_t
*
keyLen
);
#ifdef __cplusplus
}
#endif
#endif // TDENGINE_TSIMPLEHASH_H
source/libs/executor/src/executor.c
浏览文件 @
29fab2e3
...
@@ -95,17 +95,17 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, void* streamReadHandle) {
...
@@ -95,17 +95,17 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, void* streamReadHandle) {
}
}
int32_t
qUpdateQualifiedTableId
(
qTaskInfo_t
tinfo
,
SArray
*
tableIdList
,
bool
isAdd
)
{
int32_t
qUpdateQualifiedTableId
(
qTaskInfo_t
tinfo
,
SArray
*
tableIdList
,
bool
isAdd
)
{
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
tinfo
;
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
tinfo
;
// traverse to the streamscan node to add this table id
// traverse to the streamscan node to add this table id
SOperatorInfo
*
pInfo
=
pTaskInfo
->
pRoot
;
SOperatorInfo
*
pInfo
=
pTaskInfo
->
pRoot
;
while
(
pInfo
->
operatorType
!=
OP_StreamScan
)
{
while
(
pInfo
->
operatorType
!=
OP_StreamScan
)
{
pInfo
=
pInfo
->
pDownstream
[
0
];
pInfo
=
pInfo
->
pDownstream
[
0
];
}
}
SStreamBlockScanInfo
*
pScanInfo
=
pInfo
->
info
;
SStreamBlockScanInfo
*
pScanInfo
=
pInfo
->
info
;
if
(
isAdd
)
{
if
(
isAdd
)
{
int32_t
code
=
tqReadHandle
Set
TbUidList
(
pScanInfo
->
readerHandle
,
tableIdList
);
int32_t
code
=
tqReadHandle
Add
TbUidList
(
pScanInfo
->
readerHandle
,
tableIdList
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
...
@@ -114,4 +114,4 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, SArray* tableIdList, bool isA
...
@@ -114,4 +114,4 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, SArray* tableIdList, bool isA
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
\ No newline at end of file
source/libs/executor/src/executorMain.c
浏览文件 @
29fab2e3
...
@@ -158,7 +158,7 @@ int32_t qExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t *useconds) {
...
@@ -158,7 +158,7 @@ int32_t qExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t *useconds) {
int64_t
st
=
0
;
int64_t
st
=
0
;
st
=
taosGetTimestampUs
();
st
=
taosGetTimestampUs
();
*
pRes
=
pTaskInfo
->
pRoot
->
exec
(
pTaskInfo
->
pRoot
,
&
newgroup
);
*
pRes
=
pTaskInfo
->
pRoot
->
nextDataFn
(
pTaskInfo
->
pRoot
,
&
newgroup
);
uint64_t
el
=
(
taosGetTimestampUs
()
-
st
);
uint64_t
el
=
(
taosGetTimestampUs
()
-
st
);
pTaskInfo
->
cost
.
elapsedTime
+=
el
;
pTaskInfo
->
cost
.
elapsedTime
+=
el
;
...
@@ -179,13 +179,6 @@ int32_t qExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t *useconds) {
...
@@ -179,13 +179,6 @@ int32_t qExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t *useconds) {
return
pTaskInfo
->
code
;
return
pTaskInfo
->
code
;
}
}
void
*
qGetResultRetrieveMsg
(
qTaskInfo_t
qinfo
)
{
SQInfo
*
pQInfo
=
(
SQInfo
*
)
qinfo
;
assert
(
pQInfo
!=
NULL
);
return
pQInfo
->
rspContext
;
}
int32_t
qKillTask
(
qTaskInfo_t
qinfo
)
{
int32_t
qKillTask
(
qTaskInfo_t
qinfo
)
{
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
qinfo
;
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
qinfo
;
...
@@ -221,7 +214,7 @@ int32_t qAsyncKillTask(qTaskInfo_t qinfo) {
...
@@ -221,7 +214,7 @@ int32_t qAsyncKillTask(qTaskInfo_t qinfo) {
int32_t
qIsTaskCompleted
(
qTaskInfo_t
qinfo
)
{
int32_t
qIsTaskCompleted
(
qTaskInfo_t
qinfo
)
{
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
qinfo
;
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
qinfo
;
if
(
pTaskInfo
==
NULL
/*|| !isValidQInfo(pTaskInfo)*/
)
{
if
(
pTaskInfo
==
NULL
)
{
return
TSDB_CODE_QRY_INVALID_QHANDLE
;
return
TSDB_CODE_QRY_INVALID_QHANDLE
;
}
}
...
@@ -235,33 +228,3 @@ void qDestroyTask(qTaskInfo_t qTaskHandle) {
...
@@ -235,33 +228,3 @@ void qDestroyTask(qTaskInfo_t qTaskHandle) {
queryCostStatis
(
pTaskInfo
);
// print the query cost summary
queryCostStatis
(
pTaskInfo
);
// print the query cost summary
doDestroyTask
(
pTaskInfo
);
doDestroyTask
(
pTaskInfo
);
}
}
#if 0
//kill by qid
int32_t qKillQueryByQId(void* pMgmt, int64_t qId, int32_t waitMs, int32_t waitCount) {
int32_t error = TSDB_CODE_SUCCESS;
void** handle = qAcquireTask(pMgmt, qId);
if(handle == NULL) return terrno;
SQInfo* pQInfo = (SQInfo*)(*handle);
if (pQInfo == NULL || !isValidQInfo(pQInfo)) {
return TSDB_CODE_QRY_INVALID_QHANDLE;
}
qWarn("%s be killed(no memory commit).", pQInfo->qId);
setTaskKilled(pQInfo);
// wait query stop
int32_t loop = 0;
while (pQInfo->owner != 0) {
taosMsleep(waitMs);
if(loop++ > waitCount){
error = TSDB_CODE_FAILED;
break;
}
}
qReleaseTask(pMgmt, (void **)&handle, true);
return error;
}
#endif
source/libs/executor/src/executorimpl.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/executor/src/tlinearhash.c
浏览文件 @
29fab2e3
...
@@ -29,8 +29,8 @@ typedef struct SLHashBucket {
...
@@ -29,8 +29,8 @@ typedef struct SLHashBucket {
typedef
struct
SLHashObj
{
typedef
struct
SLHashObj
{
SDiskbasedBuf
*
pBuf
;
SDiskbasedBuf
*
pBuf
;
_hash_fn_t
hashFn
;
_hash_fn_t
hashFn
;
int32_t
tuplesPerPage
;
SLHashBucket
**
pBucket
;
// entry list
SLHashBucket
**
pBucket
;
// entry list
int32_t
tuplesPerPage
;
int32_t
numOfAlloc
;
// number of allocated bucket ptr slot
int32_t
numOfAlloc
;
// number of allocated bucket ptr slot
int32_t
bits
;
// the number of bits used in hash
int32_t
bits
;
// the number of bits used in hash
int32_t
numOfBuckets
;
// the number of buckets
int32_t
numOfBuckets
;
// the number of buckets
...
@@ -142,7 +142,7 @@ static void doRemoveFromBucket(SFilePage* pPage, SLHashNode* pNode, SLHashBucket
...
@@ -142,7 +142,7 @@ static void doRemoveFromBucket(SFilePage* pPage, SLHashNode* pNode, SLHashBucket
pBucket
->
size
-=
1
;
pBucket
->
size
-=
1
;
}
}
static
void
do
Compress
BucketPages
(
SLHashObj
*
pHashObj
,
SLHashBucket
*
pBucket
)
{
static
void
do
Trim
BucketPages
(
SLHashObj
*
pHashObj
,
SLHashBucket
*
pBucket
)
{
size_t
numOfPages
=
taosArrayGetSize
(
pBucket
->
pPageIdList
);
size_t
numOfPages
=
taosArrayGetSize
(
pBucket
->
pPageIdList
);
if
(
numOfPages
<=
1
)
{
if
(
numOfPages
<=
1
)
{
return
;
return
;
...
@@ -253,6 +253,7 @@ SLHashObj* tHashInit(int32_t inMemPages, int32_t pageSize, _hash_fn_t fn, int32_
...
@@ -253,6 +253,7 @@ SLHashObj* tHashInit(int32_t inMemPages, int32_t pageSize, _hash_fn_t fn, int32_
return
NULL
;
return
NULL
;
}
}
// disable compress when flushing to disk
setBufPageCompressOnDisk
(
pHashObj
->
pBuf
,
false
);
setBufPageCompressOnDisk
(
pHashObj
->
pBuf
,
false
);
/**
/**
...
@@ -367,7 +368,7 @@ int32_t tHashPut(SLHashObj* pHashObj, const void *key, size_t keyLen, void *data
...
@@ -367,7 +368,7 @@ int32_t tHashPut(SLHashObj* pHashObj, const void *key, size_t keyLen, void *data
releaseBufPage
(
pHashObj
->
pBuf
,
p
);
releaseBufPage
(
pHashObj
->
pBuf
,
p
);
}
}
do
Compress
BucketPages
(
pHashObj
,
pBucket
);
do
Trim
BucketPages
(
pHashObj
,
pBucket
);
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
...
source/libs/executor/src/tsimplehash.c
0 → 100644
浏览文件 @
29fab2e3
/*
* 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 "os.h"
#include "tsimplehash.h"
#include "taoserror.h"
#define SHASH_DEFAULT_LOAD_FACTOR 0.75
#define HASH_MAX_CAPACITY (1024*1024*16)
#define SHASH_NEED_RESIZE(_h) ((_h)->size >= (_h)->capacity * SHASH_DEFAULT_LOAD_FACTOR)
#define GET_SHASH_NODE_KEY(_n, _dl) ((char*)(_n) + sizeof(SHNode) + (_dl))
#define GET_SHASH_NODE_DATA(_n) ((char*)(_n) + sizeof(SHNode))
#define HASH_INDEX(v, c) ((v) & ((c)-1))
#define HASH_NEED_RESIZE(_h) ((_h)->size >= (_h)->capacity * SHASH_DEFAULT_LOAD_FACTOR)
#define FREE_HASH_NODE(_n) \
do { \
tfree(_n); \
} while (0);
typedef
struct
SHNode
{
struct
SHNode
*
next
;
char
data
[];
}
SHNode
;
typedef
struct
SSHashObj
{
SHNode
**
hashList
;
size_t
capacity
;
// number of slots
size_t
size
;
// number of elements in hash table
_hash_fn_t
hashFp
;
// hash function
_equal_fn_t
equalFp
;
// equal function
int32_t
keyLen
;
int32_t
dataLen
;
}
SSHashObj
;
static
FORCE_INLINE
int32_t
taosHashCapacity
(
int32_t
length
)
{
int32_t
len
=
MIN
(
length
,
HASH_MAX_CAPACITY
);
int32_t
i
=
4
;
while
(
i
<
len
)
i
=
(
i
<<
1u
);
return
i
;
}
SSHashObj
*
tSimpleHashInit
(
size_t
capacity
,
_hash_fn_t
fn
,
size_t
keyLen
,
size_t
dataLen
)
{
ASSERT
(
fn
!=
NULL
);
if
(
capacity
==
0
)
{
capacity
=
4
;
}
SSHashObj
*
pHashObj
=
(
SSHashObj
*
)
calloc
(
1
,
sizeof
(
SSHashObj
));
if
(
pHashObj
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
// the max slots is not defined by user
pHashObj
->
capacity
=
taosHashCapacity
((
int32_t
)
capacity
);
pHashObj
->
equalFp
=
memcmp
;
pHashObj
->
hashFp
=
fn
;
ASSERT
((
pHashObj
->
capacity
&
(
pHashObj
->
capacity
-
1
))
==
0
);
pHashObj
->
keyLen
=
keyLen
;
pHashObj
->
dataLen
=
dataLen
;
pHashObj
->
hashList
=
(
SHNode
**
)
calloc
(
pHashObj
->
capacity
,
sizeof
(
void
*
));
if
(
pHashObj
->
hashList
==
NULL
)
{
free
(
pHashObj
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
return
pHashObj
;
}
int32_t
tSimpleHashGetSize
(
const
SSHashObj
*
pHashObj
)
{
if
(
pHashObj
==
NULL
)
{
return
0
;
}
return
(
int32_t
)
atomic_load_64
(
&
pHashObj
->
size
);
}
static
SHNode
*
doCreateHashNode
(
const
void
*
key
,
size_t
keyLen
,
const
void
*
pData
,
size_t
dsize
,
uint32_t
hashVal
)
{
SHNode
*
pNewNode
=
malloc
(
sizeof
(
SHNode
)
+
keyLen
+
dsize
);
if
(
pNewNode
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
pNewNode
->
next
=
NULL
;
memcpy
(
GET_SHASH_NODE_DATA
(
pNewNode
),
pData
,
dsize
);
memcpy
(
GET_SHASH_NODE_KEY
(
pNewNode
,
dsize
),
key
,
keyLen
);
return
pNewNode
;
}
void
taosHashTableResize
(
SSHashObj
*
pHashObj
)
{
if
(
!
HASH_NEED_RESIZE
(
pHashObj
))
{
return
;
}
int32_t
newCapacity
=
(
int32_t
)(
pHashObj
->
capacity
<<
1u
);
if
(
newCapacity
>
HASH_MAX_CAPACITY
)
{
// uDebug("current capacity:%zu, maximum capacity:%d, no resize applied due to limitation is reached",
// pHashObj->capacity, HASH_MAX_CAPACITY);
return
;
}
int64_t
st
=
taosGetTimestampUs
();
void
*
pNewEntryList
=
realloc
(
pHashObj
->
hashList
,
sizeof
(
void
*
)
*
newCapacity
);
if
(
pNewEntryList
==
NULL
)
{
// qWarn("hash resize failed due to out of memory, capacity remain:%zu", pHashObj->capacity);
return
;
}
size_t
inc
=
newCapacity
-
pHashObj
->
capacity
;
memset
(
pNewEntryList
+
pHashObj
->
capacity
*
sizeof
(
void
*
),
0
,
inc
);
pHashObj
->
hashList
=
pNewEntryList
;
pHashObj
->
capacity
=
newCapacity
;
for
(
int32_t
idx
=
0
;
idx
<
pHashObj
->
capacity
;
++
idx
)
{
SHNode
*
pNode
=
pHashObj
->
hashList
[
idx
];
SHNode
*
pNext
;
SHNode
*
pPrev
=
NULL
;
if
(
pNode
==
NULL
)
{
continue
;
}
while
(
pNode
!=
NULL
)
{
void
*
key
=
GET_SHASH_NODE_KEY
(
pNode
,
pHashObj
->
dataLen
);
uint32_t
hashVal
=
(
*
pHashObj
->
hashFp
)(
key
,
(
uint32_t
)
pHashObj
->
dataLen
);
int32_t
newIdx
=
HASH_INDEX
(
hashVal
,
pHashObj
->
capacity
);
pNext
=
pNode
->
next
;
if
(
newIdx
!=
idx
)
{
if
(
pPrev
==
NULL
)
{
pHashObj
->
hashList
[
idx
]
=
pNext
;
}
else
{
pPrev
->
next
=
pNext
;
}
pNode
->
next
=
pHashObj
->
hashList
[
newIdx
];
pHashObj
->
hashList
[
newIdx
]
=
pNode
;
}
else
{
pPrev
=
pNode
;
}
pNode
=
pNext
;
}
}
int64_t
et
=
taosGetTimestampUs
();
// uDebug("hash table resize completed, new capacity:%d, load factor:%f, elapsed time:%fms", (int32_t)pHashObj->capacity,
// ((double)pHashObj->size) / pHashObj->capacity, (et - st) / 1000.0);
}
int32_t
tSimpleHashPut
(
SSHashObj
*
pHashObj
,
const
void
*
key
,
const
void
*
data
)
{
if
(
pHashObj
==
NULL
||
key
==
NULL
)
{
return
-
1
;
}
uint32_t
hashVal
=
(
*
pHashObj
->
hashFp
)(
key
,
(
uint32_t
)
pHashObj
->
keyLen
);
// need the resize process, write lock applied
if
(
SHASH_NEED_RESIZE
(
pHashObj
))
{
taosHashTableResize
(
pHashObj
);
}
int32_t
slot
=
HASH_INDEX
(
hashVal
,
pHashObj
->
capacity
);
SHNode
*
pNode
=
pHashObj
->
hashList
[
slot
];
if
(
pNode
==
NULL
)
{
SHNode
*
pNewNode
=
doCreateHashNode
(
key
,
pHashObj
->
keyLen
,
data
,
pHashObj
->
size
,
hashVal
);
if
(
pNewNode
==
NULL
)
{
return
-
1
;
}
pHashObj
->
hashList
[
slot
]
=
pNewNode
;
return
0
;
}
while
(
pNode
)
{
if
((
*
(
pHashObj
->
equalFp
))(
GET_SHASH_NODE_KEY
(
pNode
,
pHashObj
->
dataLen
),
key
,
pHashObj
->
keyLen
)
==
0
)
{
break
;
}
pNode
=
pNode
->
next
;
}
if
(
pNode
==
NULL
)
{
SHNode
*
pNewNode
=
doCreateHashNode
(
key
,
pHashObj
->
keyLen
,
data
,
pHashObj
->
size
,
hashVal
);
if
(
pNewNode
==
NULL
)
{
return
-
1
;
}
pNewNode
->
next
=
pHashObj
->
hashList
[
slot
];
pHashObj
->
hashList
[
slot
]
=
pNewNode
;
atomic_add_fetch_64
(
&
pHashObj
->
size
,
1
);
}
else
{
//update data
memcpy
(
GET_SHASH_NODE_DATA
(
pNode
),
data
,
pHashObj
->
dataLen
);
}
return
0
;
}
static
FORCE_INLINE
SHNode
*
doSearchInEntryList
(
SSHashObj
*
pHashObj
,
const
void
*
key
,
int32_t
index
)
{
SHNode
*
pNode
=
pHashObj
->
hashList
[
index
];
while
(
pNode
)
{
if
((
*
(
pHashObj
->
equalFp
))(
GET_SHASH_NODE_KEY
(
pNode
,
pHashObj
->
dataLen
),
key
,
pHashObj
->
keyLen
)
==
0
)
{
break
;
}
pNode
=
pNode
->
next
;
}
return
pNode
;
}
static
FORCE_INLINE
bool
taosHashTableEmpty
(
const
SSHashObj
*
pHashObj
)
{
return
tSimpleHashGetSize
(
pHashObj
)
==
0
;
}
void
*
tSimpleHashGet
(
SSHashObj
*
pHashObj
,
const
void
*
key
)
{
if
(
pHashObj
==
NULL
||
taosHashTableEmpty
(
pHashObj
)
||
key
==
NULL
)
{
return
NULL
;
}
uint32_t
hashVal
=
(
*
pHashObj
->
hashFp
)(
key
,
(
uint32_t
)
pHashObj
->
keyLen
);
int32_t
slot
=
HASH_INDEX
(
hashVal
,
pHashObj
->
capacity
);
SHNode
*
pNode
=
pHashObj
->
hashList
[
slot
];
if
(
pNode
==
NULL
)
{
return
NULL
;
}
char
*
data
=
NULL
;
pNode
=
doSearchInEntryList
(
pHashObj
,
key
,
slot
);
if
(
pNode
!=
NULL
)
{
data
=
GET_SHASH_NODE_DATA
(
pNode
);
}
return
data
;
}
int32_t
tSimpleHashRemove
(
SSHashObj
*
pHashObj
,
const
void
*
key
)
{
// todo
}
void
tSimpleHashClear
(
SSHashObj
*
pHashObj
)
{
if
(
pHashObj
==
NULL
)
{
return
;
}
SHNode
*
pNode
,
*
pNext
;
for
(
int32_t
i
=
0
;
i
<
pHashObj
->
capacity
;
++
i
)
{
pNode
=
pHashObj
->
hashList
[
i
];
if
(
pNode
==
NULL
)
{
continue
;
}
while
(
pNode
)
{
pNext
=
pNode
->
next
;
FREE_HASH_NODE
(
pNode
);
pNode
=
pNext
;
}
}
pHashObj
->
size
=
0
;
}
void
tSimpleHashCleanup
(
SSHashObj
*
pHashObj
)
{
if
(
pHashObj
==
NULL
)
{
return
;
}
tSimpleHashClear
(
pHashObj
);
tfree
(
pHashObj
->
hashList
);
}
size_t
tSimpleHashGetMemSize
(
const
SSHashObj
*
pHashObj
)
{
if
(
pHashObj
==
NULL
)
{
return
0
;
}
return
(
pHashObj
->
capacity
*
sizeof
(
void
*
))
+
sizeof
(
SHNode
)
*
tSimpleHashGetSize
(
pHashObj
)
+
sizeof
(
SSHashObj
);
}
void
*
tSimpleHashGetKey
(
const
SSHashObj
*
pHashObj
,
void
*
data
,
size_t
*
keyLen
)
{
int32_t
offset
=
offsetof
(
SHNode
,
data
);
SHNode
*
node
=
data
-
offset
;
if
(
keyLen
!=
NULL
)
{
*
keyLen
=
pHashObj
->
keyLen
;
}
return
GET_SHASH_NODE_KEY
(
node
,
pHashObj
->
dataLen
);
}
\ No newline at end of file
source/libs/executor/src/tsort.c
浏览文件 @
29fab2e3
...
@@ -16,11 +16,11 @@
...
@@ -16,11 +16,11 @@
#include "tcommon.h"
#include "tcommon.h"
#include "query.h"
#include "query.h"
#include "tsort.h"
#include "tdatablock.h"
#include "tep.h"
#include "tdef.h"
#include "tdef.h"
#include "tlosertree.h"
#include "tlosertree.h"
#include "tpagedbuf.h"
#include "tpagedbuf.h"
#include "tsort.h"
#include "tutil.h"
#include "tutil.h"
typedef
struct
STupleHandle
{
typedef
struct
STupleHandle
{
...
...
source/libs/executor/test/executorTests.cpp
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/executor/test/sortTests.cpp
浏览文件 @
29fab2e3
...
@@ -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,11 +25,12 @@
...
@@ -26,11 +25,12 @@
#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"
#include "tdatablock.h"
#include "tdef.h"
#include "tdef.h"
#include "tep.h"
#include "trpc.h"
#include "trpc.h"
#include "tvariant.h"
#include "tvariant.h"
...
...
source/libs/function/src/taggfunction.c
浏览文件 @
29fab2e3
...
@@ -28,8 +28,8 @@
...
@@ -28,8 +28,8 @@
#include "tbuffer.h"
#include "tbuffer.h"
#include "tcompression.h"
#include "tcompression.h"
//#include "queryLog.h"
//#include "queryLog.h"
#include "tdatablock.h"
#include "tudf.h"
#include "tudf.h"
#include "tep.h"
#define GET_INPUT_DATA_LIST(x) ((char *)((x)->pInput))
#define GET_INPUT_DATA_LIST(x) ((char *)((x)->pInput))
#define GET_INPUT_DATA(x, y) ((char*) colDataGetData((x)->pInput, (y)))
#define GET_INPUT_DATA(x, y) ((char*) colDataGetData((x)->pInput, (y)))
...
...
source/libs/function/src/tpercentile.c
浏览文件 @
29fab2e3
...
@@ -255,7 +255,7 @@ tMemBucket *tMemBucketCreate(int16_t nElemSize, int16_t dataType, double minval,
...
@@ -255,7 +255,7 @@ tMemBucket *tMemBucketCreate(int16_t nElemSize, int16_t dataType, double minval,
resetSlotInfo
(
pBucket
);
resetSlotInfo
(
pBucket
);
int32_t
ret
=
createDiskbasedBuf
(
&
pBucket
->
pBuffer
,
pBucket
->
bufPageSize
,
pBucket
->
bufPageSize
*
512
,
1
,
"/tmp"
);
int32_t
ret
=
createDiskbasedBuf
(
&
pBucket
->
pBuffer
,
pBucket
->
bufPageSize
,
pBucket
->
bufPageSize
*
512
,
"1"
,
"/tmp"
);
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
tMemBucketDestroy
(
pBucket
);
tMemBucketDestroy
(
pBucket
);
return
NULL
;
return
NULL
;
...
...
source/libs/index/inc/indexInt.h
浏览文件 @
29fab2e3
...
@@ -96,7 +96,7 @@ typedef struct SIndexTermQuery {
...
@@ -96,7 +96,7 @@ typedef struct SIndexTermQuery {
typedef
struct
Iterate
Iterate
;
typedef
struct
Iterate
Iterate
;
typedef
struct
IterateValue
{
typedef
struct
IterateValue
{
int8_t
type
;
int8_t
type
;
// opera type, ADD_VALUE/DELETE_VALUE
char
*
colVal
;
char
*
colVal
;
SArray
*
val
;
SArray
*
val
;
}
IterateValue
;
}
IterateValue
;
...
@@ -125,41 +125,41 @@ int32_t indexSerialCacheKey(ICacheKey* key, char* buf);
...
@@ -125,41 +125,41 @@ int32_t indexSerialCacheKey(ICacheKey* key, char* buf);
// int32_t indexSerialKey(ICacheKey* key, char* buf);
// int32_t indexSerialKey(ICacheKey* key, char* buf);
// int32_t indexSerialTermKey(SIndexTerm* itm, char* buf);
// int32_t indexSerialTermKey(SIndexTerm* itm, char* buf);
#define indexFatal(...) \
#define indexFatal(...)
\
do { \
do {
\
if (sDebugFlag & DEBUG_FATAL) { \
if (sDebugFlag & DEBUG_FATAL) {
\
taosPrintLog("index FATAL ", 255, __VA_ARGS__); \
taosPrintLog("index FATAL ",
DEBUG_FATAL,
255, __VA_ARGS__); \
} \
}
\
} while (0)
} while (0)
#define indexError(...) \
#define indexError(...)
\
do { \
do {
\
if (sDebugFlag & DEBUG_ERROR) { \
if (sDebugFlag & DEBUG_ERROR) {
\
taosPrintLog("index ERROR ", 255, __VA_ARGS__); \
taosPrintLog("index ERROR ",
DEBUG_ERROR,
255, __VA_ARGS__); \
} \
}
\
} while (0)
} while (0)
#define indexWarn(...) \
#define indexWarn(...)
\
do { \
do {
\
if (sDebugFlag & DEBUG_WARN) { \
if (sDebugFlag & DEBUG_WARN) {
\
taosPrintLog("index WARN ", 255, __VA_ARGS__); \
taosPrintLog("index WARN ",
DEBUG_WARN,
255, __VA_ARGS__); \
} \
}
\
} while (0)
} while (0)
#define indexInfo(...) \
#define indexInfo(...)
\
do { \
do {
\
if (sDebugFlag & DEBUG_INFO) { \
if (sDebugFlag & DEBUG_INFO) {
\
taosPrintLog("index ", 255, __VA_ARGS__); \
taosPrintLog("index ",
DEBUG_INFO,
255, __VA_ARGS__); \
} \
}
\
} while (0)
} while (0)
#define indexDebug(...) \
#define indexDebug(...)
\
do { \
do {
\
if (sDebugFlag & DEBUG_DEBUG) { \
if (sDebugFlag & DEBUG_DEBUG) {
\
taosPrintLog("index ", sDebugFlag, __VA_ARGS__); \
taosPrintLog("index ",
DEBUG_DEBUG,
sDebugFlag, __VA_ARGS__); \
} \
}
\
} while (0)
} while (0)
#define indexTrace(...) \
#define indexTrace(...)
\
do { \
do {
\
if (sDebugFlag & DEBUG_TRACE) { \
if (sDebugFlag & DEBUG_TRACE) {
\
taosPrintLog("index ", sDebugFlag, __VA_ARGS__); \
taosPrintLog("index ",
DEBUG_TRACE,
sDebugFlag, __VA_ARGS__); \
} \
}
\
} while (0)
} while (0)
#define INDEX_TYPE_CONTAIN_EXTERN_TYPE(ty, exTy) (((ty >> 4) & (exTy)) != 0)
#define INDEX_TYPE_CONTAIN_EXTERN_TYPE(ty, exTy) (((ty >> 4) & (exTy)) != 0)
...
...
source/libs/index/inc/index_util.h
浏览文件 @
29fab2e3
...
@@ -54,7 +54,22 @@ extern "C" {
...
@@ -54,7 +54,22 @@ extern "C" {
* output:[4, 5]
* output:[4, 5]
*/
*/
void
iIntersection
(
SArray
*
interResults
,
SArray
*
finalResult
);
void
iIntersection
(
SArray
*
interResults
,
SArray
*
finalResult
);
/* multi sorted result intersection
* input: [1, 2, 4, 5]
* [2, 3, 4, 5]
* [1, 4, 5]
* output:[1, 2, 3, 4, 5]
*/
void
iUnion
(
SArray
*
interResults
,
SArray
*
finalResult
);
void
iUnion
(
SArray
*
interResults
,
SArray
*
finalResult
);
/* sorted array
* total: [1, 2, 4, 5, 7, 8]
* except: [4, 5]
* return: [1, 2, 7, 8]
*/
void
iExcept
(
SArray
*
total
,
SArray
*
except
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/libs/index/src/index.c
浏览文件 @
29fab2e3
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#include "index.h"
#include "index.h"
#include "indexInt.h"
#include "indexInt.h"
#include "index_cache.h"
#include "index_cache.h"
#include "index_comm.h"
#include "index_tfile.h"
#include "index_tfile.h"
#include "index_util.h"
#include "index_util.h"
#include "tdef.h"
#include "tdef.h"
...
@@ -30,8 +31,18 @@
...
@@ -30,8 +31,18 @@
void
*
indexQhandle
=
NULL
;
void
*
indexQhandle
=
NULL
;
static
char
JSON_COLUMN
[]
=
"JSON"
;
#define INDEX_MERGE_ADD_DEL(src, dst, tgt) \
{ \
bool f = false; \
for (int i = 0; i < taosArrayGetSize(src); i++) { \
if (*(uint64_t*)taosArrayGet(src, i) == tgt) { \
f = true; \
} \
} \
if (f == false) { \
taosArrayPush(dst, &tgt); \
} \
}
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"
);
...
@@ -52,6 +63,12 @@ typedef struct SIdxColInfo {
...
@@ -52,6 +63,12 @@ typedef struct SIdxColInfo {
int
cVersion
;
int
cVersion
;
}
SIdxColInfo
;
}
SIdxColInfo
;
typedef
struct
SIdxTempResult
{
SArray
*
total
;
SArray
*
added
;
SArray
*
deled
;
}
SIdxTempResult
;
static
pthread_once_t
isInit
=
PTHREAD_ONCE_INIT
;
static
pthread_once_t
isInit
=
PTHREAD_ONCE_INIT
;
// static void indexInit();
// static void indexInit();
static
int
indexTermSearch
(
SIndex
*
sIdx
,
SIndexTermQuery
*
term
,
SArray
**
result
);
static
int
indexTermSearch
(
SIndex
*
sIdx
,
SIndexTermQuery
*
term
,
SArray
**
result
);
...
@@ -62,8 +79,7 @@ static int indexMergeFinalResults(SArray* interResults, EIndexOperatorType oTyp
...
@@ -62,8 +79,7 @@ static int indexMergeFinalResults(SArray* interResults, EIndexOperatorType oTyp
static
int
indexGenTFile
(
SIndex
*
index
,
IndexCache
*
cache
,
SArray
*
batch
);
static
int
indexGenTFile
(
SIndex
*
index
,
IndexCache
*
cache
,
SArray
*
batch
);
// merge cache and tfile by opera type
// merge cache and tfile by opera type
static
void
indexMergeCacheAndTFile
(
SArray
*
result
,
IterateValue
*
icache
,
IterateValue
*
iTfv
);
static
void
indexMergeCacheAndTFile
(
SArray
*
result
,
IterateValue
*
icache
,
IterateValue
*
iTfv
,
SIdxTempResult
*
helper
);
static
void
indexMergeSameKey
(
SArray
*
result
,
TFileValue
*
tv
);
// static int32_t indexSerialTermKey(SIndexTerm* itm, char* buf);
// static int32_t indexSerialTermKey(SIndexTerm* itm, char* buf);
// int32_t indexSerialKey(ICacheKey* key, char* buf);
// int32_t indexSerialKey(ICacheKey* key, char* buf);
...
@@ -379,7 +395,6 @@ static void indexInterResultsDestroy(SArray* results) {
...
@@ -379,7 +395,6 @@ static void indexInterResultsDestroy(SArray* results) {
static
int
indexMergeFinalResults
(
SArray
*
interResults
,
EIndexOperatorType
oType
,
SArray
*
fResults
)
{
static
int
indexMergeFinalResults
(
SArray
*
interResults
,
EIndexOperatorType
oType
,
SArray
*
fResults
)
{
// refactor, merge interResults into fResults by oType
// refactor, merge interResults into fResults by oType
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
interResults
);
i
--
)
{
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
interResults
);
i
--
)
{
SArray
*
t
=
taosArrayGetP
(
interResults
,
i
);
SArray
*
t
=
taosArrayGetP
(
interResults
,
i
);
taosArraySort
(
t
,
uidCompare
);
taosArraySort
(
t
,
uidCompare
);
...
@@ -398,44 +413,82 @@ static int indexMergeFinalResults(SArray* interResults, EIndexOperatorType oType
...
@@ -398,44 +413,82 @@ static int indexMergeFinalResults(SArray* interResults, EIndexOperatorType oType
return
0
;
return
0
;
}
}
static
void
indexMergeSameKey
(
SArray
*
result
,
TFileValue
*
tv
)
{
SIdxTempResult
*
sIdxTempResultCreate
()
{
int32_t
sz
=
result
?
taosArrayGetSize
(
result
)
:
0
;
SIdxTempResult
*
tr
=
calloc
(
1
,
sizeof
(
SIdxTempResult
));
tr
->
total
=
taosArrayInit
(
4
,
sizeof
(
uint64_t
));
tr
->
added
=
taosArrayInit
(
4
,
sizeof
(
uint64_t
));
tr
->
deled
=
taosArrayInit
(
4
,
sizeof
(
uint64_t
));
return
tr
;
}
void
sIdxTempResultClear
(
SIdxTempResult
*
tr
)
{
if
(
tr
==
NULL
)
{
return
;
}
taosArrayClear
(
tr
->
total
);
taosArrayClear
(
tr
->
added
);
taosArrayClear
(
tr
->
deled
);
}
void
sIdxTempResultDestroy
(
SIdxTempResult
*
tr
)
{
if
(
tr
==
NULL
)
{
return
;
}
taosArrayDestroy
(
tr
->
total
);
taosArrayDestroy
(
tr
->
added
);
taosArrayDestroy
(
tr
->
deled
);
}
static
void
sIdxTempResultMergeTo
(
SArray
*
result
,
SIdxTempResult
*
tr
)
{
taosArraySort
(
tr
->
total
,
uidCompare
);
taosArraySort
(
tr
->
added
,
uidCompare
);
taosArraySort
(
tr
->
deled
,
uidCompare
);
SArray
*
arrs
=
taosArrayInit
(
2
,
sizeof
(
void
*
));
taosArrayPush
(
arrs
,
&
tr
->
total
);
taosArrayPush
(
arrs
,
&
tr
->
added
);
iUnion
(
arrs
,
result
);
taosArrayDestroy
(
arrs
);
iExcept
(
result
,
tr
->
deled
);
}
static
void
indexMayMergeTempToFinalResult
(
SArray
*
result
,
TFileValue
*
tfv
,
SIdxTempResult
*
tr
)
{
int32_t
sz
=
taosArrayGetSize
(
result
);
if
(
sz
>
0
)
{
if
(
sz
>
0
)
{
// TODO(yihao): remove duplicate tableid
TFileValue
*
lv
=
taosArrayGetP
(
result
,
sz
-
1
);
TFileValue
*
lv
=
taosArrayGetP
(
result
,
sz
-
1
);
// indexError("merge colVal: %s", lv->colVal);
if
(
tfv
!=
NULL
&&
strcmp
(
lv
->
colVal
,
tfv
->
colVal
)
!=
0
)
{
if
(
strcmp
(
lv
->
colVal
,
tv
->
colVal
)
==
0
)
{
sIdxTempResultMergeTo
(
lv
->
tableId
,
tr
);
taosArrayAddAll
(
lv
->
tableId
,
tv
->
tableId
);
sIdxTempResultClear
(
tr
);
tfileValueDestroy
(
tv
);
taosArrayPush
(
result
,
&
tfv
);
}
else
if
(
tfv
==
NULL
)
{
// handle last iterator
sIdxTempResultMergeTo
(
lv
->
tableId
,
tr
);
}
else
{
}
else
{
taosArrayPush
(
result
,
&
tv
);
// temp result saved in help
tfileValueDestroy
(
tfv
);
}
}
}
else
{
}
else
{
taosArrayPush
(
result
,
&
tv
);
taosArrayPush
(
result
,
&
t
f
v
);
}
}
}
}
static
void
indexMergeCacheAndTFile
(
SArray
*
result
,
IterateValue
*
cv
,
IterateValue
*
tv
)
{
static
void
indexMergeCacheAndTFile
(
SArray
*
result
,
IterateValue
*
cv
,
IterateValue
*
tv
,
SIdxTempResult
*
tr
)
{
// opt
char
*
colVal
=
(
cv
!=
NULL
)
?
cv
->
colVal
:
tv
->
colVal
;
char
*
colVal
=
(
cv
!=
NULL
)
?
cv
->
colVal
:
tv
->
colVal
;
// design merge-algorithm later, too complicated to handle all kind of situation
TFileValue
*
tfv
=
tfileValueCreate
(
colVal
);
TFileValue
*
tfv
=
tfileValueCreate
(
colVal
);
indexMayMergeTempToFinalResult
(
result
,
tfv
,
tr
);
if
(
cv
!=
NULL
)
{
if
(
cv
!=
NULL
)
{
uint64_t
id
=
*
(
uint64_t
*
)
taosArrayGet
(
cv
->
val
,
0
);
if
(
cv
->
type
==
ADD_VALUE
)
{
if
(
cv
->
type
==
ADD_VALUE
)
{
taosArrayAddAll
(
tfv
->
tableId
,
cv
->
val
);
INDEX_MERGE_ADD_DEL
(
tr
->
deled
,
tr
->
added
,
id
)
}
else
if
(
cv
->
type
==
DEL_VALUE
)
{
}
else
if
(
cv
->
type
==
DEL_VALUE
)
{
}
else
if
(
cv
->
type
==
UPDATE_VALUE
)
{
INDEX_MERGE_ADD_DEL
(
tr
->
added
,
tr
->
deled
,
id
)
}
else
{
// do nothing
}
}
}
}
if
(
tv
!=
NULL
)
{
if
(
tv
!=
NULL
)
{
// opt later
taosArrayAddAll
(
tr
->
total
,
tv
->
val
);
taosArrayAddAll
(
tfv
->
tableId
,
tv
->
val
);
}
}
indexMergeSameKey
(
result
,
tfv
);
}
}
static
void
indexDestroy
Temp
Result
(
SArray
*
result
)
{
static
void
indexDestroy
Final
Result
(
SArray
*
result
)
{
int32_t
sz
=
result
?
taosArrayGetSize
(
result
)
:
0
;
int32_t
sz
=
result
?
taosArrayGetSize
(
result
)
:
0
;
for
(
size_t
i
=
0
;
i
<
sz
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
sz
;
i
++
)
{
TFileValue
*
tv
=
taosArrayGetP
(
result
,
i
);
TFileValue
*
tv
=
taosArrayGetP
(
result
,
i
);
...
@@ -443,6 +496,7 @@ static void indexDestroyTempResult(SArray* result) {
...
@@ -443,6 +496,7 @@ static void indexDestroyTempResult(SArray* result) {
}
}
taosArrayDestroy
(
result
);
taosArrayDestroy
(
result
);
}
}
int
indexFlushCacheToTFile
(
SIndex
*
sIdx
,
void
*
cache
)
{
int
indexFlushCacheToTFile
(
SIndex
*
sIdx
,
void
*
cache
)
{
if
(
sIdx
==
NULL
)
{
if
(
sIdx
==
NULL
)
{
return
-
1
;
return
-
1
;
...
@@ -467,6 +521,8 @@ int indexFlushCacheToTFile(SIndex* sIdx, void* cache) {
...
@@ -467,6 +521,8 @@ int indexFlushCacheToTFile(SIndex* sIdx, void* cache) {
bool
cn
=
cacheIter
?
cacheIter
->
next
(
cacheIter
)
:
false
;
bool
cn
=
cacheIter
?
cacheIter
->
next
(
cacheIter
)
:
false
;
bool
tn
=
tfileIter
?
tfileIter
->
next
(
tfileIter
)
:
false
;
bool
tn
=
tfileIter
?
tfileIter
->
next
(
tfileIter
)
:
false
;
SIdxTempResult
*
tr
=
sIdxTempResultCreate
();
while
(
cn
==
true
||
tn
==
true
)
{
while
(
cn
==
true
||
tn
==
true
)
{
IterateValue
*
cv
=
(
cn
==
true
)
?
cacheIter
->
getValue
(
cacheIter
)
:
NULL
;
IterateValue
*
cv
=
(
cn
==
true
)
?
cacheIter
->
getValue
(
cacheIter
)
:
NULL
;
IterateValue
*
tv
=
(
tn
==
true
)
?
tfileIter
->
getValue
(
tfileIter
)
:
NULL
;
IterateValue
*
tv
=
(
tn
==
true
)
?
tfileIter
->
getValue
(
tfileIter
)
:
NULL
;
...
@@ -480,19 +536,22 @@ int indexFlushCacheToTFile(SIndex* sIdx, void* cache) {
...
@@ -480,19 +536,22 @@ int indexFlushCacheToTFile(SIndex* sIdx, void* cache) {
comp
=
1
;
comp
=
1
;
}
}
if
(
comp
==
0
)
{
if
(
comp
==
0
)
{
indexMergeCacheAndTFile
(
result
,
cv
,
tv
);
indexMergeCacheAndTFile
(
result
,
cv
,
tv
,
tr
);
cn
=
cacheIter
->
next
(
cacheIter
);
cn
=
cacheIter
->
next
(
cacheIter
);
tn
=
tfileIter
->
next
(
tfileIter
);
tn
=
tfileIter
->
next
(
tfileIter
);
}
else
if
(
comp
<
0
)
{
}
else
if
(
comp
<
0
)
{
indexMergeCacheAndTFile
(
result
,
cv
,
NULL
);
indexMergeCacheAndTFile
(
result
,
cv
,
NULL
,
tr
);
cn
=
cacheIter
->
next
(
cacheIter
);
cn
=
cacheIter
->
next
(
cacheIter
);
}
else
{
}
else
{
indexMergeCacheAndTFile
(
result
,
NULL
,
tv
);
indexMergeCacheAndTFile
(
result
,
NULL
,
tv
,
tr
);
tn
=
tfileIter
->
next
(
tfileIter
);
tn
=
tfileIter
->
next
(
tfileIter
);
}
}
}
}
indexMayMergeTempToFinalResult
(
result
,
NULL
,
tr
);
sIdxTempResultDestroy
(
tr
);
int
ret
=
indexGenTFile
(
sIdx
,
pCache
,
result
);
int
ret
=
indexGenTFile
(
sIdx
,
pCache
,
result
);
indexDestroy
Temp
Result
(
result
);
indexDestroy
Final
Result
(
result
);
indexCacheDestroyImm
(
pCache
);
indexCacheDestroyImm
(
pCache
);
...
...
source/libs/index/src/index_cache.c
浏览文件 @
29fab2e3
...
@@ -267,6 +267,10 @@ static int indexQueryMem(MemTable* mem, CacheTerm* ct, EIndexQueryType qtype, SA
...
@@ -267,6 +267,10 @@ static int indexQueryMem(MemTable* mem, CacheTerm* ct, EIndexQueryType qtype, SA
SSkipListNode
*
node
=
tSkipListIterGet
(
iter
);
SSkipListNode
*
node
=
tSkipListIterGet
(
iter
);
if
(
node
!=
NULL
)
{
if
(
node
!=
NULL
)
{
CacheTerm
*
c
=
(
CacheTerm
*
)
SL_GET_NODE_DATA
(
node
);
CacheTerm
*
c
=
(
CacheTerm
*
)
SL_GET_NODE_DATA
(
node
);
// if (c->operaType == ADD_VALUE) {
//} else if (c->operaType == DEL_VALUE) {
//}
if
(
c
->
operaType
==
ADD_VALUE
||
qtype
==
QUERY_TERM
)
{
if
(
c
->
operaType
==
ADD_VALUE
||
qtype
==
QUERY_TERM
)
{
if
(
strcmp
(
c
->
colVal
,
ct
->
colVal
)
==
0
)
{
if
(
strcmp
(
c
->
colVal
,
ct
->
colVal
)
==
0
)
{
taosArrayPush
(
result
,
&
c
->
uid
);
taosArrayPush
(
result
,
&
c
->
uid
);
...
@@ -411,17 +415,8 @@ static bool indexCacheIteratorNext(Iterate* itera) {
...
@@ -411,17 +415,8 @@ static bool indexCacheIteratorNext(Iterate* itera) {
SSkipListNode
*
node
=
tSkipListIterGet
(
iter
);
SSkipListNode
*
node
=
tSkipListIterGet
(
iter
);
CacheTerm
*
ct
=
(
CacheTerm
*
)
SL_GET_NODE_DATA
(
node
);
CacheTerm
*
ct
=
(
CacheTerm
*
)
SL_GET_NODE_DATA
(
node
);
// equal func
// if (iv->colVal != NULL && ct->colVal != NULL) {
// if (0 == strcmp(iv->colVal, ct->colVal)) { if (iv->type == ADD_VALUE) }
//} else {
// tIterVal.colVal = calloc(1, strlen(ct->colVal) + 1);
// tIterval.colVal = tstrdup(ct->colVal);
//}
iv
->
type
=
ct
->
operaType
;
iv
->
type
=
ct
->
operaType
;
iv
->
colVal
=
tstrdup
(
ct
->
colVal
);
iv
->
colVal
=
tstrdup
(
ct
->
colVal
);
// iv->colVal = calloc(1, strlen(ct->colVal) + 1);
// memcpy(iv->colVal, ct->colVal, strlen(ct->colVal));
taosArrayPush
(
iv
->
val
,
&
ct
->
uid
);
taosArrayPush
(
iv
->
val
,
&
ct
->
uid
);
}
}
...
...
source/libs/index/src/index_fst_counting_writer.c
浏览文件 @
29fab2e3
...
@@ -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_tfile.c
浏览文件 @
29fab2e3
...
@@ -102,7 +102,6 @@ void tfileCacheDestroy(TFileCache* tcache) {
...
@@ -102,7 +102,6 @@ void tfileCacheDestroy(TFileCache* tcache) {
if
(
tcache
==
NULL
)
{
if
(
tcache
==
NULL
)
{
return
;
return
;
}
}
// free table cache
// free table cache
TFileReader
**
reader
=
taosHashIterate
(
tcache
->
tableCache
,
NULL
);
TFileReader
**
reader
=
taosHashIterate
(
tcache
->
tableCache
,
NULL
);
while
(
reader
)
{
while
(
reader
)
{
...
@@ -429,6 +428,7 @@ static bool tfileIteratorNext(Iterate* iiter) {
...
@@ -429,6 +428,7 @@ static bool tfileIteratorNext(Iterate* iiter) {
return
false
;
return
false
;
}
}
iv
->
type
=
ADD_VALUE
;
// value in tfile always ADD_VALUE
iv
->
colVal
=
colVal
;
iv
->
colVal
=
colVal
;
return
true
;
return
true
;
// std::string key(ch, sz);
// std::string key(ch, sz);
...
...
source/libs/index/src/index_util.c
浏览文件 @
29fab2e3
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
*/
*/
#include "index_util.h"
#include "index_util.h"
#include "index.h"
#include "index.h"
typedef
struct
MergeIndex
{
typedef
struct
MergeIndex
{
int
idx
;
int
idx
;
int
len
;
int
len
;
...
@@ -111,6 +112,26 @@ void iUnion(SArray *inters, SArray *final) {
...
@@ -111,6 +112,26 @@ void iUnion(SArray *inters, SArray *final) {
break
;
break
;
}
}
}
}
tfree
(
mi
);
tfree
(
mi
);
}
}
void
iExcept
(
SArray
*
total
,
SArray
*
except
)
{
int32_t
tsz
=
taosArrayGetSize
(
total
);
int32_t
esz
=
taosArrayGetSize
(
except
);
if
(
esz
==
0
||
tsz
==
0
)
{
return
;
}
int
vIdx
=
0
;
for
(
int
i
=
0
;
i
<
tsz
;
i
++
)
{
uint64_t
val
=
*
(
uint64_t
*
)
taosArrayGet
(
total
,
i
);
int
idx
=
iBinarySearch
(
except
,
0
,
esz
-
1
,
val
);
if
(
idx
>=
0
&&
idx
<
esz
&&
*
(
uint64_t
*
)
taosArrayGet
(
except
,
idx
)
==
val
)
{
continue
;
}
taosArraySet
(
total
,
vIdx
,
&
val
);
vIdx
+=
1
;
}
taosArrayPopTailBatch
(
total
,
tsz
-
vIdx
);
}
source/libs/index/test/fstTest.cc
浏览文件 @
29fab2e3
...
@@ -19,7 +19,7 @@ static std::string fileName = "/tmp/tindex.tindex";
...
@@ -19,7 +19,7 @@ static std::string fileName = "/tmp/tindex.tindex";
class
FstWriter
{
class
FstWriter
{
public:
public:
FstWriter
()
{
FstWriter
()
{
remov
e
(
fileName
.
c_str
());
taosRemoveFil
e
(
fileName
.
c_str
());
_wc
=
writerCtxCreate
(
TFile
,
fileName
.
c_str
(),
false
,
64
*
1024
*
1024
);
_wc
=
writerCtxCreate
(
TFile
,
fileName
.
c_str
(),
false
,
64
*
1024
*
1024
);
_b
=
fstBuilderCreate
(
_wc
,
0
);
_b
=
fstBuilderCreate
(
_wc
,
0
);
}
}
...
...
source/libs/index/test/jsonUT.cc
浏览文件 @
29fab2e3
...
@@ -105,6 +105,22 @@ TEST_F(JsonEnv, testWriteMillonData) {
...
@@ -105,6 +105,22 @@ TEST_F(JsonEnv, testWriteMillonData) {
}
}
indexMultiTermDestroy
(
terms
);
indexMultiTermDestroy
(
terms
);
}
}
{
std
::
string
colName
(
"voltagefdadfa"
);
std
::
string
colVal
(
"abxxxxxxxxxxxx"
);
for
(
uint
i
=
0
;
i
<
1000
;
i
++
)
{
colVal
[
i
%
colVal
.
size
()]
=
'0'
+
i
%
128
;
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
<
1000
;
i
++
)
{
tIndexJsonPut
(
index
,
terms
,
i
);
}
indexMultiTermDestroy
(
terms
);
}
}
{
{
std
::
string
colName
(
"voltagefdadfa"
);
std
::
string
colName
(
"voltagefdadfa"
);
std
::
string
colVal
(
"abxxxxxxxxxxxx"
);
std
::
string
colVal
(
"abxxxxxxxxxxxx"
);
...
...
source/libs/index/test/utilUT.cc
浏览文件 @
29fab2e3
...
@@ -224,3 +224,84 @@ TEST_F(UtilEnv, 04union) {
...
@@ -224,3 +224,84 @@ TEST_F(UtilEnv, 04union) {
iUnion
(
src
,
rslt
);
iUnion
(
src
,
rslt
);
assert
(
taosArrayGetSize
(
rslt
)
==
12
);
assert
(
taosArrayGetSize
(
rslt
)
==
12
);
}
}
TEST_F
(
UtilEnv
,
01
Except
)
{
SArray
*
total
=
taosArrayInit
(
4
,
sizeof
(
uint64_t
));
{
uint64_t
arr1
[]
=
{
1
,
4
,
5
,
6
};
for
(
int
i
=
0
;
i
<
sizeof
(
arr1
)
/
sizeof
(
arr1
[
0
]);
i
++
)
{
taosArrayPush
(
total
,
&
arr1
[
i
]);
}
}
SArray
*
except
=
taosArrayInit
(
4
,
sizeof
(
uint64_t
));
{
uint64_t
arr1
[]
=
{
1
,
4
,
5
,
6
};
for
(
int
i
=
0
;
i
<
sizeof
(
arr1
)
/
sizeof
(
arr1
[
0
]);
i
++
)
{
taosArrayPush
(
except
,
&
arr1
[
i
]);
}
}
iExcept
(
total
,
except
);
ASSERT_EQ
(
taosArrayGetSize
(
total
),
0
);
taosArrayClear
(
total
);
taosArrayClear
(
except
);
{
uint64_t
arr1
[]
=
{
1
,
4
,
5
,
6
,
7
,
8
};
for
(
int
i
=
0
;
i
<
sizeof
(
arr1
)
/
sizeof
(
arr1
[
0
]);
i
++
)
{
taosArrayPush
(
total
,
&
arr1
[
i
]);
}
}
{
uint64_t
arr1
[]
=
{
2
,
4
,
5
,
6
};
for
(
int
i
=
0
;
i
<
sizeof
(
arr1
)
/
sizeof
(
arr1
[
0
]);
i
++
)
{
taosArrayPush
(
except
,
&
arr1
[
i
]);
}
}
iExcept
(
total
,
except
);
ASSERT_EQ
(
taosArrayGetSize
(
total
),
3
);
taosArrayClear
(
total
);
taosArrayClear
(
except
);
{
uint64_t
arr1
[]
=
{
1
,
4
,
5
,
6
,
7
,
8
,
10
,
100
};
for
(
int
i
=
0
;
i
<
sizeof
(
arr1
)
/
sizeof
(
arr1
[
0
]);
i
++
)
{
taosArrayPush
(
total
,
&
arr1
[
i
]);
}
}
{
uint64_t
arr1
[]
=
{
2
,
4
,
5
,
6
};
for
(
int
i
=
0
;
i
<
sizeof
(
arr1
)
/
sizeof
(
arr1
[
0
]);
i
++
)
{
taosArrayPush
(
except
,
&
arr1
[
i
]);
}
}
iExcept
(
total
,
except
);
ASSERT_EQ
(
taosArrayGetSize
(
total
),
5
);
ASSERT_EQ
(
*
(
uint64_t
*
)
taosArrayGet
(
total
,
0
),
1
);
ASSERT_EQ
(
*
(
uint64_t
*
)
taosArrayGet
(
total
,
1
),
7
);
ASSERT_EQ
(
*
(
uint64_t
*
)
taosArrayGet
(
total
,
2
),
8
);
ASSERT_EQ
(
*
(
uint64_t
*
)
taosArrayGet
(
total
,
3
),
10
);
ASSERT_EQ
(
*
(
uint64_t
*
)
taosArrayGet
(
total
,
4
),
100
);
taosArrayClear
(
total
);
taosArrayClear
(
except
);
{
uint64_t
arr1
[]
=
{
1
,
100
};
for
(
int
i
=
0
;
i
<
sizeof
(
arr1
)
/
sizeof
(
arr1
[
0
]);
i
++
)
{
taosArrayPush
(
total
,
&
arr1
[
i
]);
}
}
{
uint64_t
arr1
[]
=
{
2
,
4
,
5
,
6
};
for
(
int
i
=
0
;
i
<
sizeof
(
arr1
)
/
sizeof
(
arr1
[
0
]);
i
++
)
{
taosArrayPush
(
except
,
&
arr1
[
i
]);
}
}
iExcept
(
total
,
except
);
ASSERT_EQ
(
taosArrayGetSize
(
total
),
2
);
ASSERT_EQ
(
*
(
uint64_t
*
)
taosArrayGet
(
total
,
0
),
1
);
ASSERT_EQ
(
*
(
uint64_t
*
)
taosArrayGet
(
total
,
1
),
100
);
}
source/libs/monitor/inc/monInt.h
浏览文件 @
29fab2e3
...
@@ -23,18 +23,24 @@
...
@@ -23,18 +23,24 @@
#include "tjson.h"
#include "tjson.h"
typedef
struct
{
typedef
struct
{
SRWLatch
lock
;
int64_t
ts
;
SArray
*
logs
;
// array of SMonLogItem
ELogLevel
level
;
int32_t
maxLogs
;
char
content
[
MON_LOG_LEN
];
const
char
*
server
;
}
SMonLogItem
;
uint16_t
port
;
}
SMonitor
;
typedef
struct
SMonInfo
{
typedef
struct
SMonInfo
{
SArray
*
logs
;
// array of SMonLogItem
SArray
*
logs
;
// array of SMonLogItem
SJson
*
pJson
;
SJson
*
pJson
;
}
SMonInfo
;
}
SMonInfo
;
typedef
struct
{
pthread_mutex_t
lock
;
SArray
*
logs
;
// array of SMonLogItem
int32_t
maxLogs
;
const
char
*
server
;
uint16_t
port
;
}
SMonitor
;
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/libs/monitor/src/monitor.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/monitor/test/monTest.cpp
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/parser/src/insertParser.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/parser/test/mockCatalog.cpp
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/parser/test/mockCatalogService.cpp
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/parser/test/parserTests.cpp
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/parser/test/plannerTest.cpp
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/qcom/src/queryUtil.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/qworker/test/qworkerTests.cpp
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/scalar/inc/filterInt.h
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/scalar/src/filter.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/scalar/src/scalar.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/scalar/src/sclvector.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/scalar/test/filter/filterTests.cpp
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/scalar/test/scalar/scalarTests.cpp
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/scheduler/test/schedulerTests.cpp
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/sync/inc/syncInt.h
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/sync/src/syncIO.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncIOSendMsgClientTest.cpp
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncIOSendMsgServerTest.cpp
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncIOSendMsgTest.cpp
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncIOTickPingTest.cpp
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncIOTickQTest.cpp
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncRaftStoreTest.cpp
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/sync/test/syncTest.cpp
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/tdb/src/db/tdb.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/tdb/src/db/tdbUtil.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/tdb/src/inc/tdbUtil.h
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/tdb/test/tdbTest.cpp
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/tfs/CMakeLists.txt
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/tfs/inc/tfsInt.h
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/tfs/src/tfs.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/tfs/test/tfsTest.cpp
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/transport/inc/rpcLog.h
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/transport/test/pushClient.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/transport/test/pushServer.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/transport/test/rclient.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/transport/test/rserver.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/transport/test/syncClient.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/transport/test/transUT.cc
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/wal/src/walMeta.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/wal/src/walWrite.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/libs/wal/test/walMetaTest.cpp
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/os/src/osDir.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/os/src/osEnv.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/os/src/osFile.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/os/src/osSysinfo.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/util/src/tcache.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/util/src/tconfig.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/util/src/terror.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/util/src/thash.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/util/src/thttp.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/util/src/tlog.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/util/src/tpagedbuf.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/util/src/ttimer.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/util/test/arrayTest.cpp
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/util/test/cacheTest.cpp
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/util/test/encodeTest.cpp
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/util/test/freelistTest.cpp
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/util/test/hashTest.cpp
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
source/util/test/pageBufferTest.cpp
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
tests
@
904e6f0e
比较
08ed39f0
...
904e6f0e
此差异已折叠。
点击以展开。
tools/shell/src/backup/shellImport.c
浏览文件 @
29fab2e3
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录