From 865a13c1c2bfa8000f2df1452587c34bdca2da11 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Wed, 6 Apr 2022 16:46:26 +0800 Subject: [PATCH] fix error in sort logic --- source/common/src/tdatablock.c | 2 +- source/libs/executor/src/tsort.c | 6 +++--- source/libs/executor/test/sortTests.cpp | 6 +++++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 372ea9a2d7..63c095ecf5 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -411,7 +411,7 @@ int32_t blockDataSplitRows(SSDataBlock* pBlock, bool hasVarCol, int32_t startInd if (size > pageSize) { *stopIndex = j - 1; - ASSERT(*stopIndex > startIndex); + ASSERT(*stopIndex >= startIndex); return TSDB_CODE_SUCCESS; } diff --git a/source/libs/executor/src/tsort.c b/source/libs/executor/src/tsort.c index e5312921fa..7e01fe0ba8 100644 --- a/source/libs/executor/src/tsort.c +++ b/source/libs/executor/src/tsort.c @@ -132,9 +132,9 @@ void tsortDestroySortHandle(SSortHandle* pSortHandle) { taosMemoryFreeClear(pSortHandle->idStr); blockDataDestroy(pSortHandle->pDataBlock); for (size_t i = 0; i < taosArrayGetSize(pSortHandle->pOrderedSource); i++){ - SExternalMemSource* pSource = taosArrayGet(pSortHandle->pOrderedSource, i); - blockDataDestroy(pSource->src.pBlock); - taosMemoryFreeClear(pSource); + SExternalMemSource** pSource = taosArrayGet(pSortHandle->pOrderedSource, i); + blockDataDestroy((*pSource)->src.pBlock); + taosMemoryFreeClear(*pSource); } taosArrayDestroy(pSortHandle->pOrderedSource); taosMemoryFreeClear(pSortHandle); diff --git a/source/libs/executor/test/sortTests.cpp b/source/libs/executor/test/sortTests.cpp index 9ad16669a4..f1891f9c62 100644 --- a/source/libs/executor/test/sortTests.cpp +++ b/source/libs/executor/test/sortTests.cpp @@ -91,7 +91,7 @@ SSDataBlock* getSingleColDummyBlock(void* param) { char strOri[128] = {0}; taosRandStr(strOri, size); int32_t len = 0; - bool ret = taosMbsToUcs4(strOri, size, (TdUcs4*)varDataVal(str), 128, &len); + bool ret = taosMbsToUcs4(strOri, size, (TdUcs4*)varDataVal(str), size * TSDB_NCHAR_SIZE, &len); if (!ret){ printf("error\n"); return NULL; @@ -321,6 +321,10 @@ TEST(testCase, external_mem_sort_Test) { char buf[128] = {0}; memcpy(buf, varDataVal(v), varDataLen(v)); printf("%d: %s\n", row++, buf); + }else if(pInfo[i].type == TSDB_DATA_TYPE_DOUBLE) { + printf("double: %lf\n", *(double*)v); + }else if (pInfo[i].type == TSDB_DATA_TYPE_FLOAT) { + printf("float: %f\n", *(float*)v); }else{ int64_t result = 0; if (!bigendian()){ -- GitLab