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;
|
||||
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 isNotNullFunc;// not return null value.
|
||||
uint8_t scanFlag; // record current running step, default: 0
|
||||
int16_t functionId; // function id
|
||||
char *pOutput; // final result output buffer, point to sdata->data
|
||||
|
|
|
@ -1543,6 +1543,7 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput,
|
|||
SFuncExecEnv env = {0};
|
||||
pCtx->functionId = pExpr->pExpr->_function.pFunctNode->funcId;
|
||||
pCtx->isPseudoFunc = fmIsWindowPseudoColumnFunc(pCtx->functionId);
|
||||
pCtx->isNotNullFunc = fmIsNotNullOutputFunc(pCtx->functionId);
|
||||
|
||||
if (fmIsAggFunc(pCtx->functionId) || fmIsIndefiniteRowsFunc(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;
|
||||
}
|
||||
|
||||
if (fmIsNotNullOutputFunc(pCtx[j].functionId)) {
|
||||
if (pCtx[j].isNotNullFunc) {
|
||||
returnNotNull = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -794,7 +794,8 @@ int32_t minmaxFunctionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
|||
switch (pCol->info.type) {
|
||||
case TSDB_DATA_TYPE_UBIGINT:
|
||||
case TSDB_DATA_TYPE_BIGINT:
|
||||
colDataAppendInt64(pCol, currentRow, &pRes->v);
|
||||
((int64_t*)pCol->pData)[currentRow] = pRes->v;
|
||||
// colDataAppendInt64(pCol, currentRow, &pRes->v);
|
||||
break;
|
||||
case TSDB_DATA_TYPE_UINT:
|
||||
case TSDB_DATA_TYPE_INT:
|
||||
|
@ -822,10 +823,12 @@ int32_t minmaxFunctionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
|||
colDataAppendNULL(pCol, currentRow);
|
||||
}
|
||||
|
||||
if (pEntryInfo->numOfRes > 0) {
|
||||
code = setSelectivityValue(pCtx, pBlock, &pRes->tuplePos, currentRow);
|
||||
} else {
|
||||
code = setSelectivityValue(pCtx, pBlock, &pRes->nullTuplePos, currentRow);
|
||||
if (pCtx->subsidiaries.num > 0) {
|
||||
if (pEntryInfo->numOfRes > 0) {
|
||||
code = setSelectivityValue(pCtx, pBlock, &pRes->tuplePos, currentRow);
|
||||
} else {
|
||||
code = setSelectivityValue(pCtx, pBlock, &pRes->nullTuplePos, currentRow);
|
||||
}
|
||||
}
|
||||
|
||||
return code;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "tpagedbuf.h"
|
||||
#include "taoserror.h"
|
||||
#include "tcompression.h"
|
||||
#include "thash.h"
|
||||
#include "tsimplehash.h"
|
||||
#include "tlog.h"
|
||||
|
||||
#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
|
||||
SList* freePgList; // free page list
|
||||
SArray* pIdList; // page id list
|
||||
SHashObj* all;
|
||||
SSHashObj*all;
|
||||
SList* lruList;
|
||||
void* emptyDummyIdList; // dummy id list
|
||||
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;
|
||||
}
|
||||
|
||||
pPBuf->all = taosHashInit(10, fn, true, false);
|
||||
pPBuf->all = tSimpleHashInit(20, fn);
|
||||
if (pPBuf->all == NULL) {
|
||||
goto _error;
|
||||
}
|
||||
|
@ -438,7 +438,7 @@ void* getNewBufPage(SDiskbasedBuf* pBuf, int32_t* pageId) {
|
|||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
@ -463,7 +463,7 @@ void* getBufPage(SDiskbasedBuf* pBuf, int32_t id) {
|
|||
|
||||
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) {
|
||||
uError("failed to locate the buffer page:%d, %s", id, pBuf->id);
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
|
@ -615,7 +615,7 @@ void destroyDiskbasedBuf(SDiskbasedBuf* pBuf) {
|
|||
taosArrayDestroy(pBuf->emptyDummyIdList);
|
||||
taosArrayDestroy(pBuf->pFree);
|
||||
|
||||
taosHashCleanup(pBuf->all);
|
||||
tSimpleHashCleanup(pBuf->all);
|
||||
|
||||
taosMemoryFreeClear(pBuf->id);
|
||||
taosMemoryFreeClear(pBuf->assistBuf);
|
||||
|
@ -711,7 +711,7 @@ void clearDiskbasedBuf(SDiskbasedBuf* pBuf) {
|
|||
taosArrayClear(pBuf->emptyDummyIdList);
|
||||
taosArrayClear(pBuf->pFree);
|
||||
|
||||
taosHashClear(pBuf->all);
|
||||
tSimpleHashClear(pBuf->all);
|
||||
|
||||
pBuf->numOfPages = 0; // all pages are in buffer in the first place
|
||||
pBuf->totalBufSize = 0;
|
||||
|
|
Loading…
Reference in New Issue