refactor: adjust log.

This commit is contained in:
Haojun Liao 2024-09-06 13:58:03 +08:00
parent 482eab9666
commit 8a1d527da9
1 changed files with 19 additions and 17 deletions

View File

@ -79,9 +79,8 @@ struct SSortHandle {
bool forceUsePQSort; bool forceUsePQSort;
BoundedQueue* pBoundedQueue; BoundedQueue* pBoundedQueue;
uint32_t tmpRowIdx; uint32_t tmpRowIdx;
int64_t mergeLimit;
int64_t mergeLimit; int64_t currMergeLimitTs;
int64_t currMergeLimitTs;
int32_t sourceId; int32_t sourceId;
SSDataBlock* pDataBlock; SSDataBlock* pDataBlock;
@ -2380,19 +2379,22 @@ static int32_t createBlocksMergeSortInitialSources(SSortHandle* pHandle) {
return code; return code;
} }
static void freeSSortSource(SSortSource* source) { static void freeSortSource(SSortSource* pSource) {
if (NULL == source) { if (NULL == pSource) {
return; return;
} }
if (source->param && !source->onlyRef) { if (!pSource->onlyRef && pSource->param) {
taosMemoryFree(source->param); taosMemoryFree(pSource->param);
} }
if (!source->onlyRef && source->src.pBlock) {
blockDataDestroy(source->src.pBlock); if (!pSource->onlyRef && pSource->src.pBlock) {
source->src.pBlock = NULL; blockDataDestroy(pSource->src.pBlock);
pSource->src.pBlock = NULL;
} }
taosMemoryFree(source);
qInfo("---free-single:%p", pSource);
taosMemoryFree(pSource);
} }
static int32_t createBlocksQuickSortInitialSources(SSortHandle* pHandle) { static int32_t createBlocksQuickSortInitialSources(SSortHandle* pHandle) {
@ -2424,7 +2426,7 @@ static int32_t createBlocksQuickSortInitialSources(SSortHandle* pHandle) {
sortBufSize = pHandle->numOfPages * pHandle->pageSize; sortBufSize = pHandle->numOfPages * pHandle->pageSize;
code = createOneDataBlock(pBlock, false, &pHandle->pDataBlock); code = createOneDataBlock(pBlock, false, &pHandle->pDataBlock);
if (code) { if (code) {
freeSSortSource(pSource); freeSortSource(pSource);
return code; return code;
} }
} }
@ -2435,7 +2437,7 @@ static int32_t createBlocksQuickSortInitialSources(SSortHandle* pHandle) {
code = blockDataMerge(pHandle->pDataBlock, pBlock); code = blockDataMerge(pHandle->pDataBlock, pBlock);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
freeSSortSource(pSource); freeSortSource(pSource);
return code; return code;
} }
@ -2445,7 +2447,7 @@ static int32_t createBlocksQuickSortInitialSources(SSortHandle* pHandle) {
int64_t st = taosGetTimestampUs(); int64_t st = taosGetTimestampUs();
code = blockDataSort(pHandle->pDataBlock, pHandle->pSortInfo); code = blockDataSort(pHandle->pDataBlock, pHandle->pSortInfo);
if (code != 0) { if (code != 0) {
freeSSortSource(pSource); freeSortSource(pSource);
return code; return code;
} }
@ -2454,13 +2456,13 @@ static int32_t createBlocksQuickSortInitialSources(SSortHandle* pHandle) {
if (pHandle->pqMaxRows > 0) blockDataKeepFirstNRows(pHandle->pDataBlock, pHandle->pqMaxRows); if (pHandle->pqMaxRows > 0) blockDataKeepFirstNRows(pHandle->pDataBlock, pHandle->pqMaxRows);
code = doAddToBuf(pHandle->pDataBlock, pHandle); code = doAddToBuf(pHandle->pDataBlock, pHandle);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
freeSSortSource(pSource); freeSortSource(pSource);
return code; return code;
} }
} }
} }
freeSSortSource(pSource); freeSortSource(pSource);
if (pHandle->pDataBlock != NULL && pHandle->pDataBlock->info.rows > 0) { if (pHandle->pDataBlock != NULL && pHandle->pDataBlock->info.rows > 0) {
size_t size = blockDataGetSize(pHandle->pDataBlock); size_t size = blockDataGetSize(pHandle->pDataBlock);
@ -2501,7 +2503,7 @@ static int32_t createInitialSources(SSortHandle* pHandle) {
code = createBlocksMergeSortInitialSources(pHandle); code = createBlocksMergeSortInitialSources(pHandle);
} }
qDebug("%zu sources created", taosArrayGetSize(pHandle->pOrderedSource)); qDebug("%s %zu sources created", pHandle->idStr, taosArrayGetSize(pHandle->pOrderedSource));
return code; return code;
} }