enh:[TD-32158] Free memory only when function need cleanup.
This commit is contained in:
parent
122b707ac8
commit
ad7b2ddc1b
|
@ -258,6 +258,7 @@ typedef struct SqlFunctionCtx {
|
|||
SFuncInputRowIter rowIter;
|
||||
bool bInputFinished;
|
||||
bool hasWindowOrGroup; // denote that the function is used with time window or group
|
||||
bool needCleanup; // denote that the function need to be cleaned up
|
||||
} SqlFunctionCtx;
|
||||
|
||||
typedef struct tExprNode {
|
||||
|
|
|
@ -592,8 +592,15 @@ void cleanupResultInfoInStream(SExecTaskInfo* pTaskInfo, void* pState, SExprSupp
|
|||
int32_t numOfExprs = pSup->numOfExprs;
|
||||
int32_t* rowEntryOffset = pSup->rowEntryInfoOffset;
|
||||
SqlFunctionCtx* pCtx = pSup->pCtx;
|
||||
|
||||
int32_t numOfRows = getNumOfTotalRes(pGroupResInfo);
|
||||
bool needCleanup = false;
|
||||
|
||||
for (int32_t j = 0; j < numOfExprs; ++j) {
|
||||
needCleanup |= pCtx[j].needCleanup;
|
||||
}
|
||||
if (!needCleanup) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int32_t i = pGroupResInfo->index; i < numOfRows; i += 1) {
|
||||
SResultWindowInfo* pWinInfo = taosArrayGet(pGroupResInfo->pRows, i);
|
||||
|
@ -620,6 +627,13 @@ void cleanupResultInfo(SExecTaskInfo* pTaskInfo, SExprSupp* pSup, SDiskbasedBuf*
|
|||
int32_t numOfExprs = pSup->numOfExprs;
|
||||
int32_t* rowEntryOffset = pSup->rowEntryInfoOffset;
|
||||
SqlFunctionCtx* pCtx = pSup->pCtx;
|
||||
bool needCleanup = false;
|
||||
for (int32_t j = 0; j < numOfExprs; ++j) {
|
||||
needCleanup |= pCtx[j].needCleanup;
|
||||
}
|
||||
if (!needCleanup) {
|
||||
return;
|
||||
}
|
||||
|
||||
// begin from last iter
|
||||
void* pData = pGroupResInfo->dataPos;
|
||||
|
|
|
@ -2111,6 +2111,7 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput,
|
|||
pCtx->saveHandle.currentPage = -1;
|
||||
pCtx->pStore = pStore;
|
||||
pCtx->hasWindowOrGroup = false;
|
||||
pCtx->needCleanup = false;
|
||||
}
|
||||
|
||||
for (int32_t i = 1; i < numOfOutput; ++i) {
|
||||
|
|
|
@ -2114,6 +2114,7 @@ int32_t percentileFunction(SqlFunctionCtx* pCtx) {
|
|||
SET_VAL(pResInfo, numOfElems, 1);
|
||||
}
|
||||
|
||||
pCtx->needCleanup = true;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -6078,6 +6079,7 @@ int32_t modeFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) {
|
|||
pInfo->pHash = NULL;
|
||||
return terrno;
|
||||
}
|
||||
pCtx->needCleanup = true;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue