diff --git a/include/util/tfunctional.h b/include/util/tfunctional.h deleted file mode 100644 index 43e3cd5e48..0000000000 --- a/include/util/tfunctional.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * 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 . - */ -#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_*/ diff --git a/include/util/tskiplist.h b/include/util/tskiplist.h index 10d3dcdbaa..1379a330d5 100644 --- a/include/util/tskiplist.h +++ b/include/util/tskiplist.h @@ -19,7 +19,6 @@ #include "os.h" #include "taos.h" #include "tarray.h" -#include "tfunctional.h" #ifdef __cplusplus extern "C" { @@ -67,7 +66,6 @@ typedef struct SSkipList { uint32_t size; SSkipListNode *pHead; // point to the first element SSkipListNode *pTail; // point to the last element - tGenericSavedFunc *insertHandleFn; } SSkipList; typedef struct SSkipListIterator { diff --git a/source/util/src/tfunctional.c b/source/util/src/tfunctional.c deleted file mode 100644 index d8f1e33324..0000000000 --- a/source/util/src/tfunctional.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * 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 . - */ - -#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 diff --git a/source/util/src/tskiplist.c b/source/util/src/tskiplist.c index d93e9fc569..c72c5c70ae 100644 --- a/source/util/src/tskiplist.c +++ b/source/util/src/tskiplist.c @@ -87,7 +87,6 @@ SSkipList *tSkipListCreate(uint8_t maxLevel, uint8_t keyType, uint16_t keyLen, _ #if SKIP_LIST_RECORD_PERFORMANCE pSkipList->state.nTotalMemSize += sizeof(SSkipList); #endif - pSkipList->insertHandleFn = NULL; return pSkipList; } @@ -105,8 +104,6 @@ void tSkipListDestroy(SSkipList *pSkipList) { tSkipListFreeNode(pTemp); } - taosMemoryFreeClear(pSkipList->insertHandleFn); - tSkipListUnlock(pSkipList); if (pSkipList->lock != NULL) { taosThreadRwlockDestroy(pSkipList->lock); @@ -684,35 +681,14 @@ static SSkipListNode *tSkipListPutImpl(SSkipList *pSkipList, void *pData, SSkipL } else { 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) { 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 { pNode = tSkipListNewNode(getSkipListRandLevel(pSkipList)); 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; - tSkipListDoInsert(pSkipList, direction, pNode, isForward); } }