From 79625df5e4dac8f906e39ca3597c04df579f92b7 Mon Sep 17 00:00:00 2001 From: kailixu Date: Thu, 8 Jun 2023 18:39:51 +0800 Subject: [PATCH] chore: code optimization --- source/libs/planner/src/planLogicCreater.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 5a8512c12d..953ca13d3b 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -732,25 +732,25 @@ static int32_t createInterpFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt* p return code; } -static int32_t eraseDuplicatedWindowPseudoCol(SWindowLogicNode* pWindow, SNodeList* pProjections) { +static int32_t eraseDuplicatedPseudoColumnFuncs(SNodeList* pFuncs, SNodeList* pProjections) { int32_t code = 0; int32_t funcIndex = 0; - SSHashObj* pHashFunc = NULL; + SSHashObj* pFuncHash = NULL; SNode* pFuncNode = NULL; - FOREACH(pFuncNode, pWindow->pFuncs) { + FOREACH(pFuncNode, pFuncs) { SFunctionNode* pFunc = (SFunctionNode*)pFuncNode; if (!fmIsWindowPseudoColumnFunc(pFunc->funcId)) { ++funcIndex; continue; } - if (!pHashFunc && !(pHashFunc = tSimpleHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT)))) { + if (!pFuncHash && !(pFuncHash = tSimpleHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT)))) { code = TSDB_CODE_OUT_OF_MEMORY; break; } - void* hashVal = tSimpleHashGet(pHashFunc, &pFunc->funcId, sizeof(pFunc->funcId)); + void* hashVal = tSimpleHashGet(pFuncHash, &pFunc->funcId, sizeof(pFunc->funcId)); if (!hashVal) { - tSimpleHashPut(pHashFunc, &pFunc->funcId, sizeof(pFunc->funcId), &funcIndex, sizeof(funcIndex)); + tSimpleHashPut(pFuncHash, &pFunc->funcId, sizeof(pFunc->funcId), &funcIndex, sizeof(funcIndex)); ++funcIndex; continue; } @@ -765,13 +765,13 @@ static int32_t eraseDuplicatedWindowPseudoCol(SWindowLogicNode* pWindow, SNodeLi } } if (!exist) { - nodesListErase(pWindow->pFuncs, nodesListGetCell(pWindow->pFuncs, funcIndex)); + nodesListErase(pFuncs, nodesListGetCell(pFuncs, funcIndex)); } else { - nodesListErase(pWindow->pFuncs, nodesListGetCell(pWindow->pFuncs, *(int32_t*)hashVal)); - tSimpleHashPut(pHashFunc, &pFunc->funcId, sizeof(pFunc->funcId), &funcIndex, sizeof(funcIndex)); + nodesListErase(pFuncs, nodesListGetCell(pFuncs, *(int32_t*)hashVal)); + tSimpleHashPut(pFuncHash, &pFunc->funcId, sizeof(pFunc->funcId), &funcIndex, sizeof(funcIndex)); } } - tSimpleHashCleanup(pHashFunc); + tSimpleHashCleanup(pFuncHash); return code; } @@ -794,7 +794,7 @@ static int32_t createWindowLogicNodeFinalize(SLogicPlanContext* pCxt, SSelectStm if (TSDB_CODE_SUCCESS == code && WINDOW_TYPE_INTERVAL == pWindow->winType && pSelect->pProjectionList) { // erase duplicated Window Pseudo funcNode by filtering colNode in pSelect->pProjectionList - code = eraseDuplicatedWindowPseudoCol(pWindow, pSelect->pProjectionList); + code = eraseDuplicatedPseudoColumnFuncs(pWindow->pFuncs, pSelect->pProjectionList); } if (TSDB_CODE_SUCCESS == code) { -- GitLab