enh(query): optimize the data block load algorithm in table scan operator.
This commit is contained in:
parent
59de47a714
commit
d40f830b77
|
@ -1093,13 +1093,6 @@ static void doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx,
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// in case of the block distribution query, the inputBytes is not a constant value.
|
|
||||||
//pCtx[i].input.pData[0] = taosArrayGet(pBlock->pDataBlock, slotId);
|
|
||||||
//pCtx[i].input.totalRows = pBlock->info.rows;
|
|
||||||
//pCtx[i].input.numOfRows = pBlock->info.rows;
|
|
||||||
//pCtx[i].input.startRowIndex = 0;
|
|
||||||
|
|
||||||
|
|
||||||
// uint32_t status = aAggs[pCtx[i].functionId].status;
|
// uint32_t status = aAggs[pCtx[i].functionId].status;
|
||||||
// if ((status & (FUNCSTATE_SELECTIVITY | FUNCSTATE_NEED_TS)) != 0) {
|
// if ((status & (FUNCSTATE_SELECTIVITY | FUNCSTATE_NEED_TS)) != 0) {
|
||||||
// SColumnInfoData* tsInfo = taosArrayGet(pBlock->pDataBlock, 0);
|
// SColumnInfoData* tsInfo = taosArrayGet(pBlock->pDataBlock, 0);
|
||||||
|
@ -1754,6 +1747,10 @@ void setBlockStatisInfo(SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, SSDataBlock*
|
||||||
pInput->colDataAggIsSet = true;
|
pInput->colDataAggIsSet = true;
|
||||||
pInput->numOfRows = pBlock->info.rows;
|
pInput->numOfRows = pBlock->info.rows;
|
||||||
pInput->totalRows = pBlock->info.rows;
|
pInput->totalRows = pBlock->info.rows;
|
||||||
|
|
||||||
|
// Here we set the column info data since the data type for each column data is required, but
|
||||||
|
// the data in the corresponding SColumnInfoData will not be used.
|
||||||
|
pInput->pData[j] = taosArrayGet(pBlock->pDataBlock, slotId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -399,7 +399,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
{
|
{
|
||||||
.name = "sum",
|
.name = "sum",
|
||||||
.type = FUNCTION_TYPE_SUM,
|
.type = FUNCTION_TYPE_SUM,
|
||||||
.classification = FUNC_MGT_AGG_FUNC,
|
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED,
|
||||||
.translateFunc = translateSum,
|
.translateFunc = translateSum,
|
||||||
.dataRequiredFunc = statisDataRequired,
|
.dataRequiredFunc = statisDataRequired,
|
||||||
.getEnvFunc = getSumFuncEnv,
|
.getEnvFunc = getSumFuncEnv,
|
||||||
|
@ -410,7 +410,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
{
|
{
|
||||||
.name = "min",
|
.name = "min",
|
||||||
.type = FUNCTION_TYPE_MIN,
|
.type = FUNCTION_TYPE_MIN,
|
||||||
.classification = FUNC_MGT_AGG_FUNC,
|
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED,
|
||||||
.translateFunc = translateInOutNum,
|
.translateFunc = translateInOutNum,
|
||||||
.dataRequiredFunc = statisDataRequired,
|
.dataRequiredFunc = statisDataRequired,
|
||||||
.getEnvFunc = getMinmaxFuncEnv,
|
.getEnvFunc = getMinmaxFuncEnv,
|
||||||
|
@ -421,7 +421,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
{
|
{
|
||||||
.name = "max",
|
.name = "max",
|
||||||
.type = FUNCTION_TYPE_MAX,
|
.type = FUNCTION_TYPE_MAX,
|
||||||
.classification = FUNC_MGT_AGG_FUNC,
|
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED,
|
||||||
.translateFunc = translateInOutNum,
|
.translateFunc = translateInOutNum,
|
||||||
.dataRequiredFunc = statisDataRequired,
|
.dataRequiredFunc = statisDataRequired,
|
||||||
.getEnvFunc = getMinmaxFuncEnv,
|
.getEnvFunc = getMinmaxFuncEnv,
|
||||||
|
|
|
@ -361,20 +361,15 @@ int32_t doMinMaxHelper(SqlFunctionCtx *pCtx, int32_t isMinFunc) {
|
||||||
index = pInput->pColumnDataAgg[0]->maxIndex;
|
index = pInput->pColumnDataAgg[0]->maxIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
TSKEY key = TSKEY_INITIAL_VAL;
|
|
||||||
if (pCtx->ptsList != NULL) {
|
|
||||||
// the index is the original position, not the relative position
|
// the index is the original position, not the relative position
|
||||||
key = pCtx->ptsList[index];
|
TSKEY key = (pCtx->ptsList != NULL)? pCtx->ptsList[index]:TSKEY_INITIAL_VAL;
|
||||||
}
|
|
||||||
|
|
||||||
if (IS_SIGNED_NUMERIC_TYPE(type)) {
|
if (IS_SIGNED_NUMERIC_TYPE(type)) {
|
||||||
|
int64_t prev = 0;
|
||||||
|
GET_TYPED_DATA(prev, int64_t, type, buf);
|
||||||
|
|
||||||
int64_t val = GET_INT64_VAL(tval);
|
int64_t val = GET_INT64_VAL(tval);
|
||||||
|
if ((prev < val) ^ isMinFunc) {
|
||||||
#if defined(_DEBUG_VIEW)
|
|
||||||
qDebug("max value updated according to pre-cal:%d", *data);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ((*(int64_t*)buf < val) ^ isMinFunc) {
|
|
||||||
*(int64_t*) buf = val;
|
*(int64_t*) buf = val;
|
||||||
for (int32_t i = 0; i < (pCtx)->subsidiaryRes.numOfCols; ++i) {
|
for (int32_t i = 0; i < (pCtx)->subsidiaryRes.numOfCols; ++i) {
|
||||||
SqlFunctionCtx* __ctx = pCtx->subsidiaryRes.pCtx[i];
|
SqlFunctionCtx* __ctx = pCtx->subsidiaryRes.pCtx[i];
|
||||||
|
@ -387,14 +382,23 @@ int32_t doMinMaxHelper(SqlFunctionCtx *pCtx, int32_t isMinFunc) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
|
} else if (IS_UNSIGNED_NUMERIC_TYPE(type)) {
|
||||||
|
uint64_t prev = 0;
|
||||||
|
GET_TYPED_DATA(prev, uint64_t, type, buf);
|
||||||
|
|
||||||
uint64_t val = GET_UINT64_VAL(tval);
|
uint64_t val = GET_UINT64_VAL(tval);
|
||||||
UPDATE_DATA(pCtx, *(uint64_t*)buf, val, numOfElems, isMinFunc, key);
|
UPDATE_DATA(pCtx, prev, val, numOfElems, isMinFunc, key);
|
||||||
} else if (type == TSDB_DATA_TYPE_DOUBLE) {
|
} else if (type == TSDB_DATA_TYPE_DOUBLE) {
|
||||||
|
double prev = 0;
|
||||||
|
GET_TYPED_DATA(prev, double, type, buf);
|
||||||
|
|
||||||
double val = GET_DOUBLE_VAL(tval);
|
double val = GET_DOUBLE_VAL(tval);
|
||||||
UPDATE_DATA(pCtx, *(double*)buf, val, numOfElems, isMinFunc, key);
|
UPDATE_DATA(pCtx, prev, val, numOfElems, isMinFunc, key);
|
||||||
} else if (type == TSDB_DATA_TYPE_FLOAT) {
|
} else if (type == TSDB_DATA_TYPE_FLOAT) {
|
||||||
|
float prev = 0;
|
||||||
|
GET_TYPED_DATA(prev, float, type, buf);
|
||||||
|
|
||||||
double val = GET_DOUBLE_VAL(tval);
|
double val = GET_DOUBLE_VAL(tval);
|
||||||
UPDATE_DATA(pCtx, *(float*)buf, (float)val, numOfElems, isMinFunc, key);
|
UPDATE_DATA(pCtx, prev, (float)val, numOfElems, isMinFunc, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
return numOfElems;
|
return numOfElems;
|
||||||
|
|
Loading…
Reference in New Issue