fix error in order by logic
This commit is contained in:
parent
155b14388b
commit
e7585db216
|
@ -6513,9 +6513,9 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSDataBlock* pR
|
||||||
return NULL;
|
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->numOfRowsInRes = 1024;
|
||||||
pInfo->pDataBlock = pResBlock;
|
pInfo->pDataBlock = pResBlock;
|
||||||
pInfo->pSortInfo = pSortInfo;
|
pInfo->pSortInfo = pSortInfo;
|
||||||
|
|
|
@ -141,8 +141,8 @@ static int32_t doAddNewExternalMemSource(SDiskbasedBuf *pBuf, SArray* pAllSource
|
||||||
(*sourceId) += 1;
|
(*sourceId) += 1;
|
||||||
|
|
||||||
int32_t rowSize = blockDataGetSerialRowSize(pSource->src.pBlock);
|
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);
|
return blockDataEnsureCapacity(pSource->src.pBlock, numOfRows);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,7 +421,7 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) {
|
||||||
size_t pgSize = pHandle->pageSize;
|
size_t pgSize = pHandle->pageSize;
|
||||||
int32_t numOfRows = (pgSize - blockDataGetSerialMetaSize(pHandle->pDataBlock))/ blockDataGetSerialRowSize(pHandle->pDataBlock);
|
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);
|
size_t numOfSorted = taosArrayGetSize(pHandle->pOrderedSource);
|
||||||
for(int32_t t = 0; t < sortPass; ++t) {
|
for(int32_t t = 0; t < sortPass; ++t) {
|
||||||
|
|
|
@ -83,7 +83,7 @@ SSDataBlock* getSingleColStrBlock(void* param) {
|
||||||
|
|
||||||
SColumnInfoData colInfo = {0};
|
SColumnInfoData colInfo = {0};
|
||||||
colInfo.info.type = TSDB_DATA_TYPE_NCHAR;
|
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.info.colId = 1;
|
||||||
colInfo.varmeta.offset = static_cast<int32_t *>(taosMemoryCalloc(pInfo->pageRows, sizeof(int32_t)));
|
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) {
|
for (int32_t i = 0; i < pInfo->pageRows; ++i) {
|
||||||
SColumnInfoData* pColInfo = static_cast<SColumnInfoData*>(TARRAY_GET_ELEM(pBlock->pDataBlock, 0));
|
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};
|
char str[64] = {0};
|
||||||
taosRandStr(varDataVal(str), size);
|
taosRandStr(varDataVal(str), size);
|
||||||
varDataSetLen(str, size);
|
varDataSetLen(str, size);
|
||||||
|
@ -101,6 +101,8 @@ SSDataBlock* getSingleColStrBlock(void* param) {
|
||||||
|
|
||||||
pBlock->info.rows = pInfo->pageRows;
|
pBlock->info.rows = pInfo->pageRows;
|
||||||
pBlock->info.numOfCols = 1;
|
pBlock->info.numOfCols = 1;
|
||||||
|
pBlock->info.hasVarCol = true;
|
||||||
|
|
||||||
return pBlock;
|
return pBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +220,7 @@ TEST(testCase, external_mem_sort_Test) {
|
||||||
SArray* orderInfo = taosArrayInit(1, sizeof(SBlockOrderInfo));
|
SArray* orderInfo = taosArrayInit(1, sizeof(SBlockOrderInfo));
|
||||||
taosArrayPush(orderInfo, &oi);
|
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);
|
tsortSetFetchRawDataFp(phandle, getSingleColDummyBlock);
|
||||||
|
|
||||||
_info* pInfo = (_info*) taosMemoryCalloc(1, sizeof(_info));
|
_info* pInfo = (_info*) taosMemoryCalloc(1, sizeof(_info));
|
||||||
|
|
Loading…
Reference in New Issue