提交 78acaed8 编写于 作者: wmmhello's avatar wmmhello

fix error in sort logic

上级 9b66bb16
......@@ -36,11 +36,13 @@ IF (TD_WINDOWS)
ENDIF ()
ELSE ()
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3")
#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3")
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -static-libasan -g3")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -static-libasan -g3")
MESSAGE("System processor ID: ${CMAKE_SYSTEM_PROCESSOR}")
IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64")
IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
ADD_DEFINITIONS("-D_TD_ARM_")
ELSE ()
ADD_DEFINITIONS("-msse4.2 -mfma")
......
......@@ -373,9 +373,9 @@ int32_t blockDataSplitRows(SSDataBlock* pBlock, bool hasVarCol, int32_t startInd
size_t payloadSize = pageSize - (headerSize + colHeaderSize);
// TODO speedup by checking if the whole page can fit in firstly.
if (!hasVarCol) {
/*if (!hasVarCol) {
size_t rowSize = blockDataGetRowSize(pBlock);
int32_t capacity = (payloadSize / (rowSize * 8 + bitmapChar * numOfCols)) * 8;
int32_t capacity = (payloadSize / (rowSize * 8 + bitmapChar * numOfCols)) * 8; //if pageSize = 128, rowSize = 2, it will core in doAddToBuf:assert(size <= getBufPageSize(pHandle->pBuf));
*stopIndex = startIndex + capacity;
if (*stopIndex >= numOfRows) {
......@@ -383,7 +383,7 @@ int32_t blockDataSplitRows(SSDataBlock* pBlock, bool hasVarCol, int32_t startInd
}
return TSDB_CODE_SUCCESS;
}
}*/
// iterate the rows that can be fit in this buffer page
int32_t size = (headerSize + colHeaderSize);
......
......@@ -131,7 +131,12 @@ void tsortDestroySortHandle(SSortHandle* pSortHandle) {
destroyDiskbasedBuf(pSortHandle->pBuf);
taosMemoryFreeClear(pSortHandle->idStr);
blockDataDestroy(pSortHandle->pDataBlock);
sortComparClearup(&pSortHandle->cmpParam); // pOrderedSource is in cmpParam
for (size_t i = 0; i < taosArrayGetSize(pSortHandle->pOrderedSource); i++){
SExternalMemSource* pSource = taosArrayGet(pSortHandle->pOrderedSource, i);
blockDataDestroy(pSource->src.pBlock);
taosMemoryFreeClear(pSource);
}
taosArrayDestroy(pSortHandle->pOrderedSource);
taosMemoryFreeClear(pSortHandle);
}
......
......@@ -122,7 +122,8 @@ SSDataBlock* getSingleColDummyBlock(void* param) {
}
colDataAppend(pColInfo, i, result, false);
printf("int: %lld\n", v);
printf("int: %ld\n", v);
taosMemoryFree(result);
}
}
......@@ -238,11 +239,12 @@ TEST(testCase, inMem_sort_Test) {
}
taosArrayDestroy(orderInfo);
tsortDestroySortHandle(phandle);
taosMemoryFree(pInfo);
}
TEST(testCase, external_mem_sort_Test) {
_info* pInfo = (_info*) taosMemoryCalloc(7, sizeof(_info));
_info* pInfo = (_info*) taosMemoryCalloc(8, sizeof(_info));
pInfo[0].startVal = 0;
pInfo[0].pageRows = 10;
pInfo[0].count = 6;
......@@ -258,32 +260,32 @@ TEST(testCase, external_mem_sort_Test) {
pInfo[2].count = 6;
pInfo[2].type = TSDB_DATA_TYPE_USMALLINT;
pInfo[2].startVal = 0;
pInfo[2].pageRows = 100;
pInfo[2].count = 6;
pInfo[2].type = TSDB_DATA_TYPE_INT;
pInfo[3].startVal = 0;
pInfo[3].pageRows = 100;
pInfo[3].count = 6;
pInfo[3].type = TSDB_DATA_TYPE_UBIGINT;
pInfo[3].type = TSDB_DATA_TYPE_INT;
pInfo[4].startVal = 0;
pInfo[4].pageRows = 100;
pInfo[4].count = 6;
pInfo[4].type = TSDB_DATA_TYPE_DOUBLE;
pInfo[4].type = TSDB_DATA_TYPE_UBIGINT;
pInfo[5].startVal = 0;
pInfo[5].pageRows = 50;
pInfo[5].pageRows = 100;
pInfo[5].count = 6;
pInfo[5].type = TSDB_DATA_TYPE_NCHAR;
pInfo[5].type = TSDB_DATA_TYPE_DOUBLE;
pInfo[6].startVal = 0;
pInfo[6].pageRows = 100;
pInfo[6].pageRows = 50;
pInfo[6].count = 6;
pInfo[6].type = TSDB_DATA_TYPE_BINARY;
pInfo[6].type = TSDB_DATA_TYPE_NCHAR;
pInfo[7].startVal = 0;
pInfo[7].pageRows = 100;
pInfo[7].count = 6;
pInfo[7].type = TSDB_DATA_TYPE_BINARY;
for (int i = 0; i < 7; i++){
for (int i = 0; i < 8; i++){
SBlockOrderInfo oi = {0};
oi.order = TSDB_ORDER_ASC;
oi.slotId = 0;
......@@ -326,7 +328,7 @@ TEST(testCase, external_mem_sort_Test) {
}else{
memcpy((char*)(&result) + sizeof(int64_t) - tDataTypes[pInfo[i].type].bytes, v, tDataTypes[pInfo[i].type].bytes);
}
printf("%d: %lld\n", row++, result);
printf("%d: %ld\n", row++, result);
}
}
taosArrayDestroy(orderInfo);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册