Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f89b43b6
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看板
提交
f89b43b6
编写于
6月 30, 2023
作者:
M
Minglei Jin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tdb/ofp-recycle: new ofps list with pager
上级
8e491c30
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
32 addition
and
32 deletion
+32
-32
source/libs/tdb/src/db/tdbBtree.c
source/libs/tdb/src/db/tdbBtree.c
+29
-11
source/libs/tdb/src/db/tdbPager.c
source/libs/tdb/src/db/tdbPager.c
+2
-0
source/libs/tdb/src/inc/tdbInt.h
source/libs/tdb/src/inc/tdbInt.h
+1
-0
source/libs/tdb/test/tdbPageRecycleTest.cpp
source/libs/tdb/test/tdbPageRecycleTest.cpp
+0
-21
未找到文件。
source/libs/tdb/src/db/tdbBtree.c
浏览文件 @
f89b43b6
...
...
@@ -234,7 +234,9 @@ int tdbBtreeDelete(SBTree *pBt, const void *pKey, int kLen, TXN *pTxn) {
tdbBtcOpen
(
&
btc
,
pBt
,
pTxn
);
/*
btc.coder.ofps = taosArrayInit(8, sizeof(SPgno));
btc.coder.ofps = taosArrayInit(8, sizeof(SPage *));
// btc.coder.ofps = taosArrayInit(8, sizeof(SPgno));
//pBtc->coder.ofps = taosArrayInit(8, sizeof(SPage *));
*/
tdbTrace
(
"tdb delete, btc: %p, pTxn: %p"
,
&
btc
,
pTxn
);
...
...
@@ -256,7 +258,18 @@ int tdbBtreeDelete(SBTree *pBt, const void *pKey, int kLen, TXN *pTxn) {
tdbBtcClose
(
&
btc
);
return
-
1
;
}
/*
SArray *ofps = btc.coder.ofps;
if (ofps) {
for (int i = 0; i < TARRAY_SIZE(ofps); ++i) {
SPage *ofp = *(SPage **)taosArrayGet(ofps, i);
tdbPagerInsertFreePage(btc.pBt->pPager, ofp, btc.pTxn);
}
taosArrayDestroy(ofps);
btc.coder.ofps = NULL;
}
*/
tdbBtcClose
(
&
btc
);
return
0
;
}
...
...
@@ -1319,11 +1332,11 @@ static int tdbBtreeDecodePayload(SPage *pPage, const SCell *pCell, int nHeader,
if
(
ret
<
0
)
{
return
-
1
;
}
/*
if (pDecoder->ofps) {
taosArrayPush(pDecoder->ofps, &ofp);
}
*/
ofpCell
=
tdbPageGetCell
(
ofp
,
0
);
if
(
nLeft
<=
ofp
->
maxLocal
-
sizeof
(
SPgno
))
{
...
...
@@ -1363,11 +1376,11 @@ static int tdbBtreeDecodePayload(SPage *pPage, const SCell *pCell, int nHeader,
if
(
ret
<
0
)
{
return
-
1
;
}
/*
if (pDecoder->ofps) {
taosArrayPush(pDecoder->ofps, &ofp);
}
*/
ofpCell
=
tdbPageGetCell
(
ofp
,
0
);
int
lastKeyPage
=
0
;
...
...
@@ -1578,12 +1591,13 @@ static int tdbBtreeCellSize(const SPage *pPage, SCell *pCell, int dropOfp, TXN *
// SPgno origPgno = pgno;
memcpy
(
&
pgno
,
ofpCell
+
bytes
,
sizeof
(
pgno
));
/*
ret
=
tdbPagerWrite
(
pBt
->
pPager
,
ofp
);
if
(
ret
<
0
)
{
tdbError
(
"failed to write page since %s"
,
terrstr
());
return
-
1
;
}
/*
tdbPageDropCell(ofp, 0, pTxn, pBt);
*/
// SIntHdr *pIntHdr = (SIntHdr *)(ofp->pData);
...
...
@@ -1591,6 +1605,11 @@ static int tdbBtreeCellSize(const SPage *pPage, SCell *pCell, int dropOfp, TXN *
// pIntHdr->pgno = 0;
// ofp->pPager = NULL;
SArray
*
ofps
=
pPage
->
pPager
->
ofps
;
if
(
ofps
)
{
taosArrayPush
(
ofps
,
&
ofp
);
}
tdbPagerReturnPage
(
pPage
->
pPager
,
ofp
,
pTxn
);
nLeft
-=
bytes
;
...
...
@@ -2103,8 +2122,7 @@ int tdbBtcDelete(SBTC *pBtc) {
return
-
1
;
}
// btc.coder.ofps = taosArrayInit(8, sizeof(SPgno));
pBtc
->
coder
.
ofps
=
taosArrayInit
(
8
,
sizeof
(
SPage
*
));
pBtc
->
pPage
->
pPager
->
ofps
=
taosArrayInit
(
8
,
sizeof
(
SPage
*
));
tdbPageDropCell
(
pBtc
->
pPage
,
idx
,
pBtc
->
pTxn
,
pBtc
->
pBt
);
...
...
@@ -2161,15 +2179,15 @@ int tdbBtcDelete(SBTC *pBtc) {
}
}
SArray
*
ofps
=
pBtc
->
coder
.
ofps
;
SArray
*
ofps
=
pBtc
->
pPage
->
pPager
->
ofps
;
if
(
ofps
)
{
for
(
int
i
=
0
;
i
<
TARRAY_SIZE
(
ofps
);
++
i
)
{
SPage
*
ofp
=
*
(
SPage
**
)
taosArrayGet
(
ofps
,
i
);
// tdbPagerInsertFreePage(pBtc->pBt
->pPager, ofp, pBtc->pTxn);
tdbPagerInsertFreePage
(
pBtc
->
pPage
->
pPager
,
ofp
,
pBtc
->
pTxn
);
}
taosArrayDestroy
(
ofps
);
pBtc
->
coder
.
ofps
=
NULL
;
pBtc
->
pPage
->
pPager
->
ofps
=
NULL
;
}
return
0
;
...
...
source/libs/tdb/src/db/tdbPager.c
浏览文件 @
f89b43b6
...
...
@@ -722,6 +722,7 @@ int tdbPagerInsertFreePage(SPager *pPager, SPage *pPage, TXN *pTxn) {
// memset(pPage->pData, 0, pPage->pageSize);
tdbTrace
(
"tdb/insert-free-page: tbc recycle page: %d."
,
pgno
);
// printf("tdb/insert-free-page: tbc recycle page: %d.\n", pgno);
code
=
tdbTbInsert
(
pPager
->
pEnv
->
pFreeDb
,
&
pgno
,
sizeof
(
pgno
),
NULL
,
0
,
pTxn
);
if
(
code
<
0
)
{
tdbError
(
"tdb/insert-free-page: tb insert failed with ret: %d."
,
code
);
...
...
@@ -765,6 +766,7 @@ static int tdbPagerRemoveFreePage(SPager *pPager, SPgno *pPgno, TXN *pTxn) {
*
pPgno
=
*
(
SPgno
*
)
pKey
;
tdbTrace
(
"tdb/remove-free-page: tbc get page: %d."
,
*
pPgno
);
// printf("tdb/remove-free-page: tbc get page: %d.\n", *pPgno);
code
=
tdbTbcDelete
(
pCur
);
if
(
code
<
0
)
{
...
...
source/libs/tdb/src/inc/tdbInt.h
浏览文件 @
f89b43b6
...
...
@@ -407,6 +407,7 @@ struct SPager {
SRBTree
rbt
;
// u8 inTran;
TXN
*
pActiveTxn
;
SArray
*
ofps
;
SPager
*
pNext
;
// used by TDB
SPager
*
pHashNext
;
// used by TDB
#ifdef USE_MAINDB
...
...
source/libs/tdb/test/tdbPageRecycleTest.cpp
浏览文件 @
f89b43b6
...
...
@@ -730,15 +730,7 @@ TEST(TdbPageRecycleTest, recycly_seq_insert_ofp_nocommit) {
char
key
[
64
];
char
val
[(
4083
-
4
-
3
-
2
)
+
1
];
// pSize(4096) - amSize(1) - pageHdr(8) - footerSize(4)
int64_t
poolLimit
=
4096
;
// 1M pool limit
/*
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
=
0
;
iData
<
nData
;
++
iData
)
{
sprintf
(
key
,
"key%03d"
,
iData
);
sprintf
(
val
,
"value%03d"
,
iData
);
...
...
@@ -759,19 +751,6 @@ TEST(TdbPageRecycleTest, recycly_seq_insert_ofp_nocommit) {
}
}
/*
// generate value payload
// 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
// char const *key = "key1";
char const *key = "key123456789";
ret = tdbTbInsert(pDb, key, strlen(key) + 1, val, valLen, txn);
GTEST_ASSERT_EQ(ret, 0);
*/
// commit current transaction
tdbCommit
(
pEnv
,
txn
);
tdbPostCommit
(
pEnv
,
txn
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录