From 110703f9dfaba749bed52185cd1acfd9889b4742 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 30 Mar 2022 10:51:07 +0000 Subject: [PATCH] refact more --- source/libs/tdb/src/db/tdbEnv.c | 15 +++++++++++ source/libs/tdb/src/db/tdbTxn.c | 44 ++++++++++++++++---------------- source/libs/tdb/src/inc/tdbEnv.h | 5 ++++ source/libs/tdb/src/inc/tdbInt.h | 17 ------------ source/libs/tdb/src/inc/tdbTxn.h | 4 --- source/libs/tdb/test/tdbTest.cpp | 2 +- 6 files changed, 43 insertions(+), 44 deletions(-) diff --git a/source/libs/tdb/src/db/tdbEnv.c b/source/libs/tdb/src/db/tdbEnv.c index 4439147e09..5a5c281ed1 100644 --- a/source/libs/tdb/src/db/tdbEnv.c +++ b/source/libs/tdb/src/db/tdbEnv.c @@ -64,6 +64,21 @@ int tdbEnvClose(TENV *pEnv) { return 0; } +int tdbBegin(TENV *pEnv) { + // TODO + return 0; +} + +int tdbCommit(TENV *pEnv) { + // TODO + return 0; +} + +int tdbRollback(TENV *pEnv) { + // TODO + return 0; +} + SPager *tdbEnvGetPager(TENV *pEnv, const char *fname) { // TODO return NULL; diff --git a/source/libs/tdb/src/db/tdbTxn.c b/source/libs/tdb/src/db/tdbTxn.c index bb0bc6c845..03bcbb44a7 100644 --- a/source/libs/tdb/src/db/tdbTxn.c +++ b/source/libs/tdb/src/db/tdbTxn.c @@ -15,29 +15,29 @@ #include "tdbInt.h" -int tdbTxnBegin(TENV *pEnv) { - // TODO - return 0; -} +// int tdbTxnBegin(TENV *pEnv) { +// // TODO +// return 0; +// } -int tdbTxnCommit(TENV *pEnv) { - SPager *pPager = NULL; - int ret; +// int tdbTxnCommit(TENV *pEnv) { +// SPager *pPager = NULL; +// int ret; - for (;;) { - break; - ret = tdbPagerCommit(pPager); - if (ret < 0) { - ASSERT(0); - return -1; - } - } +// for (;;) { +// break; +// ret = tdbPagerCommit(pPager); +// if (ret < 0) { +// ASSERT(0); +// return -1; +// } +// } - // TODO - return 0; -} +// // TODO +// return 0; +// } -int tdbTxnRollback(TENV *pEnv) { - // TODO - return 0; -} \ No newline at end of file +// int tdbTxnRollback(TENV *pEnv) { +// // TODO +// return 0; +// } \ No newline at end of file diff --git a/source/libs/tdb/src/inc/tdbEnv.h b/source/libs/tdb/src/inc/tdbEnv.h index a651c3a12e..693be86cd8 100644 --- a/source/libs/tdb/src/inc/tdbEnv.h +++ b/source/libs/tdb/src/inc/tdbEnv.h @@ -25,10 +25,15 @@ typedef struct STEnv { char *jfname; int jfd; SPCache *pCache; + int nHash; + SPager **pagerHash; } TENV; int tdbEnvOpen(const char *rootDir, int pageSize, int cacheSize, TENV **ppEnv); int tdbEnvClose(TENV *pEnv); +int tdbBegin(TENV *pEnv); +int tdbCommit(TENV *pEnv); +int tdbRollback(TENV *pEnv); SPager *tdbEnvGetPager(TENV *pEnv, const char *fname); diff --git a/source/libs/tdb/src/inc/tdbInt.h b/source/libs/tdb/src/inc/tdbInt.h index 361a460cef..26f9247952 100644 --- a/source/libs/tdb/src/inc/tdbInt.h +++ b/source/libs/tdb/src/inc/tdbInt.h @@ -91,23 +91,6 @@ static FORCE_INLINE int tdbCmprPgId(const void *p1, const void *p2) { // dbname #define TDB_MAX_DBNAME_LEN 24 -// tdb_log -#define tdbError(var) - -#define TERR_A(val, op, flag) \ - do { \ - if (((val) = (op)) != 0) { \ - goto flag; \ - } \ - } while (0) - -#define TERR_B(val, op, flag) \ - do { \ - if (((val) = (op)) == NULL) { \ - goto flag; \ - } \ - } while (0) - #define TDB_VARIANT_LEN ((int)-1) typedef int (*FKeyComparator)(const void *pKey1, int kLen1, const void *pKey2, int kLen2); diff --git a/source/libs/tdb/src/inc/tdbTxn.h b/source/libs/tdb/src/inc/tdbTxn.h index cc11369785..0be2dad3c2 100644 --- a/source/libs/tdb/src/inc/tdbTxn.h +++ b/source/libs/tdb/src/inc/tdbTxn.h @@ -28,10 +28,6 @@ struct STxn { void *xArg; }; -int tdbTxnBegin(TENV *pEnv); -int tdbTxnCommit(TENV *pEnv); -int tdbTxnRollback(TENV *pEnv); - #ifdef __cplusplus } #endif diff --git a/source/libs/tdb/test/tdbTest.cpp b/source/libs/tdb/test/tdbTest.cpp index a976a9e581..2d19596ca6 100644 --- a/source/libs/tdb/test/tdbTest.cpp +++ b/source/libs/tdb/test/tdbTest.cpp @@ -147,7 +147,7 @@ TEST(tdb_test, simple_test) { i++; } - tdbTxnCommit(pEnv); + tdbCommit(pEnv); } { // Query the data -- GitLab