未验证 提交 a2fcf511 编写于 作者: H Hui Li 提交者: GitHub

Merge pull request #17677 from taosdata/fix/TD-19794-V30

fix(coverage): remove the function about skiplist callback
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_UTIL_FUNCTIONAL_H_
#define _TD_UTIL_FUNCTIONAL_H_
#include "os.h"
#ifdef __cplusplus
extern "C" {
#endif
// TODO: hard to use, trying to rewrite it using va_list
typedef void* (*GenericVaFunc)(void* args[]);
typedef int32_t (*I32VaFunc)(void* args[]);
typedef void (*VoidVaFunc)(void* args[]);
typedef struct GenericSavedFunc {
GenericVaFunc func;
void* args[];
} tGenericSavedFunc;
typedef struct I32SavedFunc {
I32VaFunc func;
void* args[];
} tI32SavedFunc;
typedef struct VoidSavedFunc {
VoidVaFunc func;
void* args[];
} tVoidSavedFunc;
tGenericSavedFunc* genericSavedFuncInit(GenericVaFunc func, int32_t numOfArgs);
tI32SavedFunc* i32SavedFuncInit(I32VaFunc func, int32_t numOfArgs);
tVoidSavedFunc* voidSavedFuncInit(VoidVaFunc func, int32_t numOfArgs);
void* genericInvoke(tGenericSavedFunc* const pSavedFunc);
int32_t i32Invoke(tI32SavedFunc* const pSavedFunc);
void voidInvoke(tVoidSavedFunc* const pSavedFunc);
#ifdef __cplusplus
}
#endif
#endif /*_TD_UTIL_FUNCTIONAL_H_*/
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "os.h" #include "os.h"
#include "taos.h" #include "taos.h"
#include "tarray.h" #include "tarray.h"
#include "tfunctional.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
...@@ -67,7 +66,6 @@ typedef struct SSkipList { ...@@ -67,7 +66,6 @@ typedef struct SSkipList {
uint32_t size; uint32_t size;
SSkipListNode *pHead; // point to the first element SSkipListNode *pHead; // point to the first element
SSkipListNode *pTail; // point to the last element SSkipListNode *pTail; // point to the last element
tGenericSavedFunc *insertHandleFn;
} SSkipList; } SSkipList;
typedef struct SSkipListIterator { typedef struct SSkipListIterator {
......
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "tfunctional.h"
FORCE_INLINE void* genericInvoke(tGenericSavedFunc* const pSavedFunc) { return pSavedFunc->func(pSavedFunc->args); }
#if 0
tGenericSavedFunc* genericSavedFuncInit(GenericVaFunc func, int32_t numOfArgs) {
tGenericSavedFunc* pSavedFunc = taosMemoryMalloc(sizeof(tGenericSavedFunc) + numOfArgs * (sizeof(void*)));
if (pSavedFunc == NULL) return NULL;
pSavedFunc->func = func;
return pSavedFunc;
}
tI32SavedFunc* i32SavedFuncInit(I32VaFunc func, int32_t numOfArgs) {
tI32SavedFunc* pSavedFunc = taosMemoryMalloc(sizeof(tI32SavedFunc) + numOfArgs * sizeof(void*));
if (pSavedFunc == NULL) return NULL;
pSavedFunc->func = func;
return pSavedFunc;
}
tVoidSavedFunc* voidSavedFuncInit(VoidVaFunc func, int32_t numOfArgs) {
tVoidSavedFunc* pSavedFunc = taosMemoryMalloc(sizeof(tVoidSavedFunc) + numOfArgs * sizeof(void*));
if (pSavedFunc == NULL) return NULL;
pSavedFunc->func = func;
return pSavedFunc;
}
FORCE_INLINE int32_t i32Invoke(tI32SavedFunc* const pSavedFunc) { return pSavedFunc->func(pSavedFunc->args); }
FORCE_INLINE void voidInvoke(tVoidSavedFunc* const pSavedFunc) {
if (pSavedFunc) pSavedFunc->func(pSavedFunc->args);
}
#endif
\ No newline at end of file
...@@ -87,7 +87,6 @@ SSkipList *tSkipListCreate(uint8_t maxLevel, uint8_t keyType, uint16_t keyLen, _ ...@@ -87,7 +87,6 @@ SSkipList *tSkipListCreate(uint8_t maxLevel, uint8_t keyType, uint16_t keyLen, _
#if SKIP_LIST_RECORD_PERFORMANCE #if SKIP_LIST_RECORD_PERFORMANCE
pSkipList->state.nTotalMemSize += sizeof(SSkipList); pSkipList->state.nTotalMemSize += sizeof(SSkipList);
#endif #endif
pSkipList->insertHandleFn = NULL;
return pSkipList; return pSkipList;
} }
...@@ -105,8 +104,6 @@ void tSkipListDestroy(SSkipList *pSkipList) { ...@@ -105,8 +104,6 @@ void tSkipListDestroy(SSkipList *pSkipList) {
tSkipListFreeNode(pTemp); tSkipListFreeNode(pTemp);
} }
taosMemoryFreeClear(pSkipList->insertHandleFn);
tSkipListUnlock(pSkipList); tSkipListUnlock(pSkipList);
if (pSkipList->lock != NULL) { if (pSkipList->lock != NULL) {
taosThreadRwlockDestroy(pSkipList->lock); taosThreadRwlockDestroy(pSkipList->lock);
...@@ -684,35 +681,14 @@ static SSkipListNode *tSkipListPutImpl(SSkipList *pSkipList, void *pData, SSkipL ...@@ -684,35 +681,14 @@ static SSkipListNode *tSkipListPutImpl(SSkipList *pSkipList, void *pData, SSkipL
} else { } else {
pNode = SL_NODE_GET_BACKWARD_POINTER(direction[0], 0); pNode = SL_NODE_GET_BACKWARD_POINTER(direction[0], 0);
} }
if (pSkipList->insertHandleFn) {
pSkipList->insertHandleFn->args[0] = pData;
pSkipList->insertHandleFn->args[1] = pNode->pData;
pData = genericInvoke(pSkipList->insertHandleFn);
}
if (pData) { if (pData) {
atomic_store_ptr(&(pNode->pData), pData); atomic_store_ptr(&(pNode->pData), pData);
} }
} else {
// for compatiblity, duplicate key inserted when update=0 should be also calculated as affected rows!
if (pSkipList->insertHandleFn) {
pSkipList->insertHandleFn->args[0] = NULL;
pSkipList->insertHandleFn->args[1] = NULL;
genericInvoke(pSkipList->insertHandleFn);
}
} }
} else { } else {
pNode = tSkipListNewNode(getSkipListRandLevel(pSkipList)); pNode = tSkipListNewNode(getSkipListRandLevel(pSkipList));
if (pNode != NULL) { if (pNode != NULL) {
// insertHandleFn will be assigned only for timeseries data,
// in which case, pData is pointed to an memory to be freed later;
// while for metadata, the mem alloc will not be called.
if (pSkipList->insertHandleFn) {
pSkipList->insertHandleFn->args[0] = pData;
pSkipList->insertHandleFn->args[1] = NULL;
pData = genericInvoke(pSkipList->insertHandleFn);
}
pNode->pData = pData; pNode->pData = pData;
tSkipListDoInsert(pSkipList, direction, pNode, isForward); tSkipListDoInsert(pSkipList, direction, pNode, isForward);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册