From b27bf263af954db61f835a998a3620f3fe284a15 Mon Sep 17 00:00:00 2001 From: slzhou Date: Tue, 30 Jan 2024 10:26:24 +0800 Subject: [PATCH] fix: calcualte row bytes once --- source/libs/executor/src/tsort.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/libs/executor/src/tsort.c b/source/libs/executor/src/tsort.c index 45dfa2e026..4e5cc37d99 100644 --- a/source/libs/executor/src/tsort.c +++ b/source/libs/executor/src/tsort.c @@ -78,6 +78,7 @@ struct SSortHandle { bool bSortByRowId; SDiskbasedBuf* pExtRowsBuf; + int32_t extRowBytes; int32_t extRowsPageSize; int32_t extRowsMemSize; int32_t srcTsSlotId; @@ -1006,7 +1007,7 @@ static int32_t blockRowToBuf(SSDataBlock* pBlock, int32_t rowIdx, char* buf) { static int32_t saveBlockRowToExtRowsBuf(SSortHandle* pHandle, SSDataBlock* pBlock, int32_t rowIdx, int32_t* pPageId, int32_t* pOffset, int32_t* pLength) { SDiskbasedBuf* pResultBuf = pHandle->pExtRowsBuf; - int32_t rowBytes = blockDataGetRowSize(pBlock) + taosArrayGetSize(pBlock->pDataBlock) + sizeof(int32_t); + int32_t rowBytes = pHandle->extRowBytes; int32_t pageId = -1; SFilePage* pFilePage = NULL; int32_t code = getPageFromExtSrcRowsBuf(pResultBuf, rowBytes, &pageId, &pFilePage); @@ -1082,6 +1083,7 @@ static void initRowIdSort(SSortHandle* pHandle) { int32_t tsortSetSortByRowId(SSortHandle* pHandle, int32_t extRowsPageSize, int32_t extRowsMemSize) { int32_t code = createDiskbasedBuf(&pHandle->pExtRowsBuf, extRowsPageSize, extRowsMemSize, "sort-ext-rows", tsTempDir); dBufSetPrintInfo(pHandle->pExtRowsBuf); + pHandle->extRowBytes = blockDataGetRowSize(pHandle->pDataBlock) + taosArrayGetSize(pHandle->pDataBlock->pDataBlock) + sizeof(int32_t); pHandle->extRowsPageSize = extRowsPageSize; pHandle->extRowsMemSize = extRowsMemSize; SBlockOrderInfo* pOrder = taosArrayGet(pHandle->pSortInfo, 0);