From add314fa3831cc99b8d13e6ce00c9d7a9e2f78dc Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 7 Feb 2022 07:41:17 +0000 Subject: [PATCH] more --- source/libs/tdb/src/db/btree.c | 1 + source/libs/tdb/src/db/pgcache.c | 4 +++- source/libs/tdb/src/db/pgfile.c | 16 +++++++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/source/libs/tdb/src/db/btree.c b/source/libs/tdb/src/db/btree.c index e87a25c2c3..7d42484488 100644 --- a/source/libs/tdb/src/db/btree.c +++ b/source/libs/tdb/src/db/btree.c @@ -16,6 +16,7 @@ #include "tdbInt.h" struct SBTree { + pgno_t rootPage; // TODO }; diff --git a/source/libs/tdb/src/db/pgcache.c b/source/libs/tdb/src/db/pgcache.c index 88d932ba22..fb9385af98 100644 --- a/source/libs/tdb/src/db/pgcache.c +++ b/source/libs/tdb/src/db/pgcache.c @@ -123,7 +123,9 @@ int pgCacheClose(SPgCache *pPgCache) { } SPage *pgCacheFetch(SPgCache *pPgCache, pgid_t pgid) { - // TODO + SPage *pPage; + + // 1. Check if the page is cached return NULL; } diff --git a/source/libs/tdb/src/db/pgfile.c b/source/libs/tdb/src/db/pgfile.c index b98d10e6a6..15c18b2950 100644 --- a/source/libs/tdb/src/db/pgfile.c +++ b/source/libs/tdb/src/db/pgfile.c @@ -67,12 +67,22 @@ int pgFileClose(SPgFile *pPgFile) { } SPage *pgFileFetch(SPgFile *pPgFile, pgno_t pgno) { - // TODO - return NULL; + SPgCache *pPgCache; + SPage * pPage; + pgid_t pgid; + + pPgCache = pPgFile->pPgCache; + pPage = NULL; + memcpy(pgid.fileid, pPgFile->fileid, TDB_FILE_ID_LEN); + pgid.pgno = pgno; + + pPage = pgCacheFetch(pPgCache, pgid); + + return pPage; } int pgFileRelease(SPage *pPage) { - // TODO + pgCacheRelease(pPage); return 0; } -- GitLab