From df0ab85f80dbac639bd32944311a1da005453936 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 23 Feb 2022 08:49:12 +0000 Subject: [PATCH] more TDB --- source/libs/tdb/src/db/tdbBtree.c | 8 +++++--- source/libs/tdb/src/db/tdbEnv.c | 6 ++++++ source/libs/tdb/src/inc/tdbBtree.h | 2 ++ source/libs/tdb/src/inc/tdbEnv.h | 14 +++++++------- source/libs/tdb/src/inc/tdbInt.h | 4 ++-- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/source/libs/tdb/src/db/tdbBtree.c b/source/libs/tdb/src/db/tdbBtree.c index d76155bbdf..d35d6a7abd 100644 --- a/source/libs/tdb/src/db/tdbBtree.c +++ b/source/libs/tdb/src/db/tdbBtree.c @@ -15,6 +15,7 @@ #include "tdbInt.h" +#if 0 struct SBtCursor { SBTree *pBtree; SPgno pgno; @@ -39,9 +40,9 @@ typedef struct __attribute__((__packed__)) { typedef int (*BtreeCmprFn)(const void *, const void *); -#define BTREE_PAGE_HDR(pPage) NULL /* TODO */ +#define BTREE_PAGE_HDR(pPage) NULL /* TODO */ #define BTREE_PAGE_PAYLOAD_AT(pPage, idx) NULL /*TODO*/ -#define BTREE_PAGE_IS_LEAF(pPage) 0 /* TODO */ +#define BTREE_PAGE_IS_LEAF(pPage) 0 /* TODO */ static int btreeCreate(SBTree **ppBt); static int btreeDestroy(SBTree *pBt); @@ -161,4 +162,5 @@ static int btreeCursorMoveToChild(SBtCursor *pBtCur, SPgno pgno) { SPgFile *pPgFile; // TODO return 0; -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/source/libs/tdb/src/db/tdbEnv.c b/source/libs/tdb/src/db/tdbEnv.c index e81fbfaca8..d84832226b 100644 --- a/source/libs/tdb/src/db/tdbEnv.c +++ b/source/libs/tdb/src/db/tdbEnv.c @@ -15,6 +15,12 @@ #include "tdbInt.h" +struct STEnv { + char * rootDir; + SPCache *pCache; + int jfd; +}; + #if 0 struct STDbEnv { char * rootDir; // root directory of the environment diff --git a/source/libs/tdb/src/inc/tdbBtree.h b/source/libs/tdb/src/inc/tdbBtree.h index faa71cf2f8..85abe27ea7 100644 --- a/source/libs/tdb/src/inc/tdbBtree.h +++ b/source/libs/tdb/src/inc/tdbBtree.h @@ -23,6 +23,7 @@ extern "C" { typedef struct SBTree SBTree; typedef struct SBtCursor SBtCursor; +#if 0 // SBTree int btreeOpen(SBTree **ppBt, SPgFile *pPgFile); int btreeClose(SBTree *pBt); @@ -36,6 +37,7 @@ int btreeCursorNext(SBtCursor *pBtCur); struct SBTree { SPgno root; }; +#endif #ifdef __cplusplus } diff --git a/source/libs/tdb/src/inc/tdbEnv.h b/source/libs/tdb/src/inc/tdbEnv.h index 823e157706..9de9e4a0e4 100644 --- a/source/libs/tdb/src/inc/tdbEnv.h +++ b/source/libs/tdb/src/inc/tdbEnv.h @@ -20,13 +20,13 @@ extern "C" { #endif -#if 0 -const char* tdbEnvGetRootDir(TENV* pEnv); -SPgFile* tdbEnvGetPageFile(TENV* pEnv, const uint8_t fileid[]); -SPgCache* tdbEnvGetPgCache(TENV* pEnv); -int tdbEnvRgstPageFile(TENV* pEnv, SPgFile* pPgFile); -int tdbEnvRgstDB(TENV* pEnv, TDB* pDb); -#endif +typedef struct STEnv STEnv; + +int tdbEnvOpen(STEnv **ppEnv); +int tdbEnvClose(STEnv *pEnv); + +int tdbEnvBegin(STEnv *pEnv); +int tdbEnvCommit(STEnv *pEnv); #ifdef __cplusplus } diff --git a/source/libs/tdb/src/inc/tdbInt.h b/source/libs/tdb/src/inc/tdbInt.h index 2cef8979b0..ec99d1e97e 100644 --- a/source/libs/tdb/src/inc/tdbInt.h +++ b/source/libs/tdb/src/inc/tdbInt.h @@ -116,13 +116,13 @@ typedef TD_DLIST_NODE(SPgFile) SPgFileListNode; #include "tdbUtil.h" -// #include "tdbBtree.h" +#include "tdbBtree.h" #include "tdbPCache.h" #include "tdbPFile.h" -// #include "tdbEnv.h" +#include "tdbEnv.h" #ifdef __cplusplus }