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

more TDB

上级 24fe6cb2
...@@ -14,16 +14,6 @@ ...@@ -14,16 +14,6 @@
*/ */
#include "tdbInt.h" #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; typedef TD_DLIST(SPage) SPgList;
struct SPgCache { struct SPgCache {
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
#include "tdbInt.h" #include "tdbInt.h"
static int pgFileRead(SPgFile *pPgFile, pgno_t pgno, uint8_t *pData);
int pgFileOpen(const char *fname, SPgCache *pPgCache, SPgFile **ppPgFile) { int pgFileOpen(const char *fname, SPgCache *pPgCache, SPgFile **ppPgFile) {
SPgFile *pPgFile; SPgFile *pPgFile;
...@@ -80,6 +82,14 @@ SPage *pgFileFetch(SPgFile *pPgFile, pgno_t pgno) { ...@@ -80,6 +82,14 @@ SPage *pgFileFetch(SPgFile *pPgFile, pgno_t pgno) {
// TODO // TODO
} else { } else {
pPage = pgCacheFetch(pPgCache, pgid); 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; return pPage;
...@@ -94,3 +104,8 @@ int pgFileWrite(SPage *pPage) { ...@@ -94,3 +104,8 @@ int pgFileWrite(SPage *pPage) {
// TODO // TODO
return 0; 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); ...@@ -34,6 +34,16 @@ int pgCacheRelease(SPage *pPage);
// SPage // 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 #ifdef __cplusplus
} }
#endif #endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册