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

fix error in order by logic

上级 155b1438
......@@ -6513,9 +6513,9 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSDataBlock* pR
return NULL;
}
pInfo->bufPageSize = rowSize < 1024 ? 1024 : rowSize;
pInfo->bufPageSize = rowSize < 1024 ? 1024 : rowSize*2;
pInfo->sortBufSize = pInfo->bufPageSize * 16; // 1MB, TODO dynamic set the available sort buffer
pInfo->sortBufSize = pInfo->bufPageSize * 16; // TODO dynamic set the available sort buffer
pInfo->numOfRowsInRes = 1024;
pInfo->pDataBlock = pResBlock;
pInfo->pSortInfo = pSortInfo;
......
......@@ -141,8 +141,8 @@ static int32_t doAddNewExternalMemSource(SDiskbasedBuf *pBuf, SArray* pAllSource
(*sourceId) += 1;
int32_t rowSize = blockDataGetSerialRowSize(pSource->src.pBlock);
int32_t numOfRows = (getBufPageSize(pBuf) - blockDataGetSerialMetaSize(pBlock))/rowSize;
int32_t numOfRows = (getBufPageSize(pBuf) - blockDataGetSerialMetaSize(pBlock))/rowSize; // The value of numOfRows must be greater than 0, which is guaranteed by the previous memory allocation
ASSERT(numOfRows > 0);
return blockDataEnsureCapacity(pSource->src.pBlock, numOfRows);
}
......@@ -421,7 +421,7 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) {
size_t pgSize = pHandle->pageSize;
int32_t numOfRows = (pgSize - blockDataGetSerialMetaSize(pHandle->pDataBlock))/ blockDataGetSerialRowSize(pHandle->pDataBlock);
// blockDataEnsureCapacity(pHandle->pDataBlock, numOfRows); // useless, it is already enough
blockDataEnsureCapacity(pHandle->pDataBlock, numOfRows); // useless, it is already enough
size_t numOfSorted = taosArrayGetSize(pHandle->pOrderedSource);
for(int32_t t = 0; t < sortPass; ++t) {
......
......@@ -83,7 +83,7 @@ SSDataBlock* getSingleColStrBlock(void* param) {
SColumnInfoData colInfo = {0};
colInfo.info.type = TSDB_DATA_TYPE_NCHAR;
colInfo.info.bytes = TSDB_NCHAR_SIZE * 32;
colInfo.info.bytes = TSDB_NCHAR_SIZE * 16;
colInfo.info.colId = 1;
colInfo.varmeta.offset = static_cast<int32_t *>(taosMemoryCalloc(pInfo->pageRows, sizeof(int32_t)));
......@@ -92,7 +92,7 @@ SSDataBlock* getSingleColStrBlock(void* param) {
for (int32_t i = 0; i < pInfo->pageRows; ++i) {
SColumnInfoData* pColInfo = static_cast<SColumnInfoData*>(TARRAY_GET_ELEM(pBlock->pDataBlock, 0));
int32_t size = taosRand() % 32;
int32_t size = taosRand() % 16;
char str[64] = {0};
taosRandStr(varDataVal(str), size);
varDataSetLen(str, size);
......@@ -101,6 +101,8 @@ SSDataBlock* getSingleColStrBlock(void* param) {
pBlock->info.rows = pInfo->pageRows;
pBlock->info.numOfCols = 1;
pBlock->info.hasVarCol = true;
return pBlock;
}
......@@ -218,7 +220,7 @@ TEST(testCase, external_mem_sort_Test) {
SArray* orderInfo = taosArrayInit(1, sizeof(SBlockOrderInfo));
taosArrayPush(orderInfo, &oi);
SSortHandle* phandle = tsortCreateSortHandle(orderInfo, SORT_SINGLESOURCE_SORT, 32, 6, NULL, "test_abc");
SSortHandle* phandle = tsortCreateSortHandle(orderInfo, SORT_SINGLESOURCE_SORT, 128, 6, NULL, "test_abc");
tsortSetFetchRawDataFp(phandle, getSingleColDummyBlock);
_info* pInfo = (_info*) taosMemoryCalloc(1, sizeof(_info));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册