From 14bd838a9f285464b1025634a77f0a1d6c56e522 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Thu, 31 Mar 2022 02:23:58 +0000 Subject: [PATCH] more TDB --- .clang-format | 1 + source/libs/tdb/src/db/tdbEnv.c | 6 +++--- source/libs/tdb/src/inc/tdbInt.h | 2 -- source/libs/tdb/src/inc/tdbOs.h | 2 ++ source/libs/tdb/src/inc/tdbUtil.h | 5 +---- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.clang-format b/.clang-format index 3ddd8b43f6..e58d518b3b 100644 --- a/.clang-format +++ b/.clang-format @@ -5,6 +5,7 @@ AccessModifierOffset: -1 AlignAfterOpenBracket: Align AlignConsecutiveAssignments: false AlignConsecutiveDeclarations: true +AlignConsecutiveMacros: true AlignEscapedNewlinesLeft: true AlignOperands: true AlignTrailingComments: true diff --git a/source/libs/tdb/src/db/tdbEnv.c b/source/libs/tdb/src/db/tdbEnv.c index 6e74aefc62..a9e29d3f73 100644 --- a/source/libs/tdb/src/db/tdbEnv.c +++ b/source/libs/tdb/src/db/tdbEnv.c @@ -95,7 +95,7 @@ int tdbRollback(TENV *pEnv) { } SPager *tdbEnvGetPager(TENV *pEnv, const char *fname) { - int hash; + u32 hash; SPager **ppPager; hash = tdbCstringHash(fname); @@ -107,7 +107,7 @@ SPager *tdbEnvGetPager(TENV *pEnv, const char *fname) { } void tdbEnvAddPager(TENV *pEnv, SPager *pPager) { - int hash; + u32 hash; SPager **ppPager; // rehash if neccessary @@ -130,7 +130,7 @@ void tdbEnvAddPager(TENV *pEnv, SPager *pPager) { } void tdbEnvRemovePager(TENV *pEnv, SPager *pPager) { - int hash; + u32 hash; SPager **ppPager; // remove from the list diff --git a/source/libs/tdb/src/inc/tdbInt.h b/source/libs/tdb/src/inc/tdbInt.h index 26f9247952..57e01f904c 100644 --- a/source/libs/tdb/src/inc/tdbInt.h +++ b/source/libs/tdb/src/inc/tdbInt.h @@ -16,8 +16,6 @@ #ifndef _TD_TDB_INTERNAL_H_ #define _TD_TDB_INTERNAL_H_ -#include "os.h" - #include "tdb.h" #ifdef __cplusplus diff --git a/source/libs/tdb/src/inc/tdbOs.h b/source/libs/tdb/src/inc/tdbOs.h index 5259cfb4d3..ae389708f4 100644 --- a/source/libs/tdb/src/inc/tdbOs.h +++ b/source/libs/tdb/src/inc/tdbOs.h @@ -24,6 +24,8 @@ extern "C" { #define TDB_FOR_TDENGINE #ifdef TDB_FOR_TDENGINE +#include "os.h" +#include "thash.h" // For memory ----------------- #define tdbOsMalloc taosMemoryMalloc diff --git a/source/libs/tdb/src/inc/tdbUtil.h b/source/libs/tdb/src/inc/tdbUtil.h index a4cb09ea94..6abddb5b22 100644 --- a/source/libs/tdb/src/inc/tdbUtil.h +++ b/source/libs/tdb/src/inc/tdbUtil.h @@ -101,10 +101,7 @@ static inline int tdbGetVarInt(const u8 *p, int *v) { return n; } -static inline int tdbCstringHash(const char *s) { - // TODO - return 0; -} +static inline u32 tdbCstringHash(const char *s) { return MurmurHash3_32(s, strlen(s)); } #ifdef __cplusplus } -- GitLab