From 124fb5fc5076163d091f5036b3e610d8cf8f6dd5 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 30 Nov 2022 17:52:12 +0800 Subject: [PATCH 1/2] refactor: do some internal refactor. --- include/util/tarray.h | 15 ++------------- source/dnode/mnode/impl/src/mndConsumer.c | 5 +++-- source/dnode/vnode/src/tsdb/tsdbRead.c | 1 + source/libs/stream/src/streamUpdate.c | 7 ++++++- source/util/src/tarray.c | 9 +-------- 5 files changed, 13 insertions(+), 24 deletions(-) diff --git a/include/util/tarray.h b/include/util/tarray.h index beebd70dea..0e78397ecb 100644 --- a/include/util/tarray.h +++ b/include/util/tarray.h @@ -220,15 +220,10 @@ void taosArrayClear(SArray* pArray); */ void taosArrayClearEx(SArray* pArray, void (*fp)(void*)); -/** - * clear the array (remove all element) - * @param pArray - * @param fp - */ -void taosArrayClearP(SArray* pArray, FDelete fp); - void* taosArrayDestroy(SArray* pArray); + void taosArrayDestroyP(SArray* pArray, FDelete fp); + void taosArrayDestroyEx(SArray* pArray, FDelete fp); /** @@ -238,12 +233,6 @@ void taosArrayDestroyEx(SArray* pArray, FDelete fp); */ void taosArraySort(SArray* pArray, __compar_fn_t comparFn); -/** - * sort string array - * @param pArray - */ -void taosArraySortString(SArray* pArray, __compar_fn_t comparFn); - /** * search the array * @param pArray diff --git a/source/dnode/mnode/impl/src/mndConsumer.c b/source/dnode/mnode/impl/src/mndConsumer.c index 58f8172282..4397ea0751 100644 --- a/source/dnode/mnode/impl/src/mndConsumer.c +++ b/source/dnode/mnode/impl/src/mndConsumer.c @@ -538,7 +538,7 @@ static int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) { int32_t code = -1; SArray *newSub = subscribe.topicNames; - taosArraySortString(newSub, taosArrayCompareString); + taosArraySort(newSub, taosArrayCompareString); taosArrayRemoveDuplicateP(newSub, taosArrayCompareString, taosMemoryFree); int32_t newTopicNum = taosArrayGetSize(newSub); @@ -850,7 +850,8 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer, // add to current topic taosArrayPush(pOldConsumer->currentTopics, &addedTopic); - taosArraySortString(pOldConsumer->currentTopics, taosArrayCompareString); + taosArraySort(pOldConsumer->currentTopics, taosArrayCompareString); + // set status if (taosArrayGetSize(pOldConsumer->rebNewTopics) == 0 && taosArrayGetSize(pOldConsumer->rebRemovedTopics) == 0) { if (pOldConsumer->status == MQ_CONSUMER_STATUS__MODIFY || diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index 26c9ce6810..83532c2a20 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -2543,6 +2543,7 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader* goto _err; } + // TODO: opt the perf of read del index code = tsdbReadDelIdx(pDelFReader, aDelIdx); if (code != TSDB_CODE_SUCCESS) { taosArrayDestroy(aDelIdx); diff --git a/source/libs/stream/src/streamUpdate.c b/source/libs/stream/src/streamUpdate.c index 1589fddda4..1ce4a35dff 100644 --- a/source/libs/stream/src/streamUpdate.c +++ b/source/libs/stream/src/streamUpdate.c @@ -44,6 +44,11 @@ static void windowSBfAdd(SUpdateInfo *pInfo, uint64_t count) { } } +static void clearItemHelper(void* p) { + SScalableBf** pBf = p; + tScalableBfDestroy(*pBf); +} + static void windowSBfDelete(SUpdateInfo *pInfo, uint64_t count) { if (count < pInfo->numSBFs) { for (uint64_t i = 0; i < count; ++i) { @@ -52,7 +57,7 @@ static void windowSBfDelete(SUpdateInfo *pInfo, uint64_t count) { taosArrayRemove(pInfo->pTsSBFs, 0); } } else { - taosArrayClearP(pInfo->pTsSBFs, (FDelete)tScalableBfDestroy); + taosArrayClearEx(pInfo->pTsSBFs, clearItemHelper); } pInfo->minTS += pInfo->interval * count; } diff --git a/source/util/src/tarray.c b/source/util/src/tarray.c index f53b1cfd7f..ae25786375 100644 --- a/source/util/src/tarray.c +++ b/source/util/src/tarray.c @@ -399,9 +399,7 @@ void taosArrayDestroyEx(SArray* pArray, FDelete fp) { } void taosArraySort(SArray* pArray, __compar_fn_t compar) { - assert(pArray != NULL); - assert(compar != NULL); - + ASSERT(pArray != NULL && compar != NULL); taosSort(pArray->pData, pArray->size, pArray->elemSize, compar); } @@ -417,11 +415,6 @@ int32_t taosArraySearchIdx(const SArray* pArray, const void* key, __compar_fn_t return item == NULL ? -1 : (int32_t)((char*)item - (char*)pArray->pData) / pArray->elemSize; } -void taosArraySortString(SArray* pArray, __compar_fn_t comparFn) { - assert(pArray != NULL); - taosSort(pArray->pData, pArray->size, pArray->elemSize, comparFn); -} - static int32_t taosArrayPartition(SArray* pArray, int32_t i, int32_t j, __ext_compar_fn_t fn, const void* userData) { void* key = taosArrayGetP(pArray, i); while (i < j) { From 26122eb51a224808bcbf6ad011c64d7a1179318a Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Wed, 30 Nov 2022 19:47:39 +0800 Subject: [PATCH 2/2] fix: benchmark query result precision (#18581) * fix: taosbenchmark query result precision * test: update to f5da335 * test: update taos-tools 96192d4 * test: update taos-tools c6df1eb * test: update taostools 2378cdf * fix: taosbenchmark query result precision --- cmake/taostools_CMakeLists.txt.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/taostools_CMakeLists.txt.in b/cmake/taostools_CMakeLists.txt.in index 47f2d20828..e0585f8d13 100644 --- a/cmake/taostools_CMakeLists.txt.in +++ b/cmake/taostools_CMakeLists.txt.in @@ -2,7 +2,7 @@ # taos-tools ExternalProject_Add(taos-tools GIT_REPOSITORY https://github.com/taosdata/taos-tools.git - GIT_TAG b103d9b + GIT_TAG 5445810 SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools" BINARY_DIR "" #BUILD_IN_SOURCE TRUE