From 3d156255c857aa668fadaa414f9a2bd4a07098a4 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 9 Feb 2022 10:40:11 +0800 Subject: [PATCH] [td-11818] opt performance --- source/common/src/tep.c | 18 +++++++++--------- source/libs/executor/test/executorTests.cpp | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/source/common/src/tep.c b/source/common/src/tep.c index 64bd5e635a..0a5dfe4c4b 100644 --- a/source/common/src/tep.c +++ b/source/common/src/tep.c @@ -538,18 +538,18 @@ int32_t dataBlockCompar(const void* p1, const void* p2, const void* param) { SSDataBlock* pDataBlock = pHelper->pDataBlock; - int32_t* left = (int32_t*) p1; - int32_t* right = (int32_t*) p2; + int32_t left = *(int32_t*) p1; + int32_t right = *(int32_t*) p2; SArray* pInfo = pHelper->orderInfo; for(int32_t i = 0; i < pInfo->size; ++i) { - SBlockOrderInfo* pOrder = taosArrayGet(pInfo, i); + SBlockOrderInfo* pOrder = TARRAY_GET_ELEM(pInfo, i); SColumnInfoData* pColInfoData = TARRAY_GET_ELEM(pDataBlock->pDataBlock, pOrder->colIndex); if (pColInfoData->hasNull) { - bool leftNull = colDataIsNull(pColInfoData, pDataBlock->info.rows, *left, pDataBlock->pBlockAgg); - bool rightNull = colDataIsNull(pColInfoData, pDataBlock->info.rows, *right, pDataBlock->pBlockAgg); + bool leftNull = colDataIsNull(pColInfoData, pDataBlock->info.rows, left, pDataBlock->pBlockAgg); + bool rightNull = colDataIsNull(pColInfoData, pDataBlock->info.rows, right, pDataBlock->pBlockAgg); if (leftNull && rightNull) { continue; // continue to next slot } @@ -563,8 +563,8 @@ int32_t dataBlockCompar(const void* p1, const void* p2, const void* param) { } } - void* left1 = colDataGet(pColInfoData, *left); - void* right1 = colDataGet(pColInfoData, *right); + void* left1 = colDataGet(pColInfoData, left); + void* right1 = colDataGet(pColInfoData, right); switch(pColInfoData->info.type) { case TSDB_DATA_TYPE_INT: { @@ -575,9 +575,9 @@ int32_t dataBlockCompar(const void* p1, const void* p2, const void* param) { break; } else { if (pOrder->order == TSDB_ORDER_ASC) { - return (leftx <= rightx)? -1:1; + return (leftx < rightx)? -1:1; } else { - return (leftx <= rightx)? 1:-1; + return (leftx < rightx)? 1:-1; } } } diff --git a/source/libs/executor/test/executorTests.cpp b/source/libs/executor/test/executorTests.cpp index 69d2603f62..c8db23c429 100644 --- a/source/libs/executor/test/executorTests.cpp +++ b/source/libs/executor/test/executorTests.cpp @@ -78,7 +78,7 @@ SSDataBlock* getDummyBlock(void* param, bool* newgroup) { char buf[128] = {0}; char b1[128] = {0}; for(int32_t i = 0; i < numOfRows; ++i) { - SColumnInfoData* pColInfo = static_cast(taosArrayGet(pBlock->pDataBlock, 0)); + SColumnInfoData* pColInfo = static_cast(TARRAY_GET_ELEM(pBlock->pDataBlock, 0)); int32_t v = (--pInfo->startVal); colDataAppend(pColInfo, i, reinterpret_cast(&v), false); @@ -86,7 +86,7 @@ SSDataBlock* getDummyBlock(void* param, bool* newgroup) { sprintf(buf, "this is %d row", i); STR_TO_VARSTR(b1, buf); - SColumnInfoData* pColInfo2 = static_cast(taosArrayGet(pBlock->pDataBlock, 1)); + SColumnInfoData* pColInfo2 = static_cast(TARRAY_GET_ELEM(pBlock->pDataBlock, 1)); colDataAppend(pColInfo2, i, b1, false); } -- GitLab