From 5012ecc1a5df9cb17aca1751f1b72e8894e38c48 Mon Sep 17 00:00:00 2001 From: hjxilinx Date: Fri, 14 Feb 2020 15:52:18 +0800 Subject: [PATCH] add the test code for hashtable --- src/inc/hash.h | 9 +++++++-- src/util/src/hash.c | 30 ------------------------------ 2 files changed, 7 insertions(+), 32 deletions(-) diff --git a/src/inc/hash.h b/src/inc/hash.h index 14c73fb370..3d60abe9c6 100644 --- a/src/inc/hash.h +++ b/src/inc/hash.h @@ -16,6 +16,10 @@ #ifndef TDENGINE_HASH_H #define TDENGINE_HASH_H +#ifdef __cplusplus +extern "C" { +#endif + #include "hashutil.h" #define HASH_MAX_CAPACITY (1024 * 1024 * 16) @@ -64,11 +68,12 @@ int32_t taosNumElemsInHashTable(HashObj *pObj); char *taosGetDataFromHashTable(HashObj *pObj, const char *key, uint32_t keyLen); - void taosCleanUpHashTable(void *handle); int32_t taosGetHashMaxOverflowLength(HashObj *pObj); -int32_t taosCheckHashTable(HashObj *pObj); +#ifdef __cplusplus +} +#endif #endif // TDENGINE_HASH_H diff --git a/src/util/src/hash.c b/src/util/src/hash.c index 99643c92cc..2f643f17fa 100644 --- a/src/util/src/hash.c +++ b/src/util/src/hash.c @@ -340,10 +340,6 @@ static void doAddToHashTable(HashObj *pObj, SHashNode *pNode) { pEntry->num++; pObj->size++; - -// char key[512] = {0}; -// memcpy(key, pNode->key, MIN(512, pNode->keyLen)); -// pTrace("key:%s %p add to hash table", key, pNode); } int32_t taosNumElemsInHashTable(HashObj *pObj) { @@ -525,29 +521,3 @@ int32_t taosGetHashMaxOverflowLength(HashObj* pObj) { return num; } - -int32_t taosCheckHashTable(HashObj *pObj) { - for(int32_t i = 0; i < pObj->capacity; ++i) { - SHashEntry *pEntry = pObj->hashList[i]; - - SHashNode* pNode = pEntry->next; - if (pNode != NULL) { - assert(pEntry == pNode->prev1); - int32_t num = 1; - - SHashNode* pNext = pNode->next; - - while(pNext) { - assert(pNext->prev == pNode); - - pNode = pNext; - pNext = pNext->next; - num ++; - } - - assert(num == pEntry->num); - } - } - - return 0; -}