diff --git a/source/libs/tdb/src/db/tdbBtree.c b/source/libs/tdb/src/db/tdbBtree.c index c5e7469516fdfc7bda72695389f8c80508ea44b3..5fa3782baf6fff8c3b9ae9eac27e8f36845e47de 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 f3b5967295fecc95fc0d707d26b3c3417c1e388b..364d1925fa31f3a757d3c7b4a0fcc68efc51ac1c 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;