From d622916529e259e6e7eecfa4f7422e8e066366cb Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Thu, 3 Mar 2022 10:12:09 +0000 Subject: [PATCH] more TDB --- source/libs/tdb/src/db/tdbBtree.c | 6 ++++++ source/libs/tdb/src/inc/tdbInt.h | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/source/libs/tdb/src/db/tdbBtree.c b/source/libs/tdb/src/db/tdbBtree.c index c5e7469516..5fa3782baf 100644 --- a/source/libs/tdb/src/db/tdbBtree.c +++ b/source/libs/tdb/src/db/tdbBtree.c @@ -15,6 +15,12 @@ #include "tdbInt.h" +#define TDB_BTREE_ROOT 0x1 +#define TDB_BTREE_LEAF 0x2 + +#define TDB_BTREE_PAGE_IS_ROOT(flags) TDB_FLAG_HAS(flags, TDB_BTREE_ROOT) +#define TDB_BTREE_PAGE_IS_LEAF(flags) TDB_FLAG_HAS(flags, TDB_BTREE_LEAF) + struct SBTree { SPgno root; int keyLen; diff --git a/source/libs/tdb/src/inc/tdbInt.h b/source/libs/tdb/src/inc/tdbInt.h index f3b5967295..364d1925fa 100644 --- a/source/libs/tdb/src/inc/tdbInt.h +++ b/source/libs/tdb/src/inc/tdbInt.h @@ -128,6 +128,11 @@ typedef int (*FKeyComparator)(const void *pKey1, int kLen1, const void *pKey2, i #define BTREE_MAX_DEPTH 20 +#define TDB_FLAG_HAS(flags, flag) (((flags) & (flag)) != 0) +#define TDB_FLAG_NO(flags, flag) ((flags) & (flag) == 0) +#define TDB_FLAG_ADD(flags, flag) ((flags) |= (flag)) +#define TDB_FLAG_REMOVE(flags, flag) ((flags) &= (~(flag))) + typedef struct SPager SPager; typedef struct SPCache SPCache; -- GitLab