Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
02400c15
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
02400c15
编写于
4月 28, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: add unitest for sdb
上级
a13cb870
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
69 addition
and
69 deletion
+69
-69
source/dnode/mnode/impl/test/sdb/sdbTest.cpp
source/dnode/mnode/impl/test/sdb/sdbTest.cpp
+62
-60
source/dnode/mnode/sdb/inc/sdbInt.h
source/dnode/mnode/sdb/inc/sdbInt.h
+0
-2
source/dnode/mnode/sdb/src/sdb.c
source/dnode/mnode/sdb/src/sdb.c
+4
-4
source/dnode/mnode/sdb/src/sdbFile.c
source/dnode/mnode/sdb/src/sdbFile.c
+3
-3
未找到文件。
source/dnode/mnode/impl/test/sdb/sdbTest.cpp
浏览文件 @
02400c15
...
...
@@ -343,6 +343,8 @@ int32_t strDefault(SMnode *pMnode) {
pRaw
=
strEncode
(
&
strObj
);
sdbSetRawStatus
(
pRaw
,
SDB_STATUS_READY
);
if
(
sdbWriteWithoutFree
(
pMnode
->
pSdb
,
pRaw
)
!=
0
)
return
-
1
;
EXPECT_EQ
(
sdbGetRawTotalSize
(
pRaw
),
79
);
sdbFreeRaw
(
pRaw
);
return
0
;
...
...
@@ -386,36 +388,36 @@ TEST_F(MndTestSdb, 01_Write_Str) {
opt
.
path
=
"/tmp/mnode_test_sdb"
;
taosRemoveDir
(
opt
.
path
);
SSdbTable
strTable1
=
{
.
sdbType
=
SDB_USER
,
.
keyType
=
SDB_KEY_BINARY
,
.
deployFp
=
(
SdbDeployFp
)
strDefault
,
.
encodeFp
=
(
SdbEncodeFp
)
strEncode
,
.
decodeFp
=
(
SdbDecodeFp
)
strDecode
,
.
insertFp
=
(
SdbInsertFp
)
strInsert
,
.
updateFp
=
(
SdbUpdateFp
)
strUpdate
,
.
deleteFp
=
(
SdbDeleteFp
)
strDelete
,
}
;
SSdbTable
strTable2
=
{
.
sdbType
=
SDB_VGROUP
,
.
keyType
=
SDB_KEY_INT32
,
.
encodeFp
=
(
SdbEncodeFp
)
i32Encode
,
.
decodeFp
=
(
SdbDecodeFp
)
i32Decode
,
.
insertFp
=
(
SdbInsertFp
)
i32Insert
,
.
updateFp
=
(
SdbUpdateFp
)
i32Update
,
.
deleteFp
=
(
SdbDeleteFp
)
i32Delete
,
}
;
SSdbTable
strTable3
=
{
.
sdbType
=
SDB_CONSUMER
,
.
keyType
=
SDB_KEY_INT64
,
.
encodeFp
=
(
SdbEncodeFp
)
i64Encode
,
.
decodeFp
=
(
SdbDecodeFp
)
i64Decode
,
.
insertFp
=
(
SdbInsertFp
)
i64Insert
,
.
updateFp
=
(
SdbUpdateFp
)
i64Update
,
.
deleteFp
=
(
SdbDeleteFp
)
i64Delete
,
}
;
SSdbTable
strTable1
;
memset
(
&
strTable1
,
0
,
sizeof
(
SSdbTable
));
strTable1
.
sdbType
=
SDB_USER
;
strTable1
.
keyType
=
SDB_KEY_BINARY
;
strTable1
.
deployFp
=
(
SdbDeployFp
)
strDefault
;
strTable1
.
encodeFp
=
(
SdbEncodeFp
)
strEncode
;
strTable1
.
decodeFp
=
(
SdbDecodeFp
)
strDecode
;
strTable1
.
insertFp
=
(
SdbInsertFp
)
strInsert
;
strTable1
.
updateFp
=
(
SdbUpdateFp
)
strUpdate
;
strTable1
.
deleteFp
=
(
SdbDeleteFp
)
strDelete
;
SSdbTable
strTable2
;
memset
(
&
strTable2
,
0
,
sizeof
(
SSdbTable
));
strTable2
.
sdbType
=
SDB_VGROUP
;
strTable2
.
keyType
=
SDB_KEY_INT32
;
strTable2
.
encodeFp
=
(
SdbEncodeFp
)
i32Encode
;
strTable2
.
decodeFp
=
(
SdbDecodeFp
)
i32Decode
;
strTable2
.
insertFp
=
(
SdbInsertFp
)
i32Insert
;
strTable2
.
updateFp
=
(
SdbUpdateFp
)
i32Update
;
strTable2
.
deleteFp
=
(
SdbDeleteFp
)
i32Delete
;
SSdbTable
strTable3
;
memset
(
&
strTable3
,
0
,
sizeof
(
SSdbTable
));
strTable3
.
sdbType
=
SDB_CONSUMER
;
strTable3
.
keyType
=
SDB_KEY_INT64
;
strTable3
.
encodeFp
=
(
SdbEncodeFp
)
i64Encode
;
strTable3
.
decodeFp
=
(
SdbDecodeFp
)
i64Decode
;
strTable3
.
insertFp
=
(
SdbInsertFp
)
i64Insert
;
strTable3
.
updateFp
=
(
SdbUpdateFp
)
i64Update
;
strTable3
.
deleteFp
=
(
SdbDeleteFp
)
i64Delete
;
pSdb
=
sdbInit
(
&
opt
);
mnode
.
pSdb
=
pSdb
;
...
...
@@ -730,36 +732,36 @@ TEST_F(MndTestSdb, 01_Read_Str) {
opt
.
pMnode
=
&
mnode
;
opt
.
path
=
"/tmp/mnode_test_sdb"
;
SSdbTable
strTable1
=
{
.
sdbType
=
SDB_USER
,
.
keyType
=
SDB_KEY_BINARY
,
.
deployFp
=
(
SdbDeployFp
)
strDefault
,
.
encodeFp
=
(
SdbEncodeFp
)
strEncode
,
.
decodeFp
=
(
SdbDecodeFp
)
strDecode
,
.
insertFp
=
(
SdbInsertFp
)
strInsert
,
.
updateFp
=
(
SdbUpdateFp
)
strUpdate
,
.
deleteFp
=
(
SdbDeleteFp
)
strDelete
,
}
;
SSdbTable
strTable2
=
{
.
sdbType
=
SDB_VGROUP
,
.
keyType
=
SDB_KEY_INT32
,
.
encodeFp
=
(
SdbEncodeFp
)
i32Encode
,
.
decodeFp
=
(
SdbDecodeFp
)
i32Decode
,
.
insertFp
=
(
SdbInsertFp
)
i32Insert
,
.
updateFp
=
(
SdbUpdateFp
)
i32Update
,
.
deleteFp
=
(
SdbDeleteFp
)
i32Delete
,
}
;
SSdbTable
strTable3
=
{
.
sdbType
=
SDB_CONSUMER
,
.
keyType
=
SDB_KEY_INT64
,
.
encodeFp
=
(
SdbEncodeFp
)
i64Encode
,
.
decodeFp
=
(
SdbDecodeFp
)
i64Decode
,
.
insertFp
=
(
SdbInsertFp
)
i64Insert
,
.
updateFp
=
(
SdbUpdateFp
)
i64Update
,
.
deleteFp
=
(
SdbDeleteFp
)
i64Delete
,
}
;
SSdbTable
strTable1
;
memset
(
&
strTable1
,
0
,
sizeof
(
SSdbTable
));
strTable1
.
sdbType
=
SDB_USER
;
strTable1
.
keyType
=
SDB_KEY_BINARY
;
strTable1
.
deployFp
=
(
SdbDeployFp
)
strDefault
;
strTable1
.
encodeFp
=
(
SdbEncodeFp
)
strEncode
;
strTable1
.
decodeFp
=
(
SdbDecodeFp
)
strDecode
;
strTable1
.
insertFp
=
(
SdbInsertFp
)
strInsert
;
strTable1
.
updateFp
=
(
SdbUpdateFp
)
strUpdate
;
strTable1
.
deleteFp
=
(
SdbDeleteFp
)
strDelete
;
SSdbTable
strTable2
;
memset
(
&
strTable2
,
0
,
sizeof
(
SSdbTable
));
strTable2
.
sdbType
=
SDB_VGROUP
;
strTable2
.
keyType
=
SDB_KEY_INT32
;
strTable2
.
encodeFp
=
(
SdbEncodeFp
)
i32Encode
;
strTable2
.
decodeFp
=
(
SdbDecodeFp
)
i32Decode
;
strTable2
.
insertFp
=
(
SdbInsertFp
)
i32Insert
;
strTable2
.
updateFp
=
(
SdbUpdateFp
)
i32Update
;
strTable2
.
deleteFp
=
(
SdbDeleteFp
)
i32Delete
;
SSdbTable
strTable3
;
memset
(
&
strTable3
,
0
,
sizeof
(
SSdbTable
));
strTable3
.
sdbType
=
SDB_CONSUMER
;
strTable3
.
keyType
=
SDB_KEY_INT64
;
strTable3
.
encodeFp
=
(
SdbEncodeFp
)
i64Encode
;
strTable3
.
decodeFp
=
(
SdbDecodeFp
)
i64Decode
;
strTable3
.
insertFp
=
(
SdbInsertFp
)
i64Insert
;
strTable3
.
updateFp
=
(
SdbUpdateFp
)
i64Update
;
strTable3
.
deleteFp
=
(
SdbDeleteFp
)
i64Delete
;
pSdb
=
sdbInit
(
&
opt
);
mnode
.
pSdb
=
pSdb
;
...
...
source/dnode/mnode/sdb/inc/sdbInt.h
浏览文件 @
02400c15
...
...
@@ -31,8 +31,6 @@ extern "C" {
#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__); }}
#define SDB_MAX_SIZE (32 * 1024)
typedef
struct
SSdbRaw
{
int8_t
type
;
int8_t
status
;
...
...
source/dnode/mnode/sdb/src/sdb.c
浏览文件 @
02400c15
...
...
@@ -28,12 +28,12 @@ SSdb *sdbInit(SSdbOpt *pOption) {
return
NULL
;
}
char
path
[
PATH_MAX
+
100
];
snprintf
(
path
,
PATH_MAX
+
100
,
"%s%sdata"
,
pOption
->
path
,
TD_DIRSEP
);
char
path
[
PATH_MAX
+
100
]
=
{
0
}
;
snprintf
(
path
,
sizeof
(
path
)
,
"%s%sdata"
,
pOption
->
path
,
TD_DIRSEP
);
pSdb
->
currDir
=
strdup
(
path
);
snprintf
(
path
,
PATH_MAX
+
100
,
"%s%ssync"
,
pOption
->
path
,
TD_DIRSEP
);
snprintf
(
path
,
sizeof
(
path
)
,
"%s%ssync"
,
pOption
->
path
,
TD_DIRSEP
);
pSdb
->
syncDir
=
strdup
(
path
);
snprintf
(
path
,
PATH_MAX
+
100
,
"%s%stmp"
,
pOption
->
path
,
TD_DIRSEP
);
snprintf
(
path
,
sizeof
(
path
)
,
"%s%stmp"
,
pOption
->
path
,
TD_DIRSEP
);
pSdb
->
tmpDir
=
strdup
(
path
);
if
(
pSdb
->
currDir
==
NULL
||
pSdb
->
currDir
==
NULL
||
pSdb
->
currDir
==
NULL
)
{
sdbCleanup
(
pSdb
);
...
...
source/dnode/mnode/sdb/src/sdbFile.c
浏览文件 @
02400c15
...
...
@@ -66,7 +66,7 @@ static int32_t sdbReadFileHead(SSdb *pSdb, TdFilePtr pFile) {
}
for
(
int32_t
i
=
0
;
i
<
SDB_TABLE_SIZE
;
++
i
)
{
int64_t
ver
=
-
1
;
int64_t
ver
=
0
;
ret
=
taosReadFile
(
pFile
,
&
ver
,
sizeof
(
int64_t
));
if
(
ret
<
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
...
...
@@ -209,7 +209,7 @@ int32_t sdbReadFile(SSdb *pSdb) {
code
=
sdbWriteWithoutFree
(
pSdb
,
pRaw
);
if
(
code
!=
0
)
{
mError
(
"failed to read file:%s since %s"
,
file
,
terrstr
());
goto
PARSE_SDB_DATA_ERRO
R
;
goto
_OVE
R
;
}
}
...
...
@@ -218,7 +218,7 @@ int32_t sdbReadFile(SSdb *pSdb) {
memcpy
(
pSdb
->
tableVer
,
tableVer
,
sizeof
(
tableVer
));
mDebug
(
"read file:%s successfully, ver:%"
PRId64
,
file
,
pSdb
->
lastCommitVer
);
PARSE_SDB_DATA_ERRO
R:
_OVE
R:
taosCloseFile
(
&
pFile
);
sdbFreeRaw
(
pRaw
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录