diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 63c095ecf5904ad28675ce3c4de388556b4d62c5..33dc3a2469d79fab1035731cfeb5178f5c7a26d1 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -409,7 +409,7 @@ int32_t blockDataSplitRows(SSDataBlock* pBlock, bool hasVarCol, int32_t startInd } } - if (size > pageSize) { + if (size > pageSize) { // pageSize must be able to hold one row *stopIndex = j - 1; ASSERT(*stopIndex >= startIndex); diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index f960993e3e9714074196d7ed359717ca93da7dac..b66107b4a708c63366abd138760ff767c9a2c247 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -6155,7 +6155,7 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSDataBlock* pR return NULL; } - pInfo->bufPageSize = rowSize < 1024 ? 1024 : rowSize*2; + pInfo->bufPageSize = rowSize < 1024 ? 1024*2 : rowSize*2; // there are headers, so pageSize = rowSize + header pInfo->sortBufSize = pInfo->bufPageSize * 16; // TODO dynamic set the available sort buffer pInfo->numOfRowsInRes = 1024; diff --git a/source/libs/executor/test/sortTests.cpp b/source/libs/executor/test/sortTests.cpp index f1891f9c62d2140bdc5781efd1b757aa21d04a24..a89b76e81ecd03de63244c79547825fdbe83b0a7 100644 --- a/source/libs/executor/test/sortTests.cpp +++ b/source/libs/executor/test/sortTests.cpp @@ -287,7 +287,13 @@ TEST(testCase, external_mem_sort_Test) { for (int i = 0; i < 8; i++){ SBlockOrderInfo oi = {0}; - oi.order = TSDB_ORDER_ASC; + + if(pInfo[i].type == TSDB_DATA_TYPE_NCHAR){ + oi.order = TSDB_ORDER_DESC; + }else{ + oi.order = TSDB_ORDER_ASC; + } + oi.slotId = 0; SArray* orderInfo = taosArrayInit(1, sizeof(SBlockOrderInfo)); taosArrayPush(orderInfo, &oi); @@ -363,15 +369,16 @@ TEST(testCase, ordered_merge_sort_Test) { tsortSetFetchRawDataFp(phandle, getSingleColDummyBlock); tsortSetComparFp(phandle, docomp); + SGenericSource* p = static_cast(taosMemoryCalloc(10, sizeof(SGenericSource))); + _info* c = static_cast<_info*>(taosMemoryCalloc(10, sizeof(_info))); for(int32_t i = 0; i < 10; ++i) { - SGenericSource* p = static_cast(taosMemoryCalloc(1, sizeof(SGenericSource))); - _info* c = static_cast<_info*>(taosMemoryCalloc(1, sizeof(_info))); - c->count = 1; - c->pageRows = 1000; - c->startVal = i*1000; - - p->param = c; - tsortAddSource(phandle, p); + c[i].count = 1; + c[i].pageRows = 1000; + c[i].startVal = i*1000; + c[i].type = TSDB_DATA_TYPE_INT; + + p[i].param = c; + tsortAddSource(phandle, &p[i]); } int32_t code = tsortOpen(phandle); @@ -388,8 +395,10 @@ TEST(testCase, ordered_merge_sort_Test) { ASSERT_EQ(row++, *(int32_t*) v); } + taosMemoryFree(p); + taosMemoryFree(c); tsortDestroySortHandle(phandle); - taosMemoryFree(pBlock); + blockDataDestroy(pBlock); } #endif