From cc893cf96d259b6b98efdef21f8f3b75b1920df9 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 15 Feb 2022 06:24:58 +0000 Subject: [PATCH] more TDB --- source/libs/tdb/src/db/tdbEnv.c | 11 +++++++++-- source/libs/tdb/src/db/tdbPgCache.c | 15 --------------- source/libs/tdb/src/inc/tdbPgCache.h | 2 -- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/source/libs/tdb/src/db/tdbEnv.c b/source/libs/tdb/src/db/tdbEnv.c index 0f1002c4d1..4057bd86e6 100644 --- a/source/libs/tdb/src/db/tdbEnv.c +++ b/source/libs/tdb/src/db/tdbEnv.c @@ -63,8 +63,15 @@ int tdbEnvOpen(TENV *pEnv) { ASSERT(pEnv != NULL); - TERR_A(ret, pgCacheCreate(&pPgCache, pEnv->pgSize, pEnv->cacheSize / pEnv->pgSize), _err); - TERR_A(ret, pgCacheOpen(&pPgCache), _err); + /* TODO: here we do not need to create the root directory, more + * work should be done here + */ + mkdir(pEnv->rootDir, 0755); + + ret = pgCacheCreate(&pPgCache, pEnv->pgSize, pEnv->cacheSize / pEnv->pgSize); + if (ret != 0) { + goto _err; + } pEnv->pPgCache = pPgCache; diff --git a/source/libs/tdb/src/db/tdbPgCache.c b/source/libs/tdb/src/db/tdbPgCache.c index 3d0d770f38..466a9b2eaf 100644 --- a/source/libs/tdb/src/db/tdbPgCache.c +++ b/source/libs/tdb/src/db/tdbPgCache.c @@ -88,21 +88,6 @@ int pgCacheDestroy(SPgCache *pPgCache) { return 0; } -int pgCacheOpen(SPgCache **ppPgCache) { - if (*ppPgCache == NULL) { - if (pgCacheCreate(ppPgCache, TDB_DEFAULT_PGSIZE, TDB_DEFAULT_CACHE_SIZE / TDB_DEFAULT_PGSIZE) < 0) { - return -1; - } - } - // TODO - return 0; -} - -int pgCacheClose(SPgCache *pPgCache) { - // TODO - return 0; -} - #define PG_CACHE_HASH(fileid, pgno) \ ({ \ uint64_t *tmp = (uint64_t *)(fileid); \ diff --git a/source/libs/tdb/src/inc/tdbPgCache.h b/source/libs/tdb/src/inc/tdbPgCache.h index 4cea86dc6d..de9e254a92 100644 --- a/source/libs/tdb/src/inc/tdbPgCache.h +++ b/source/libs/tdb/src/inc/tdbPgCache.h @@ -26,8 +26,6 @@ typedef struct SPage SPage; // SPgCache int pgCacheCreate(SPgCache **ppPgCache, pgsz_t pgSize, int32_t npage); int pgCacheDestroy(SPgCache *pPgCache); -int pgCacheOpen(SPgCache **ppPgCache); -int pgCacheClose(SPgCache *pPgCache); SPage *pgCacheFetch(SPgCache *pPgCache, pgid_t pgid); int pgCacheRelease(SPage *pPage); -- GitLab