Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9dea8624
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看板
提交
9dea8624
编写于
4月 02, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact
上级
08ed99b0
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
11 addition
and
18 deletion
+11
-18
source/libs/tdb/src/db/tdbPCache.c
source/libs/tdb/src/db/tdbPCache.c
+8
-15
source/libs/tdb/src/db/tdbPager.c
source/libs/tdb/src/db/tdbPager.c
+2
-2
source/libs/tdb/src/inc/tdbPCache.h
source/libs/tdb/src/inc/tdbPCache.h
+1
-1
未找到文件。
source/libs/tdb/src/db/tdbPCache.c
浏览文件 @
9dea8624
...
@@ -36,7 +36,7 @@ struct SPCache {
...
@@ -36,7 +36,7 @@ struct SPCache {
#define PAGE_IS_PINNED(pPage) ((pPage)->pLruNext == NULL)
#define PAGE_IS_PINNED(pPage) ((pPage)->pLruNext == NULL)
static
int
tdbPCacheOpenImpl
(
SPCache
*
pCache
);
static
int
tdbPCacheOpenImpl
(
SPCache
*
pCache
);
static
SPage
*
tdbPCacheFetchImpl
(
SPCache
*
pCache
,
const
SPgid
*
pPgid
,
bool
alcNewPage
);
static
SPage
*
tdbPCacheFetchImpl
(
SPCache
*
pCache
,
const
SPgid
*
pPgid
);
static
void
tdbPCachePinPage
(
SPCache
*
pCache
,
SPage
*
pPage
);
static
void
tdbPCachePinPage
(
SPCache
*
pCache
,
SPage
*
pPage
);
static
void
tdbPCacheRemovePageFromHash
(
SPCache
*
pCache
,
SPage
*
pPage
);
static
void
tdbPCacheRemovePageFromHash
(
SPCache
*
pCache
,
SPage
*
pPage
);
static
void
tdbPCacheAddPageToHash
(
SPCache
*
pCache
,
SPage
*
pPage
);
static
void
tdbPCacheAddPageToHash
(
SPCache
*
pCache
,
SPage
*
pPage
);
...
@@ -78,12 +78,12 @@ int tdbPCacheClose(SPCache *pCache) {
...
@@ -78,12 +78,12 @@ int tdbPCacheClose(SPCache *pCache) {
return
0
;
return
0
;
}
}
SPage
*
tdbPCacheFetch
(
SPCache
*
pCache
,
const
SPgid
*
pPgid
,
bool
alcNewPage
)
{
SPage
*
tdbPCacheFetch
(
SPCache
*
pCache
,
const
SPgid
*
pPgid
)
{
SPage
*
pPage
;
SPage
*
pPage
;
tdbPCacheLock
(
pCache
);
tdbPCacheLock
(
pCache
);
pPage
=
tdbPCacheFetchImpl
(
pCache
,
pPgid
,
alcNewPage
);
pPage
=
tdbPCacheFetchImpl
(
pCache
,
pPgid
);
if
(
pPage
)
{
if
(
pPage
)
{
TDB_REF_PAGE
(
pPage
);
TDB_REF_PAGE
(
pPage
);
}
}
...
@@ -106,7 +106,7 @@ void tdbPCacheRelease(SPCache *pCache, SPage *pPage) {
...
@@ -106,7 +106,7 @@ void tdbPCacheRelease(SPCache *pCache, SPage *pPage) {
int
tdbPCacheGetPageSize
(
SPCache
*
pCache
)
{
return
pCache
->
pageSize
;
}
int
tdbPCacheGetPageSize
(
SPCache
*
pCache
)
{
return
pCache
->
pageSize
;
}
static
SPage
*
tdbPCacheFetchImpl
(
SPCache
*
pCache
,
const
SPgid
*
pPgid
,
bool
alcNewPage
)
{
static
SPage
*
tdbPCacheFetchImpl
(
SPCache
*
pCache
,
const
SPgid
*
pPgid
)
{
SPage
*
pPage
;
SPage
*
pPage
;
// 1. Search the hash table
// 1. Search the hash table
...
@@ -116,12 +116,10 @@ static SPage *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, bool alcNe
...
@@ -116,12 +116,10 @@ static SPage *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, bool alcNe
pPage
=
pPage
->
pHashNext
;
pPage
=
pPage
->
pHashNext
;
}
}
if
(
pPage
||
!
alcNewPage
)
{
if
(
pPage
)
{
if
(
pPage
)
{
tdbPCachePinPage
(
pCache
,
pPage
);
tdbPCachePinPage
(
pCache
,
pPage
);
}
}
return
pPage
;
return
pPage
;
}
// 2. Try to allocate a new page from the free list
// 2. Try to allocate a new page from the free list
if
(
pCache
->
pFree
)
{
if
(
pCache
->
pFree
)
{
...
@@ -261,17 +259,12 @@ static int tdbPCacheOpenImpl(SPCache *pCache) {
...
@@ -261,17 +259,12 @@ static int tdbPCacheOpenImpl(SPCache *pCache) {
return
0
;
return
0
;
}
}
static
int
tdbPCacheDestroyPage
(
SPage
*
pPage
)
{
// TODO
return
0
;
}
static
int
tdbPCacheCloseImpl
(
SPCache
*
pCache
)
{
static
int
tdbPCacheCloseImpl
(
SPCache
*
pCache
)
{
SPage
*
pPage
;
SPage
*
pPage
;
for
(
pPage
=
pCache
->
pList
;
pPage
;
pPage
=
pCache
->
pList
)
{
for
(
pPage
=
pCache
->
pList
;
pPage
;
pPage
=
pCache
->
pList
)
{
pCache
->
pList
=
pPage
->
pCacheNext
;
pCache
->
pList
=
pPage
->
pCacheNext
;
tdbP
CacheDestroyPage
(
pPage
);
tdbP
ageDestroy
(
pPage
,
NULL
,
NULL
);
}
}
tdbPCacheDestroyLock
(
pCache
);
tdbPCacheDestroyLock
(
pCache
);
...
...
source/libs/tdb/src/db/tdbPager.c
浏览文件 @
9dea8624
...
@@ -227,7 +227,7 @@ int tdbPagerFetchPage(SPager *pPager, SPgno pgno, SPage **ppPage, int (*initPage
...
@@ -227,7 +227,7 @@ int tdbPagerFetchPage(SPager *pPager, SPgno pgno, SPage **ppPage, int (*initPage
// Fetch a page container from the page cache
// Fetch a page container from the page cache
memcpy
(
&
pgid
,
pPager
->
fid
,
TDB_FILE_ID_LEN
);
memcpy
(
&
pgid
,
pPager
->
fid
,
TDB_FILE_ID_LEN
);
pgid
.
pgno
=
pgno
;
pgid
.
pgno
=
pgno
;
pPage
=
tdbPCacheFetch
(
pPager
->
pCache
,
&
pgid
,
1
);
pPage
=
tdbPCacheFetch
(
pPager
->
pCache
,
&
pgid
);
if
(
pPage
==
NULL
)
{
if
(
pPage
==
NULL
)
{
return
-
1
;
return
-
1
;
}
}
...
@@ -263,7 +263,7 @@ int tdbPagerNewPage(SPager *pPager, SPgno *ppgno, SPage **ppPage, int (*initPage
...
@@ -263,7 +263,7 @@ int tdbPagerNewPage(SPager *pPager, SPgno *ppgno, SPage **ppPage, int (*initPage
// Fetch a page container from the page cache
// Fetch a page container from the page cache
memcpy
(
&
pgid
,
pPager
->
fid
,
TDB_FILE_ID_LEN
);
memcpy
(
&
pgid
,
pPager
->
fid
,
TDB_FILE_ID_LEN
);
pgid
.
pgno
=
*
ppgno
;
pgid
.
pgno
=
*
ppgno
;
pPage
=
tdbPCacheFetch
(
pPager
->
pCache
,
&
pgid
,
1
);
pPage
=
tdbPCacheFetch
(
pPager
->
pCache
,
&
pgid
);
if
(
pPage
==
NULL
)
{
if
(
pPage
==
NULL
)
{
return
-
1
;
return
-
1
;
}
}
...
...
source/libs/tdb/src/inc/tdbPCache.h
浏览文件 @
9dea8624
...
@@ -48,7 +48,7 @@ extern "C" {
...
@@ -48,7 +48,7 @@ extern "C" {
int
tdbPCacheOpen
(
int
pageSize
,
int
cacheSize
,
SPCache
**
ppCache
);
int
tdbPCacheOpen
(
int
pageSize
,
int
cacheSize
,
SPCache
**
ppCache
);
int
tdbPCacheClose
(
SPCache
*
pCache
);
int
tdbPCacheClose
(
SPCache
*
pCache
);
SPage
*
tdbPCacheFetch
(
SPCache
*
pCache
,
const
SPgid
*
pPgid
,
bool
alcNewPage
);
SPage
*
tdbPCacheFetch
(
SPCache
*
pCache
,
const
SPgid
*
pPgid
);
void
tdbPCacheRelease
(
SPCache
*
pCache
,
SPage
*
pPage
);
void
tdbPCacheRelease
(
SPCache
*
pCache
,
SPage
*
pPage
);
int
tdbPCacheGetPageSize
(
SPCache
*
pCache
);
int
tdbPCacheGetPageSize
(
SPCache
*
pCache
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录