more
This commit is contained in:
parent
a95d66907a
commit
ccef4b0f63
|
@ -119,7 +119,6 @@ static SPage *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, bool alcNe
|
|||
|
||||
if (pPage || !alcNewPage) {
|
||||
if (pPage) {
|
||||
ASSERT(pPage->isLoad == 1);
|
||||
tdbPCachePinPage(pPage);
|
||||
}
|
||||
return pPage;
|
||||
|
@ -148,7 +147,7 @@ static SPage *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, bool alcNe
|
|||
if (pPage) {
|
||||
memcpy(&(pPage->pgid), pPgid, sizeof(*pPgid));
|
||||
pPage->pLruNext = NULL;
|
||||
pPage->isLoad = 0;
|
||||
pPage->pPager = NULL;
|
||||
tdbPCacheAddPageToHash(pPage);
|
||||
}
|
||||
|
||||
|
|
|
@ -133,26 +133,11 @@ SPage *tdbPagerGet(SPager *pPager, SPgno pgno) {
|
|||
|
||||
pPage = tdbPCacheFetch(pPager->pCache, &pgid, 1);
|
||||
if (pPage == NULL) {
|
||||
// TODO
|
||||
ASSERT(0);
|
||||
// TODO: handle error
|
||||
return NULL;
|
||||
}
|
||||
tdbPCacheFetchFinish(pPager->pCache, pPage);
|
||||
|
||||
if (!(pPage->isLoad)) {
|
||||
if (pgno > pPager->dbFileSize /*TODO*/) {
|
||||
memset(pPage->pData, 0, pPager->pageSize);
|
||||
} else {
|
||||
if (tdbPagerReadPage(pPager, pPage) < 0) {
|
||||
// TODO: handle error
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
pPage->isLoad = 1;
|
||||
}
|
||||
|
||||
ASSERT(pPage->isLoad);
|
||||
|
||||
return pPage;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,9 +70,6 @@ static FORCE_INLINE int tdbCmprPgId(const void *p1, const void *p2) {
|
|||
|
||||
#define TDB_IS_SAME_PAGE(pPgid1, pPgid2) (tdbCmprPgId(pPgid1, pPgid2) == 0)
|
||||
|
||||
// framd_id_t
|
||||
typedef int32_t frame_id_t;
|
||||
|
||||
// pgsz_t
|
||||
#define TDB_MIN_PGSIZE 512
|
||||
#define TDB_MAX_PGSIZE 65536
|
||||
|
@ -131,7 +128,6 @@ typedef int (*FKeyComparator)(const void *pKey1, int kLen1, const void *pKey2, i
|
|||
|
||||
#define BTREE_MAX_DEPTH 20
|
||||
|
||||
|
||||
#include "tdbUtil.h"
|
||||
|
||||
#include "tdbPage.h"
|
||||
|
|
|
@ -29,7 +29,6 @@ struct SPage {
|
|||
SPgid pgid;
|
||||
u8 isAnchor;
|
||||
u8 isLocalPage;
|
||||
u8 isLoad;
|
||||
u8 isDirty;
|
||||
i32 nRef;
|
||||
SPCache *pCache;
|
||||
|
@ -38,6 +37,7 @@ struct SPage {
|
|||
SPage * pLruNext;
|
||||
SPage * pLruPrev;
|
||||
SPage * pDirtyNext;
|
||||
SPage * pPager;
|
||||
};
|
||||
|
||||
int tdbPCacheOpen(int pageSize, int cacheSize, int extraSize, SPCache **ppCache);
|
||||
|
|
Loading…
Reference in New Issue