Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
204999d5
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看板
提交
204999d5
编写于
6月 26, 2023
作者:
M
Minglei Jin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tdb/test: refactor page recycling test cases
上级
fe197ccf
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
15 addition
and
79 deletion
+15
-79
source/libs/tdb/src/db/tdbBtree.c
source/libs/tdb/src/db/tdbBtree.c
+2
-6
source/libs/tdb/test/tdbPageRecycleTest.cpp
source/libs/tdb/test/tdbPageRecycleTest.cpp
+13
-73
未找到文件。
source/libs/tdb/src/db/tdbBtree.c
浏览文件 @
204999d5
...
...
@@ -860,10 +860,9 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
if
(
!
TDB_BTREE_PAGE_IS_LEAF
(
pNews
[
0
]))
{
((
SIntHdr
*
)(
pParent
->
pData
))
->
pgno
=
((
SIntHdr
*
)(
pNews
[
0
]
->
pData
))
->
pgno
;
}
// else {
// printf("tdb/balance: btree balance delete pgno: %d.\n", TDB_PAGE_PGNO(pNews[0]));
}
tdbPagerInsertFreePage
(
pBt
->
pPager
,
TDB_PAGE_PGNO
(
pNews
[
0
]),
pTxn
);
//}
}
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
...
...
@@ -873,15 +872,12 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
}
for
(
pageIdx
=
0
;
pageIdx
<
nOlds
;
++
pageIdx
)
{
// printf("tdb/balance: btree balance old pgno: %d.\n", TDB_PAGE_PGNO(pOlds[pageIdx]));
if
(
pageIdx
>=
nNews
)
{
// printf("tdb/balance: btree balance delete pgno: %d.\n", TDB_PAGE_PGNO(pOlds[pageIdx]));
tdbPagerInsertFreePage
(
pBt
->
pPager
,
TDB_PAGE_PGNO
(
pOlds
[
pageIdx
]),
pTxn
);
}
tdbPagerReturnPage
(
pBt
->
pPager
,
pOlds
[
pageIdx
],
pTxn
);
}
for
(;
pageIdx
<
nNews
;
++
pageIdx
)
{
// printf("tdb/balance: btree balance new pgno: %d.\n", TDB_PAGE_PGNO(pNews[pageIdx]));
tdbPagerReturnPage
(
pBt
->
pPager
,
pNews
[
pageIdx
],
pTxn
);
}
...
...
source/libs/tdb/test/tdbPageRecycleTest.cpp
浏览文件 @
204999d5
...
...
@@ -464,31 +464,25 @@ TEST(TdbPageRecycleTest, DISABLED_simple_insert1) {
GTEST_ASSERT_EQ
(
ret
,
0
);
}
static
const
int
nDataConst
=
256
*
19
;
static
void
clearDb
(
char
const
*
db
)
{
taosRemoveDir
(
db
);
}
// TEST(TdbPageRecycleTest, DISABLED_seq_insert) {
TEST
(
TdbPageRecycleTest
,
seq_insert
)
{
static
void
insertDb
(
int
nData
)
{
int
ret
=
0
;
TDB
*
pEnv
=
NULL
;
TTB
*
pDb
=
NULL
;
tdb_cmpr_fn_t
compFunc
;
int
nData
=
nDataConst
;
TXN
*
txn
=
NULL
;
int
const
pageSize
=
4
*
1024
;
taosRemoveDir
(
"tdb"
);
// Open Env
ret
=
tdbOpen
(
"tdb"
,
pageSize
,
64
,
&
pEnv
,
0
);
GTEST_ASSERT_EQ
(
ret
,
0
);
printf
(
"tdb opened
\n
"
);
// Create a database
compFunc
=
tKeyCmpr
;
ret
=
tdbTbOpen
(
"db.db"
,
-
1
,
-
1
,
compFunc
,
pEnv
,
&
pDb
,
0
);
GTEST_ASSERT_EQ
(
ret
,
0
);
printf
(
"tb opened
\n
"
);
// 1, insert nData kv
{
char
key
[
64
];
...
...
@@ -540,13 +534,11 @@ TEST(TdbPageRecycleTest, seq_insert) {
system
(
"ls -l ./tdb"
);
}
// TEST(TdbPageRecycleTest, DISABLED_seq_delete) {
TEST
(
TdbPageRecycleTest
,
seq_delete
)
{
static
void
deleteDb
(
int
nData
)
{
int
ret
=
0
;
TDB
*
pEnv
=
NULL
;
TTB
*
pDb
=
NULL
;
tdb_cmpr_fn_t
compFunc
;
int
nData
=
nDataConst
;
TXN
*
txn
=
NULL
;
int
const
pageSize
=
4
*
1024
;
...
...
@@ -612,68 +604,16 @@ TEST(TdbPageRecycleTest, seq_delete) {
system
(
"ls -l ./tdb"
);
}
// TEST(TdbPageRecycleTest, DISABLED_recycly_insert) {
TEST
(
TdbPageRecycleTest
,
recycly_insert
)
{
int
ret
=
0
;
TDB
*
pEnv
=
NULL
;
TTB
*
pDb
=
NULL
;
tdb_cmpr_fn_t
compFunc
=
tKeyCmpr
;
int
nData
=
nDataConst
;
TXN
*
txn
=
NULL
;
int
const
pageSize
=
4
*
1024
;
// Open Env
ret
=
tdbOpen
(
"tdb"
,
pageSize
,
64
,
&
pEnv
,
0
);
GTEST_ASSERT_EQ
(
ret
,
0
);
// Create a database
ret
=
tdbTbOpen
(
"db.db"
,
-
1
,
-
1
,
compFunc
,
pEnv
,
&
pDb
,
0
);
GTEST_ASSERT_EQ
(
ret
,
0
);
// 3, insert 32k records
{
char
key
[
64
];
char
val
[(
4083
-
4
-
3
-
2
)
+
1
];
// pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4)
int64_t
poolLimit
=
4096
;
SPoolMem
*
pPool
;
// open the pool
pPool
=
openPool
();
// start a transaction
tdbBegin
(
pEnv
,
&
txn
,
poolMalloc
,
poolFree
,
pPool
,
TDB_TXN_WRITE
|
TDB_TXN_READ_UNCOMMITTED
);
// for (int iData = nData; iData < nData + nData; iData++) {
for
(
int
iData
=
0
;
iData
<
nData
;
iData
++
)
{
sprintf
(
key
,
"key%03d"
,
iData
);
sprintf
(
val
,
"value%03d"
,
iData
);
ret
=
tdbTbInsert
(
pDb
,
key
,
strlen
(
key
),
val
,
strlen
(
val
),
txn
);
GTEST_ASSERT_EQ
(
ret
,
0
);
if
(
pPool
->
size
>=
poolLimit
)
{
tdbCommit
(
pEnv
,
txn
);
tdbPostCommit
(
pEnv
,
txn
);
// start a new transaction
clearPool
(
pPool
);
tdbBegin
(
pEnv
,
&
txn
,
poolMalloc
,
poolFree
,
pPool
,
TDB_TXN_WRITE
|
TDB_TXN_READ_UNCOMMITTED
);
}
}
tdbCommit
(
pEnv
,
txn
);
tdbPostCommit
(
pEnv
,
txn
);
closePool
(
pPool
);
}
static
const
int
nDataConst
=
256
*
19
;
// Close a database
tdbTbClose
(
pDb
);
// TEST(TdbPageRecycleTest, DISABLED_seq_insert) {
TEST
(
TdbPageRecycleTest
,
seq_insert
)
{
clearDb
(
"tdb"
);
insertDb
(
nDataConst
);
}
// Close Env
ret
=
tdbClose
(
pEnv
);
GTEST_ASSERT_EQ
(
ret
,
0
);
// TEST(TdbPageRecycleTest, DISABLED_seq_delete) {
TEST
(
TdbPageRecycleTest
,
seq_delete
)
{
deleteDb
(
nDataConst
);
}
system
(
"ls -l ./tdb"
);
}
// TEST(TdbPageRecycleTest, DISABLED_recycly_insert) {
TEST
(
TdbPageRecycleTest
,
recycly_insert
)
{
insertDb
(
nDataConst
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录