add the test code for hashtable
This commit is contained in:
parent
2a89ac7d7f
commit
5012ecc1a5
|
@ -16,6 +16,10 @@
|
||||||
#ifndef TDENGINE_HASH_H
|
#ifndef TDENGINE_HASH_H
|
||||||
#define TDENGINE_HASH_H
|
#define TDENGINE_HASH_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "hashutil.h"
|
#include "hashutil.h"
|
||||||
|
|
||||||
#define HASH_MAX_CAPACITY (1024 * 1024 * 16)
|
#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);
|
char *taosGetDataFromHashTable(HashObj *pObj, const char *key, uint32_t keyLen);
|
||||||
|
|
||||||
|
|
||||||
void taosCleanUpHashTable(void *handle);
|
void taosCleanUpHashTable(void *handle);
|
||||||
|
|
||||||
int32_t taosGetHashMaxOverflowLength(HashObj *pObj);
|
int32_t taosGetHashMaxOverflowLength(HashObj *pObj);
|
||||||
|
|
||||||
int32_t taosCheckHashTable(HashObj *pObj);
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // TDENGINE_HASH_H
|
#endif // TDENGINE_HASH_H
|
||||||
|
|
|
@ -340,10 +340,6 @@ static void doAddToHashTable(HashObj *pObj, SHashNode *pNode) {
|
||||||
|
|
||||||
pEntry->num++;
|
pEntry->num++;
|
||||||
pObj->size++;
|
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) {
|
int32_t taosNumElemsInHashTable(HashObj *pObj) {
|
||||||
|
@ -525,29 +521,3 @@ int32_t taosGetHashMaxOverflowLength(HashObj* pObj) {
|
||||||
|
|
||||||
return num;
|
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;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue