diff --git a/source/libs/tdb/src/db/btree.c b/source/libs/tdb/src/db/btree.c index e87a25c2c34ceaa78d0feb2fc1ec9eb8b31cd74d..7d42484488cc5cbb5a89bb0c86468ac25ff22455 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 88d932ba22121e153f2ba9a365e3dd9025752d7e..fb9385af989aa8ef875fd6ef774905b961160b84 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 b98d10e6a6df1a30fc8a2d28eed76ccf67fe456d..15c18b2950c078f33459489d7d8243782a60ce8f 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; }