diff --git a/src/inc/tresultBuf.h b/src/inc/tresultBuf.h index b99c44e73fcbd834152640b80f8a59728c7cfd8f..90000e15e639cc64156f387b5c9d56653ee5a0ec 100644 --- a/src/inc/tresultBuf.h +++ b/src/inc/tresultBuf.h @@ -88,7 +88,7 @@ int32_t getNumOfResultBufGroupId(SQueryDiskbasedResultBuf* pResultBuf); * destroy result buffer * @param pResultBuf */ -void destroyResultBuf(SQueryDiskbasedResultBuf* pResultBuf); +void destroyDiskbasedResultBuf(SQueryDiskbasedResultBuf* pResultBuf); /** * diff --git a/src/system/detail/src/vnodeQueryImpl.c b/src/system/detail/src/vnodeQueryImpl.c index d748a3cd116397e6077a5db23134400a70d60dcf..9818c90fa513ae07128e89aa25c7aaa88ceb29c5 100644 --- a/src/system/detail/src/vnodeQueryImpl.c +++ b/src/system/detail/src/vnodeQueryImpl.c @@ -585,7 +585,7 @@ static void setExecParams(SQuery *pQuery, SQLFunctionCtx *pCtx, int64_t StartQue void createQueryResultInfo(SQuery *pQuery, SWindowResult *pResultRow, bool isSTableQuery, SPosInfo *posInfo); -static void destroyTimeWindowRes(SWindowResult *pOneOutputRes, int32_t nOutputCols); +static void destroyTimeWindowRes(SWindowResult *pWindowRes, int32_t nOutputCols); static int32_t binarySearchForBlockImpl(SCompBlock *pBlock, int32_t numOfBlocks, TSKEY skey, int32_t order) { int32_t firstSlot = 0; @@ -2020,10 +2020,6 @@ static bool needToLoadDataBlock(SQuery *pQuery, SField *pField, SQLFunctionCtx * int32_t initWindowResInfo(SWindowResInfo *pWindowResInfo, SQueryRuntimeEnv *pRuntimeEnv, int32_t size, int32_t threshold, int16_t type) { - if (size < threshold) { - size = threshold; - } - pWindowResInfo->capacity = size; pWindowResInfo->threshold = threshold; @@ -2037,7 +2033,7 @@ int32_t initWindowResInfo(SWindowResInfo *pWindowResInfo, SQueryRuntimeEnv *pRun // use the pointer arraylist pWindowResInfo->pResult = calloc(threshold, sizeof(SWindowResult)); - for (int32_t i = 0; i < threshold; ++i) { + for (int32_t i = 0; i < pWindowResInfo->capacity; ++i) { SPosInfo posInfo = {-1, -1}; createQueryResultInfo(pRuntimeEnv->pQuery, &pWindowResInfo->pResult[i], pRuntimeEnv->stableQuery, &posInfo); } @@ -2051,7 +2047,7 @@ void cleanupTimeWindowInfo(SWindowResInfo *pWindowResInfo, SQueryRuntimeEnv *pRu return; } - for (int32_t i = 0; i < pWindowResInfo->size; ++i) { + for (int32_t i = 0; i < pWindowResInfo->capacity; ++i) { SWindowResult *pResult = &pWindowResInfo->pResult[i]; destroyTimeWindowRes(pResult, pRuntimeEnv->pQuery->numOfOutputCols); } @@ -2905,7 +2901,8 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) { tfree(pRuntimeEnv->pInterpoBuf); } - + + destroyDiskbasedResultBuf(pRuntimeEnv->pResultBuf); pRuntimeEnv->pTSBuf = tsBufDestory(pRuntimeEnv->pTSBuf); } @@ -4516,19 +4513,19 @@ static void allocMemForInterpo(STableQuerySupportObj *pSupporter, SQuery *pQuery static int32_t getInitialPageNum(STableQuerySupportObj *pSupporter) { SQuery *pQuery = pSupporter->runtimeEnv.pQuery; - + int32_t INITIAL_RESULT_ROWS_VALUE = 16; + int32_t num = 0; if (isGroupbyNormalCol(pQuery->pGroupbyExpr)) { num = 128; } else if (isIntervalQuery(pQuery)) { // time window query, allocate one page for each table - num = pSupporter->numOfMeters; + num = MAX(pSupporter->numOfMeters, INITIAL_RESULT_ROWS_VALUE); } else { // for super table query, one page for each subset num = pSupporter->pSidSet->numOfSubSet; } assert(num > 0); - return num; } @@ -4828,20 +4825,6 @@ void vnodeQueryFreeQInfoEx(SQInfo *pQInfo) { pSupporter->pMetersHashTable = NULL; } - if (pSupporter->pSidSet != NULL || isGroupbyNormalCol(pQInfo->query.pGroupbyExpr) || - isIntervalQuery(pQuery)) { - int32_t size = 0; - if (isGroupbyNormalCol(pQInfo->query.pGroupbyExpr) || isIntervalQuery(pQuery)) { - size = 10000; - } else if (pSupporter->pSidSet != NULL) { - size = pSupporter->pSidSet->numOfSubSet; - } - - for (int32_t i = 0; i < size; ++i) { - // destroyTimeWindowRes(&pSupporter->pResult[i], pQInfo->query.numOfOutputCols); - } - } - tSidSetDestroy(&pSupporter->pSidSet); if (pSupporter->pMeterDataInfo != NULL) { diff --git a/src/util/src/tresultBuf.c b/src/util/src/tresultBuf.c index a7377f16575147934f68148adb2d16126288ffc9..8b719ee5444aab9723788718aba25a92c1ce9efc 100644 --- a/src/util/src/tresultBuf.c +++ b/src/util/src/tresultBuf.c @@ -189,7 +189,7 @@ SIDList getDataBufPagesIdList(SQueryDiskbasedResultBuf* pResultBuf, int32_t grou } } -void destroyResultBuf(SQueryDiskbasedResultBuf* pResultBuf) { +void destroyDiskbasedResultBuf(SQueryDiskbasedResultBuf* pResultBuf) { if (pResultBuf == NULL) { return; }