refactor(query): opt perf by remove some functions.
This commit is contained in:
parent
645c45a274
commit
0030c4b5ee
|
@ -133,6 +133,7 @@ typedef struct SqlFunctionCtx {
|
||||||
SResultDataInfo resDataInfo;
|
SResultDataInfo resDataInfo;
|
||||||
uint32_t order; // data block scanner order: asc|desc
|
uint32_t order; // data block scanner order: asc|desc
|
||||||
uint8_t isPseudoFunc;// denote current function is pseudo function or not [added for perf reason]
|
uint8_t isPseudoFunc;// denote current function is pseudo function or not [added for perf reason]
|
||||||
|
uint8_t isNotNullFunc;// not return null value.
|
||||||
uint8_t scanFlag; // record current running step, default: 0
|
uint8_t scanFlag; // record current running step, default: 0
|
||||||
int16_t functionId; // function id
|
int16_t functionId; // function id
|
||||||
char *pOutput; // final result output buffer, point to sdata->data
|
char *pOutput; // final result output buffer, point to sdata->data
|
||||||
|
|
|
@ -1543,6 +1543,7 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput,
|
||||||
SFuncExecEnv env = {0};
|
SFuncExecEnv env = {0};
|
||||||
pCtx->functionId = pExpr->pExpr->_function.pFunctNode->funcId;
|
pCtx->functionId = pExpr->pExpr->_function.pFunctNode->funcId;
|
||||||
pCtx->isPseudoFunc = fmIsWindowPseudoColumnFunc(pCtx->functionId);
|
pCtx->isPseudoFunc = fmIsWindowPseudoColumnFunc(pCtx->functionId);
|
||||||
|
pCtx->isNotNullFunc = fmIsNotNullOutputFunc(pCtx->functionId);
|
||||||
|
|
||||||
if (fmIsAggFunc(pCtx->functionId) || fmIsIndefiniteRowsFunc(pCtx->functionId)) {
|
if (fmIsAggFunc(pCtx->functionId) || fmIsIndefiniteRowsFunc(pCtx->functionId)) {
|
||||||
bool isUdaf = fmIsUserDefinedFunc(pCtx->functionId);
|
bool isUdaf = fmIsUserDefinedFunc(pCtx->functionId);
|
||||||
|
|
|
@ -1065,7 +1065,7 @@ static void doUpdateNumOfRows(SqlFunctionCtx* pCtx, SResultRow* pRow, int32_t nu
|
||||||
pRow->numOfRows = pResInfo->numOfRes;
|
pRow->numOfRows = pResInfo->numOfRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fmIsNotNullOutputFunc(pCtx[j].functionId)) {
|
if (pCtx[j].isNotNullFunc) {
|
||||||
returnNotNull = true;
|
returnNotNull = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -794,7 +794,8 @@ int32_t minmaxFunctionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
switch (pCol->info.type) {
|
switch (pCol->info.type) {
|
||||||
case TSDB_DATA_TYPE_UBIGINT:
|
case TSDB_DATA_TYPE_UBIGINT:
|
||||||
case TSDB_DATA_TYPE_BIGINT:
|
case TSDB_DATA_TYPE_BIGINT:
|
||||||
colDataAppendInt64(pCol, currentRow, &pRes->v);
|
((int64_t*)pCol->pData)[currentRow] = pRes->v;
|
||||||
|
// colDataAppendInt64(pCol, currentRow, &pRes->v);
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_UINT:
|
case TSDB_DATA_TYPE_UINT:
|
||||||
case TSDB_DATA_TYPE_INT:
|
case TSDB_DATA_TYPE_INT:
|
||||||
|
@ -822,10 +823,12 @@ int32_t minmaxFunctionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
colDataAppendNULL(pCol, currentRow);
|
colDataAppendNULL(pCol, currentRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pEntryInfo->numOfRes > 0) {
|
if (pCtx->subsidiaries.num > 0) {
|
||||||
code = setSelectivityValue(pCtx, pBlock, &pRes->tuplePos, currentRow);
|
if (pEntryInfo->numOfRes > 0) {
|
||||||
} else {
|
code = setSelectivityValue(pCtx, pBlock, &pRes->tuplePos, currentRow);
|
||||||
code = setSelectivityValue(pCtx, pBlock, &pRes->nullTuplePos, currentRow);
|
} else {
|
||||||
|
code = setSelectivityValue(pCtx, pBlock, &pRes->nullTuplePos, currentRow);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include "tpagedbuf.h"
|
#include "tpagedbuf.h"
|
||||||
#include "taoserror.h"
|
#include "taoserror.h"
|
||||||
#include "tcompression.h"
|
#include "tcompression.h"
|
||||||
#include "thash.h"
|
#include "tsimplehash.h"
|
||||||
#include "tlog.h"
|
#include "tlog.h"
|
||||||
|
|
||||||
#define GET_PAYLOAD_DATA(_p) ((char*)(_p)->pData + POINTER_BYTES)
|
#define GET_PAYLOAD_DATA(_p) ((char*)(_p)->pData + POINTER_BYTES)
|
||||||
|
@ -38,7 +38,7 @@ struct SDiskbasedBuf {
|
||||||
int32_t inMemPages; // numOfPages that are allocated in memory
|
int32_t inMemPages; // numOfPages that are allocated in memory
|
||||||
SList* freePgList; // free page list
|
SList* freePgList; // free page list
|
||||||
SArray* pIdList; // page id list
|
SArray* pIdList; // page id list
|
||||||
SHashObj* all;
|
SSHashObj*all;
|
||||||
SList* lruList;
|
SList* lruList;
|
||||||
void* emptyDummyIdList; // dummy id list
|
void* emptyDummyIdList; // dummy id list
|
||||||
void* assistBuf; // assistant buffer for compress/decompress data
|
void* assistBuf; // assistant buffer for compress/decompress data
|
||||||
|
@ -377,7 +377,7 @@ int32_t createDiskbasedBuf(SDiskbasedBuf** pBuf, int32_t pagesize, int32_t inMem
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
pPBuf->all = taosHashInit(10, fn, true, false);
|
pPBuf->all = tSimpleHashInit(20, fn);
|
||||||
if (pPBuf->all == NULL) {
|
if (pPBuf->all == NULL) {
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
@ -438,7 +438,7 @@ void* getNewBufPage(SDiskbasedBuf* pBuf, int32_t* pageId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// add to hash map
|
// add to hash map
|
||||||
taosHashPut(pBuf->all, pageId, sizeof(int32_t), &pi, POINTER_BYTES);
|
tSimpleHashPut(pBuf->all, pageId, sizeof(int32_t), &pi, POINTER_BYTES);
|
||||||
pBuf->totalBufSize += pBuf->pageSize;
|
pBuf->totalBufSize += pBuf->pageSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -463,7 +463,7 @@ void* getBufPage(SDiskbasedBuf* pBuf, int32_t id) {
|
||||||
|
|
||||||
pBuf->statis.getPages += 1;
|
pBuf->statis.getPages += 1;
|
||||||
|
|
||||||
SPageInfo** pi = taosHashGet(pBuf->all, &id, sizeof(int32_t));
|
SPageInfo** pi = tSimpleHashGet(pBuf->all, &id, sizeof(int32_t));
|
||||||
if (pi == NULL || *pi == NULL) {
|
if (pi == NULL || *pi == NULL) {
|
||||||
uError("failed to locate the buffer page:%d, %s", id, pBuf->id);
|
uError("failed to locate the buffer page:%d, %s", id, pBuf->id);
|
||||||
terrno = TSDB_CODE_INVALID_PARA;
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
|
@ -615,7 +615,7 @@ void destroyDiskbasedBuf(SDiskbasedBuf* pBuf) {
|
||||||
taosArrayDestroy(pBuf->emptyDummyIdList);
|
taosArrayDestroy(pBuf->emptyDummyIdList);
|
||||||
taosArrayDestroy(pBuf->pFree);
|
taosArrayDestroy(pBuf->pFree);
|
||||||
|
|
||||||
taosHashCleanup(pBuf->all);
|
tSimpleHashCleanup(pBuf->all);
|
||||||
|
|
||||||
taosMemoryFreeClear(pBuf->id);
|
taosMemoryFreeClear(pBuf->id);
|
||||||
taosMemoryFreeClear(pBuf->assistBuf);
|
taosMemoryFreeClear(pBuf->assistBuf);
|
||||||
|
@ -711,7 +711,7 @@ void clearDiskbasedBuf(SDiskbasedBuf* pBuf) {
|
||||||
taosArrayClear(pBuf->emptyDummyIdList);
|
taosArrayClear(pBuf->emptyDummyIdList);
|
||||||
taosArrayClear(pBuf->pFree);
|
taosArrayClear(pBuf->pFree);
|
||||||
|
|
||||||
taosHashClear(pBuf->all);
|
tSimpleHashClear(pBuf->all);
|
||||||
|
|
||||||
pBuf->numOfPages = 0; // all pages are in buffer in the first place
|
pBuf->numOfPages = 0; // all pages are in buffer in the first place
|
||||||
pBuf->totalBufSize = 0;
|
pBuf->totalBufSize = 0;
|
||||||
|
|
Loading…
Reference in New Issue