提交 a5834073 编写于 作者: H Hongze Cheng

more TDB

上级 24fe6cb2
......@@ -14,16 +14,6 @@
*/
#include "tdbInt.h"
typedef TD_DLIST_NODE(SPage) SPgListNode;
struct SPage {
pgid_t pgid; // page id
frame_id_t frameid; // frame id
SPgListNode freeNode; // for SPgCache.freeList
SPgListNode pghtNode; // for pght
SPgListNode lruNode; // for LRU
uint8_t * pData; // real data
};
typedef TD_DLIST(SPage) SPgList;
struct SPgCache {
......
......@@ -15,6 +15,8 @@
#include "tdbInt.h"
static int pgFileRead(SPgFile *pPgFile, pgno_t pgno, uint8_t *pData);
int pgFileOpen(const char *fname, SPgCache *pPgCache, SPgFile **ppPgFile) {
SPgFile *pPgFile;
......@@ -80,6 +82,14 @@ SPage *pgFileFetch(SPgFile *pPgFile, pgno_t pgno) {
// TODO
} else {
pPage = pgCacheFetch(pPgCache, pgid);
if (1 /*Page is cached, no need to load from file*/) {
return pPage;
} else {
if (pgFileRead(pPgFile, pgno, pPage->pData) < 0) {
// todoerr
}
return pPage;
}
}
return pPage;
......@@ -93,4 +103,9 @@ int pgFileRelease(SPage *pPage) {
int pgFileWrite(SPage *pPage) {
// TODO
return 0;
}
static int pgFileRead(SPgFile *pPgFile, pgno_t pgno, uint8_t *pData) {
// TODO
return 0;
}
\ No newline at end of file
......@@ -34,6 +34,16 @@ int pgCacheRelease(SPage *pPage);
// SPage
typedef TD_DLIST_NODE(SPage) SPgListNode;
struct SPage {
pgid_t pgid; // page id
frame_id_t frameid; // frame id
SPgListNode freeNode; // for SPgCache.freeList
SPgListNode pghtNode; // for pght
SPgListNode lruNode; // for LRU
uint8_t * pData; // real data
};
#ifdef __cplusplus
}
#endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册