Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
de3e8861
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
de3e8861
编写于
10月 09, 2022
作者:
M
Minglei Jin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(test): ovfl page case with border condition checking
上级
d05b134a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
58 addition
and
49 deletion
+58
-49
source/libs/tdb/test/tdbExOVFLTest.cpp
source/libs/tdb/test/tdbExOVFLTest.cpp
+58
-49
未找到文件。
source/libs/tdb/test/tdbExOVFLTest.cpp
浏览文件 @
de3e8861
...
...
@@ -119,12 +119,12 @@ static int tDefaultKeyCmpr(const void *pKey1, int keyLen1, const void *pKey2, in
return
cret
;
}
TEST
(
TdbOVFLPagesTest
,
TbUpsertTest
)
{
TEST
(
TdbOVFLPagesTest
,
DISABLED_
TbUpsertTest
)
{
// TEST(TdbOVFLPagesTest, TbUpsertTest) {
}
TEST
(
TdbOVFLPagesTest
,
TbPGetTest
)
{
TEST
(
TdbOVFLPagesTest
,
DISABLED_
TbPGetTest
)
{
// TEST(TdbOVFLPagesTest, TbPGetTest) {
}
static
void
generateBigVal
(
char
*
val
,
int
valLen
)
{
...
...
@@ -156,32 +156,36 @@ static void insertOfp(void) {
// open Env
int
const
pageSize
=
4096
;
int
const
pageNum
=
64
;
TDB
*
pEnv
=
openEnv
(
"tdb"
,
pageSize
,
pageNum
);
TDB
*
pEnv
=
openEnv
(
"tdb"
,
pageSize
,
pageNum
);
GTEST_ASSERT_NE
(
pEnv
,
nullptr
);
// open db
TTB
*
pDb
=
NULL
;
TTB
*
pDb
=
NULL
;
tdb_cmpr_fn_t
compFunc
=
tKeyCmpr
;
ret
=
tdbTbOpen
(
"ofp_insert.db"
,
-
1
,
-
1
,
compFunc
,
pEnv
,
&
pDb
);
// ret = tdbTbOpen("ofp_insert.db", -1, -1, compFunc, pEnv, &pDb);
ret
=
tdbTbOpen
(
"ofp_insert.db"
,
12
,
-
1
,
compFunc
,
pEnv
,
&
pDb
);
GTEST_ASSERT_EQ
(
ret
,
0
);
// open the pool
SPoolMem
*
pPool
=
openPool
();
// start a transaction
TXN
txn
;
TXN
txn
;
int64_t
txnid
=
0
;
++
txnid
;
tdbTxnOpen
(
&
txn
,
txnid
,
poolMalloc
,
poolFree
,
pPool
,
TDB_TXN_WRITE
|
TDB_TXN_READ_UNCOMMITTED
);
tdbBegin
(
pEnv
,
&
txn
);
// generate value payload
char
val
[((
4083
-
4
-
3
-
2
)
+
1
)
*
100
];
// pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4)
int
valLen
=
sizeof
(
val
)
/
sizeof
(
val
[
0
]);
// char val[((4083 - 4 - 3 - 2) + 1) * 100]; // pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4)
char
val
[
32605
];
int
valLen
=
sizeof
(
val
)
/
sizeof
(
val
[
0
]);
generateBigVal
(
val
,
valLen
);
// insert the generated big data
ret
=
tdbTbInsert
(
pDb
,
"key1"
,
strlen
(
"key1"
),
val
,
valLen
,
&
txn
);
// char const *key = "key1";
char
const
*
key
=
"key123456789"
;
ret
=
tdbTbInsert
(
pDb
,
key
,
strlen
(
key
),
val
,
valLen
,
&
txn
);
GTEST_ASSERT_EQ
(
ret
,
0
);
// commit current transaction
...
...
@@ -189,37 +193,41 @@ static void insertOfp(void) {
tdbTxnClose
(
&
txn
);
}
//
TEST(TdbOVFLPagesTest, DISABLED_TbInsertTest) {
TEST
(
TdbOVFLPagesTest
,
TbInsertTest
)
{
TEST
(
TdbOVFLPagesTest
,
DISABLED_TbInsertTest
)
{
//
TEST(TdbOVFLPagesTest, TbInsertTest) {
insertOfp
();
}
//TEST(TdbOVFLPagesTest, DISABLED_TbGetTest) {
//
TEST(TdbOVFLPagesTest, DISABLED_TbGetTest) {
TEST
(
TdbOVFLPagesTest
,
TbGetTest
)
{
insertOfp
();
// open Env
int
const
pageSize
=
4096
;
int
const
pageNum
=
64
;
TDB
*
pEnv
=
openEnv
(
"tdb"
,
pageSize
,
pageNum
);
TDB
*
pEnv
=
openEnv
(
"tdb"
,
pageSize
,
pageNum
);
GTEST_ASSERT_NE
(
pEnv
,
nullptr
);
// open db
TTB
*
pDb
=
NULL
;
TTB
*
pDb
=
NULL
;
tdb_cmpr_fn_t
compFunc
=
tKeyCmpr
;
int
ret
=
tdbTbOpen
(
"ofp_insert.db"
,
-
1
,
-
1
,
compFunc
,
pEnv
,
&
pDb
);
// int ret = tdbTbOpen("ofp_insert.db", -1, -1, compFunc, pEnv, &pDb);
int
ret
=
tdbTbOpen
(
"ofp_insert.db"
,
12
,
-
1
,
compFunc
,
pEnv
,
&
pDb
);
GTEST_ASSERT_EQ
(
ret
,
0
);
// generate value payload
char
val
[((
4083
-
4
-
3
-
2
)
+
1
)
*
100
];
// pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4)
int
valLen
=
sizeof
(
val
)
/
sizeof
(
val
[
0
]);
// char val[((4083 - 4 - 3 - 2) + 1) * 100]; // pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4)
char
val
[
32605
];
int
valLen
=
sizeof
(
val
)
/
sizeof
(
val
[
0
]);
generateBigVal
(
val
,
valLen
);
{
// Query the data
void
*
pVal
=
NULL
;
int
vLen
;
ret
=
tdbTbGet
(
pDb
,
"key1"
,
strlen
(
"key1"
),
&
pVal
,
&
vLen
);
// char const *key = "key1";
char
const
*
key
=
"key123456789"
;
ret
=
tdbTbGet
(
pDb
,
key
,
strlen
(
key
),
&
pVal
,
&
vLen
);
ASSERT
(
ret
==
0
);
GTEST_ASSERT_EQ
(
ret
,
0
);
...
...
@@ -230,7 +238,8 @@ TEST(TdbOVFLPagesTest, TbGetTest) {
}
}
TEST
(
TdbOVFLPagesTest
,
TbDeleteTest
)
{
TEST
(
TdbOVFLPagesTest
,
DISABLED_TbDeleteTest
)
{
// TEST(TdbOVFLPagesTest, TbDeleteTest) {
int
ret
=
0
;
taosRemoveDir
(
"tdb"
);
...
...
@@ -238,11 +247,11 @@ TEST(TdbOVFLPagesTest, TbDeleteTest) {
// open Env
int
const
pageSize
=
4096
;
int
const
pageNum
=
64
;
TDB
*
pEnv
=
openEnv
(
"tdb"
,
pageSize
,
pageNum
);
TDB
*
pEnv
=
openEnv
(
"tdb"
,
pageSize
,
pageNum
);
GTEST_ASSERT_NE
(
pEnv
,
nullptr
);
// open db
TTB
*
pDb
=
NULL
;
TTB
*
pDb
=
NULL
;
tdb_cmpr_fn_t
compFunc
=
tKeyCmpr
;
ret
=
tdbTbOpen
(
"ofp_insert.db"
,
-
1
,
-
1
,
compFunc
,
pEnv
,
&
pDb
);
GTEST_ASSERT_EQ
(
ret
,
0
);
...
...
@@ -251,18 +260,18 @@ TEST(TdbOVFLPagesTest, TbDeleteTest) {
SPoolMem
*
pPool
=
openPool
();
// start a transaction
TXN
txn
;
TXN
txn
;
int64_t
txnid
=
0
;
++
txnid
;
tdbTxnOpen
(
&
txn
,
txnid
,
poolMalloc
,
poolFree
,
pPool
,
TDB_TXN_WRITE
|
TDB_TXN_READ_UNCOMMITTED
);
tdbBegin
(
pEnv
,
&
txn
);
// generate value payload
char
val
[((
4083
-
4
-
3
-
2
)
+
1
)
*
100
];
// pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4)
int
valLen
=
sizeof
(
val
)
/
sizeof
(
val
[
0
]);
char
val
[((
4083
-
4
-
3
-
2
)
+
1
)
*
100
];
// pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4)
int
valLen
=
sizeof
(
val
)
/
sizeof
(
val
[
0
]);
generateBigVal
(
val
,
valLen
);
{
// insert the generated big data
{
// insert the generated big data
ret
=
tdbTbInsert
(
pDb
,
"key1"
,
strlen
(
"key1"
),
val
,
valLen
,
&
txn
);
GTEST_ASSERT_EQ
(
ret
,
0
);
}
...
...
@@ -280,15 +289,15 @@ TEST(TdbOVFLPagesTest, TbDeleteTest) {
tdbFree
(
pVal
);
}
/* open to debug committed file
tdbCommit(pEnv, &txn);
tdbTxnClose(&txn);
++txnid;
tdbTxnOpen(&txn, txnid, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED);
tdbBegin(pEnv, &txn);
*/
{
// upsert the data
/* open to debug committed file
tdbCommit(pEnv, &txn);
tdbTxnClose(&txn);
++txnid;
tdbTxnOpen(&txn, txnid, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED);
tdbBegin(pEnv, &txn);
*/
{
// upsert the data
ret
=
tdbTbUpsert
(
pDb
,
"key1"
,
strlen
(
"key1"
),
"value1"
,
strlen
(
"value1"
),
&
txn
);
GTEST_ASSERT_EQ
(
ret
,
0
);
}
...
...
@@ -307,7 +316,7 @@ TEST(TdbOVFLPagesTest, TbDeleteTest) {
tdbFree
(
pVal
);
}
{
// delete the data
{
// delete the data
ret
=
tdbTbDelete
(
pDb
,
"key1"
,
strlen
(
"key1"
),
&
txn
);
GTEST_ASSERT_EQ
(
ret
,
0
);
}
...
...
@@ -332,7 +341,7 @@ TEST(TdbOVFLPagesTest, TbDeleteTest) {
}
TEST
(
tdb_test
,
DISABLED_simple_insert1
)
{
//
TEST(tdb_test, simple_insert1) {
//
TEST(tdb_test, simple_insert1) {
int
ret
;
TDB
*
pEnv
;
TTB
*
pDb
;
...
...
@@ -353,10 +362,10 @@ TEST(tdb_test, DISABLED_simple_insert1) {
GTEST_ASSERT_EQ
(
ret
,
0
);
{
char
key
[
64
];
//char val[(4083 - 4 - 3 - 2)]; // pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4)
char
val
[(
4083
-
4
-
3
-
2
)
+
1
];
// pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4)
int64_t
poolLimit
=
4096
;
// 1M pool limit
char
key
[
64
];
//
char val[(4083 - 4 - 3 - 2)]; // pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4)
char
val
[(
4083
-
4
-
3
-
2
)
+
1
];
// pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4)
int64_t
poolLimit
=
4096
;
// 1M pool limit
int64_t
txnid
=
0
;
SPoolMem
*
pPool
;
...
...
@@ -372,17 +381,17 @@ TEST(tdb_test, DISABLED_simple_insert1) {
sprintf
(
key
,
"key0"
);
sprintf
(
val
,
"value%d"
,
iData
);
//ret = tdbTbInsert(pDb, key, strlen(key), val, strlen(val), &txn);
//GTEST_ASSERT_EQ(ret, 0);
//
ret = tdbTbInsert(pDb, key, strlen(key), val, strlen(val), &txn);
//
GTEST_ASSERT_EQ(ret, 0);
// generate value payload
int
valLen
=
sizeof
(
val
)
/
sizeof
(
val
[
0
]);
for
(
int
i
=
6
;
i
<
valLen
;
++
i
)
{
char
c
=
char
(
i
&
0xff
);
if
(
c
==
0
)
{
c
=
1
;
}
val
[
i
]
=
c
;
char
c
=
char
(
i
&
0xff
);
if
(
c
==
0
)
{
c
=
1
;
}
val
[
i
]
=
c
;
}
ret
=
tdbTbInsert
(
pDb
,
"key1"
,
strlen
(
"key1"
),
val
,
valLen
,
&
txn
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录