enh(query): improve the perf.

This commit is contained in:
Haojun Liao 2022-11-08 14:54:42 +08:00
parent 032208e36a
commit b0a54d3fab
2 changed files with 5 additions and 1 deletions

View File

@ -985,6 +985,8 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
uint8_t* p = pData->pData + tDataTypes[pData->type].bytes * pDumpInfo->rowIndex; uint8_t* p = pData->pData + tDataTypes[pData->type].bytes * pDumpInfo->rowIndex;
memcpy(pColData->pData, p, remain * tDataTypes[pData->type].bytes); memcpy(pColData->pData, p, remain * tDataTypes[pData->type].bytes);
ASSERT((((uint64_t)pColData->pData) & (0x8 - 1)) == 0); // make sure it is aligned to 8bit
// null value exists, check one-by-one // null value exists, check one-by-one
if (pData->flag != HAS_VALUE) { if (pData->flag != HAS_VALUE) {
for (int32_t j = pDumpInfo->rowIndex; rowIndex < remain; j += step, rowIndex++) { for (int32_t j = pDumpInfo->rowIndex; rowIndex < remain; j += step, rowIndex++) {

View File

@ -906,6 +906,7 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
case TSDB_DATA_TYPE_FLOAT: { case TSDB_DATA_TYPE_FLOAT: {
float* plist = (float*)pCol->pData; float* plist = (float*)pCol->pData;
float val = 0;
for (int32_t i = start; i < numOfRows + pInput->startRowIndex; ++i) { for (int32_t i = start; i < numOfRows + pInput->startRowIndex; ++i) {
if (pCol->hasNull && colDataIsNull_f(pCol->nullbitmap, i)) { if (pCol->hasNull && colDataIsNull_f(pCol->nullbitmap, i)) {
continue; continue;
@ -913,8 +914,9 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) {
numOfElem += 1; numOfElem += 1;
pAvgRes->count += 1; pAvgRes->count += 1;
pAvgRes->sum.dsum += plist[i]; val += plist[i];
} }
pAvgRes->sum.dsum = val;
break; break;
} }