Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1441684c
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看板
提交
1441684c
编写于
11月 17, 2022
作者:
M
Minglei Jin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cleanup: remove unused pager open
上级
a186cc44
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
16 addition
and
66 deletion
+16
-66
source/libs/tdb/src/db/tdbPager.c
source/libs/tdb/src/db/tdbPager.c
+16
-66
未找到文件。
source/libs/tdb/src/db/tdbPager.c
浏览文件 @
1441684c
...
...
@@ -28,12 +28,12 @@ typedef struct {
TDB_STATIC_ASSERT
(
sizeof
(
SFileHdr
)
==
128
,
"Size of file header is not correct"
);
struct
hashset_st
{
size_t
nbits
;
size_t
mask
;
size_t
capacity
;
size_t
nbits
;
size_t
mask
;
size_t
capacity
;
size_t
*
items
;
size_t
nitems
;
double
load_factor
;
size_t
nitems
;
double
load_factor
;
};
static
const
unsigned
int
prime
=
39
;
...
...
@@ -68,11 +68,11 @@ void hashset_destroy(hashset_t set) {
}
int
hashset_add_member
(
hashset_t
set
,
void
*
item
)
{
size_t
value
=
(
size_t
)
item
;
size_t
value
=
(
size_t
)
item
;
size_t
h
;
if
(
value
==
0
)
{
return
-
1
;
return
-
1
;
}
for
(
h
=
set
->
mask
&
(
prime
*
value
);
set
->
items
[
h
]
!=
0
;
h
=
set
->
mask
&
(
h
+
prime2
))
{
...
...
@@ -103,7 +103,7 @@ int hashset_add(hashset_t set, void *item) {
set
->
nitems
=
0
;
for
(
size_t
i
=
0
;
i
<
old_capacity
;
++
i
)
{
hashset_add_member
(
set
,
(
void
*
)
old_items
[
i
]);
hashset_add_member
(
set
,
(
void
*
)
old_items
[
i
]);
}
tdbOsFree
(
old_items
);
}
...
...
@@ -112,7 +112,7 @@ int hashset_add(hashset_t set, void *item) {
}
int
hashset_remove
(
hashset_t
set
,
void
*
item
)
{
size_t
value
=
(
size_t
)
item
;
size_t
value
=
(
size_t
)
item
;
for
(
size_t
h
=
set
->
mask
&
(
prime
*
value
);
set
->
items
[
h
]
!=
0
;
h
=
set
->
mask
&
(
h
+
prime2
))
{
if
(
set
->
items
[
h
]
==
value
)
{
...
...
@@ -126,7 +126,7 @@ int hashset_remove(hashset_t set, void *item) {
}
int
hashset_contains
(
hashset_t
set
,
void
*
item
)
{
size_t
value
=
(
size_t
)
item
;
size_t
value
=
(
size_t
)
item
;
for
(
size_t
h
=
set
->
mask
&
(
prime
*
value
);
set
->
items
[
h
]
!=
0
;
h
=
set
->
mask
&
(
h
+
prime2
))
{
if
(
set
->
items
[
h
]
==
value
)
{
...
...
@@ -226,58 +226,7 @@ int tdbPagerClose(SPager *pPager) {
}
return
0
;
}
/*
int tdbPagerOpenDB(SPager *pPager, SPgno *ppgno, bool toCreate, SBTree *pBt) {
SPgno pgno;
SPage *pPage;
int ret;
if (pPager->dbOrigSize > 0) {
pgno = 1;
} else {
pgno = 0;
}
{
// TODO: try to search the main DB to get the page number
// pgno = 0;
}
if (pgno == 0 && toCreate) {
// allocate a new child page
TXN txn;
tdbTxnOpen(&txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, 0);
pPager->inTran = 1;
SBtreeInitPageArg zArg;
zArg.flags = 0x1 | 0x2; // root leaf node;
zArg.pBt = pBt;
ret = tdbPagerFetchPage(pPager, &pgno, &pPage, tdbBtreeInitPage, &zArg, &txn);
if (ret < 0) {
return -1;
}
// ret = tdbPagerAllocPage(pPager, &pPage, &pgno);
// if (ret < 0) {
// return -1;
//}
// TODO: Need to zero the page
ret = tdbPagerWrite(pPager, pPage);
if (ret < 0) {
tdbError("failed to write page since %s", terrstr());
return -1;
}
tdbTxnClose(&txn);
}
*ppgno = pgno;
return 0;
}
*/
int
tdbPagerWrite
(
SPager
*
pPager
,
SPage
*
pPage
)
{
int
ret
;
SPage
**
ppPage
;
...
...
@@ -319,7 +268,8 @@ int tdbPagerWrite(SPager *pPager, SPage *pPage) {
tRBTreePut
(
&
pPager
->
rbt
,
(
SRBTreeNode
*
)
pPage
);
// Write page to journal if neccessary
if
(
TDB_PAGE_PGNO
(
pPage
)
<=
pPager
->
dbOrigSize
&&
(
pPager
->
jPageSet
==
NULL
||
!
hashset_contains
(
pPager
->
jPageSet
,
(
void
*
)((
long
)
TDB_PAGE_PGNO
(
pPage
)))))
{
if
(
TDB_PAGE_PGNO
(
pPage
)
<=
pPager
->
dbOrigSize
&&
(
pPager
->
jPageSet
==
NULL
||
!
hashset_contains
(
pPager
->
jPageSet
,
(
void
*
)((
long
)
TDB_PAGE_PGNO
(
pPage
)))))
{
ret
=
tdbPagerWritePageToJournal
(
pPager
,
pPage
);
if
(
ret
<
0
)
{
tdbError
(
"failed to write page to journal since %s"
,
tstrerror
(
terrno
));
...
...
@@ -327,7 +277,7 @@ int tdbPagerWrite(SPager *pPager, SPage *pPage) {
}
if
(
pPager
->
jPageSet
)
{
hashset_add
(
pPager
->
jPageSet
,
(
void
*
)((
long
)
TDB_PAGE_PGNO
(
pPage
)));
hashset_add
(
pPager
->
jPageSet
,
(
void
*
)((
long
)
TDB_PAGE_PGNO
(
pPage
)));
}
}
...
...
@@ -391,7 +341,7 @@ int tdbPagerCommit(SPager *pPager, TXN *pTxn) {
tRBTreeDrop
(
&
pPager
->
rbt
,
(
SRBTreeNode
*
)
pPage
);
if
(
pPager
->
jPageSet
)
{
hashset_remove
(
pPager
->
jPageSet
,
(
void
*
)((
long
)
TDB_PAGE_PGNO
(
pPage
)));
hashset_remove
(
pPager
->
jPageSet
,
(
void
*
)((
long
)
TDB_PAGE_PGNO
(
pPage
)));
}
tdbPCacheRelease
(
pPager
->
pCache
,
pPage
,
pTxn
);
}
...
...
@@ -503,7 +453,7 @@ int tdbPagerAbort(SPager *pPager, TXN *pTxn) {
return
-
1
;
}
u8
*
pageBuf
=
tdbOsCalloc
(
1
,
pPager
->
pageSize
);
u8
*
pageBuf
=
tdbOsCalloc
(
1
,
pPager
->
pageSize
);
if
(
pageBuf
==
NULL
)
{
return
-
1
;
}
...
...
@@ -560,7 +510,7 @@ int tdbPagerAbort(SPager *pPager, TXN *pTxn) {
pPage
->
isDirty
=
0
;
tRBTreeDrop
(
&
pPager
->
rbt
,
(
SRBTreeNode
*
)
pPage
);
hashset_remove
(
pPager
->
jPageSet
,
(
void
*
)((
long
)
TDB_PAGE_PGNO
(
pPage
)));
hashset_remove
(
pPager
->
jPageSet
,
(
void
*
)((
long
)
TDB_PAGE_PGNO
(
pPage
)));
tdbPCacheRelease
(
pPager
->
pCache
,
pPage
,
pTxn
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录