From 211b6ad47cf39fa9c73459cc6bafcff44e39634d Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 7 Feb 2022 07:07:27 +0000 Subject: [PATCH] more TDB --- source/libs/tdb/src/db/pgcache.c | 2 +- source/libs/tdb/src/db/pgfile.c | 28 +++++++++++++++++++++++++++- source/libs/tdb/src/inc/pgcache.h | 4 ++-- source/libs/tdb/src/inc/pgfile.h | 16 +++++++++++++--- 4 files changed, 43 insertions(+), 7 deletions(-) diff --git a/source/libs/tdb/src/db/pgcache.c b/source/libs/tdb/src/db/pgcache.c index 5e107c4930..88d932ba22 100644 --- a/source/libs/tdb/src/db/pgcache.c +++ b/source/libs/tdb/src/db/pgcache.c @@ -122,7 +122,7 @@ int pgCacheClose(SPgCache *pPgCache) { return 0; } -SPage *pgCacheFetch(SPgCache *pPgCache) { +SPage *pgCacheFetch(SPgCache *pPgCache, pgid_t pgid) { // TODO return NULL; } diff --git a/source/libs/tdb/src/db/pgfile.c b/source/libs/tdb/src/db/pgfile.c index 2ce1e62c16..1c017657c1 100644 --- a/source/libs/tdb/src/db/pgfile.c +++ b/source/libs/tdb/src/db/pgfile.c @@ -13,4 +13,30 @@ * along with this program. If not, see . */ -#include "tdbInt.h" \ No newline at end of file +#include "tdbInt.h" + +int pgFileOpen(const char *fname, SPgCache *pPgCache, SPgFile **ppPgFile) { + SPgFile *pPgFile; + // TODO + return 0; +} + +int pgFileClose(SPgFile *pPgFile) { + // TODO + return 0; +} + +SPage *pgFileFetch(SPgFile *pPgFile, pgno_t pgno) { + // TODO + return NULL; +} + +int pgFileRelease(SPage *pPage) { + // TODO + return 0; +} + +int pgFileWrite(SPage *pPage) { + // TODO + return 0; +} \ No newline at end of file diff --git a/source/libs/tdb/src/inc/pgcache.h b/source/libs/tdb/src/inc/pgcache.h index 5a88cf3072..139cece153 100644 --- a/source/libs/tdb/src/inc/pgcache.h +++ b/source/libs/tdb/src/inc/pgcache.h @@ -25,11 +25,11 @@ typedef struct SPage SPage; // SPgCache int pgCacheCreate(SPgCache **ppPgCache, pgsize_t pgSize, int32_t npage); +int pgCacheDestroy(SPgCache *pPgCache); int pgCacheOpen(SPgCache **ppPgCache); int pgCacheClose(SPgCache *pPgCache); -int pgCacheClose(SPgCache *pPgCache); -SPage *pgCacheFetch(SPgCache *pPgCache); +SPage *pgCacheFetch(SPgCache *pPgCache, pgid_t pgid); int pgCacheRelease(SPage *pPage); // SPage diff --git a/source/libs/tdb/src/inc/pgfile.h b/source/libs/tdb/src/inc/pgfile.h index 15196ef619..e951d59da0 100644 --- a/source/libs/tdb/src/inc/pgfile.h +++ b/source/libs/tdb/src/inc/pgfile.h @@ -21,12 +21,22 @@ extern "C" { #endif typedef struct SPgFile SPgFile; - struct SPgFile { - char * fname; // backend file name - SPgCache *pPgCache; // page cache underline + char * fname; // backend file name + uint8_t fileid[TDB_FILE_ID_LEN]; // file id + SPgCache *pPgCache; // page cache underline + int fd; + pgno_t pgFileSize; }; +int pgFileOpen(const char *fname, SPgCache *pPgCache, SPgFile **ppPgFile); +int pgFileClose(SPgFile *pPgFile); + +SPage *pgFileFetch(SPgFile *pPgFile, pgno_t pgno); +int pgFileRelease(SPage *pPage); + +int pgFileWrite(SPage *pPage); + #ifdef __cplusplus } #endif -- GitLab