From ccef4b0f63a94f5c2314b4ddc7981139a09d419d Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 2 Mar 2022 08:36:19 +0000 Subject: [PATCH] more --- source/libs/tdb/src/db/tdbPCache.c | 3 +-- source/libs/tdb/src/db/tdbPager.c | 19 ++----------------- source/libs/tdb/src/inc/tdbInt.h | 4 ---- source/libs/tdb/src/inc/tdbPCache.h | 2 +- 4 files changed, 4 insertions(+), 24 deletions(-) diff --git a/source/libs/tdb/src/db/tdbPCache.c b/source/libs/tdb/src/db/tdbPCache.c index 0d5822f308..c18d43e278 100644 --- a/source/libs/tdb/src/db/tdbPCache.c +++ b/source/libs/tdb/src/db/tdbPCache.c @@ -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); } diff --git a/source/libs/tdb/src/db/tdbPager.c b/source/libs/tdb/src/db/tdbPager.c index 2c5601a14b..f023b08605 100644 --- a/source/libs/tdb/src/db/tdbPager.c +++ b/source/libs/tdb/src/db/tdbPager.c @@ -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; } diff --git a/source/libs/tdb/src/inc/tdbInt.h b/source/libs/tdb/src/inc/tdbInt.h index e94479366f..bf43632815 100644 --- a/source/libs/tdb/src/inc/tdbInt.h +++ b/source/libs/tdb/src/inc/tdbInt.h @@ -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" diff --git a/source/libs/tdb/src/inc/tdbPCache.h b/source/libs/tdb/src/inc/tdbPCache.h index 7d9153b94a..2412cb1bd0 100644 --- a/source/libs/tdb/src/inc/tdbPCache.h +++ b/source/libs/tdb/src/inc/tdbPCache.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); -- GitLab