From a2092892f720be22f1699e8eac19d69cae971c60 Mon Sep 17 00:00:00 2001 From: kailixu Date: Thu, 8 Dec 2022 14:43:48 +0800 Subject: [PATCH] refact: tsma/rsma code optimization --- source/common/src/tdatablock.c | 18 +++++++++--------- source/dnode/vnode/src/sma/smaRollup.c | 6 +++++- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 84758a08c7..a47e52b84c 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -2246,17 +2246,17 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq2** ppReq, const SSDataBlock* pDat continue; } - SSubmitTbData pTbData = {0}; + SSubmitTbData tbData = {0}; - if (!(pTbData.aRowP = taosArrayInit(rows, sizeof(SRow*)))) { + if (!(tbData.aRowP = taosArrayInit(rows, sizeof(SRow*)))) { goto _end; } - pTbData.suid = suid; - pTbData.uid = pDataBlock->info.id.groupId; - pTbData.sver = pTSchema->version; + tbData.suid = suid; + tbData.uid = pDataBlock->info.id.groupId; + tbData.sver = pTSchema->version; if (!pVals && !(pVals = taosArrayInit(colNum, sizeof(SColVal)))) { - taosArrayDestroy(pTbData.aRowP); + taosArrayDestroy(tbData.aRowP); goto _end; } @@ -2354,14 +2354,14 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq2** ppReq, const SSDataBlock* pDat } SRow* pRow = NULL; if ((terrno = tRowBuild(pVals, pTSchema, &pRow)) < 0) { - tDestroySSubmitTbData(&pTbData, TSDB_MSG_FLG_ENCODE); + tDestroySSubmitTbData(&tbData, TSDB_MSG_FLG_ENCODE); goto _end; } ASSERT(pRow); - taosArrayPush(pTbData.aRowP, &pRow); + taosArrayPush(tbData.aRowP, &pRow); } - taosArrayPush(pReq->aSubmitTbData, &pTbData); + taosArrayPush(pReq->aSubmitTbData, &tbData); } _end: taosArrayDestroy(pVals); diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index ec3bae7415..bc8a3e8513 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -714,6 +714,7 @@ static int32_t tdRSmaExecAndSubmitResult(SSma *pSma, qTaskInfo_t taskInfo, SRSma if (pReq && tdProcessSubmitReq(sinkTsdb, output->info.version, pReq) < 0) { tDestroySSubmitReq2(pReq, TSDB_MSG_FLG_ENCODE); + taosMemoryFree(pReq); smaError("vgId:%d, process submit req for rsma suid:%" PRIu64 ", uid:%" PRIu64 " level %" PRIi8 " failed since %s", SMA_VID(pSma), suid, output->info.id.groupId, pItem->level, terrstr()); @@ -723,7 +724,10 @@ static int32_t tdRSmaExecAndSubmitResult(SSma *pSma, qTaskInfo_t taskInfo, SRSma smaDebug("vgId:%d, process submit req for rsma suid:%" PRIu64 ",uid:%" PRIu64 ", level %" PRIi8 " ver %" PRIi64, SMA_VID(pSma), suid, output->info.id.groupId, pItem->level, output->info.version); - if (pReq) tDestroySSubmitReq2(pReq, TSDB_MSG_FLG_ENCODE); + if (pReq) { + tDestroySSubmitReq2(pReq, TSDB_MSG_FLG_ENCODE); + taosMemoryFree(pReq); + } } } -- GitLab