refactor: do some internal refactor.
This commit is contained in:
parent
4decef962a
commit
f096f27ce8
|
@ -1235,9 +1235,6 @@ int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBloc
|
||||||
if (fmIsPseudoColumnFunc(pfCtx->functionId)) {
|
if (fmIsPseudoColumnFunc(pfCtx->functionId)) {
|
||||||
// do nothing
|
// do nothing
|
||||||
} else if (fmIsNonstandardSQLFunc(pfCtx->functionId)) {
|
} else if (fmIsNonstandardSQLFunc(pfCtx->functionId)) {
|
||||||
// todo set the correct timestamp column
|
|
||||||
pfCtx->input.pPTS = taosArrayGet(pSrcBlock->pDataBlock, 1);
|
|
||||||
|
|
||||||
SResultRowEntryInfo* pResInfo = GET_RES_INFO(&pCtx[k]);
|
SResultRowEntryInfo* pResInfo = GET_RES_INFO(&pCtx[k]);
|
||||||
pfCtx->fpSet.init(&pCtx[k], pResInfo);
|
pfCtx->fpSet.init(&pCtx[k], pResInfo);
|
||||||
|
|
||||||
|
|
|
@ -1198,9 +1198,6 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) {
|
||||||
bool isFirstBlock = (pDiffInfo->hasPrev == false);
|
bool isFirstBlock = (pDiffInfo->hasPrev == false);
|
||||||
int32_t numOfElems = 0;
|
int32_t numOfElems = 0;
|
||||||
|
|
||||||
// int32_t step = GET_FORWARD_DIRECTION_FACTOR(pCtx->order);
|
|
||||||
// int32_t start = (pCtx->order == TSDB_ORDER_ASC) ? pInput->startRowIndex : pInput->numOfRows + pInput->startRowIndex - 1;
|
|
||||||
|
|
||||||
SColumnInfoData* pTsOutput = pCtx->pTsOutput;
|
SColumnInfoData* pTsOutput = pCtx->pTsOutput;
|
||||||
TSKEY* tsList = (int64_t*)pInput->pPTS->pData;
|
TSKEY* tsList = (int64_t*)pInput->pPTS->pData;
|
||||||
|
|
||||||
|
@ -1246,8 +1243,9 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) {
|
||||||
int32_t v = *(int32_t*)colDataGetData(pInputCol, i);
|
int32_t v = *(int32_t*)colDataGetData(pInputCol, i);
|
||||||
int32_t pos = startOffset + numOfElems;
|
int32_t pos = startOffset + numOfElems;
|
||||||
|
|
||||||
|
// there is a row of previous data block to be handled in the first place.
|
||||||
if (pDiffInfo->hasPrev) {
|
if (pDiffInfo->hasPrev) {
|
||||||
int32_t delta = -(int32_t)(v - pDiffInfo->prev.i64); // direct previous may be null
|
int32_t delta = (int32_t)(pDiffInfo->prev.i64 - v); // direct previous may be null
|
||||||
if (delta < 0 && pDiffInfo->ignoreNegative) {
|
if (delta < 0 && pDiffInfo->ignoreNegative) {
|
||||||
colDataSetNull_f(pOutput->nullbitmap, pos);
|
colDataSetNull_f(pOutput->nullbitmap, pos);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1255,11 +1253,12 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTsOutput != NULL) {
|
if (pTsOutput != NULL) {
|
||||||
colDataAppendInt64(pTsOutput, pos, &tsList[i]);
|
colDataAppendInt64(pTsOutput, pos, &pDiffInfo->prevTs);
|
||||||
}
|
}
|
||||||
pDiffInfo->hasPrev = false;
|
pDiffInfo->hasPrev = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// it is not the last row of current block
|
||||||
if (i < pInput->numOfRows + pInput->startRowIndex - 1) {
|
if (i < pInput->numOfRows + pInput->startRowIndex - 1) {
|
||||||
int32_t next = *(int32_t*)colDataGetData(pInputCol, i + 1);
|
int32_t next = *(int32_t*)colDataGetData(pInputCol, i + 1);
|
||||||
|
|
||||||
|
@ -1276,22 +1275,6 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) {
|
||||||
}
|
}
|
||||||
pDiffInfo->hasPrev = true;
|
pDiffInfo->hasPrev = true;
|
||||||
}
|
}
|
||||||
// if (colDataIsNull_f(pInputCol->nullbitmap, i)) {
|
|
||||||
// if (pDiffInfo->includeNull) {
|
|
||||||
// colDataSetNull_f(pOutput->nullbitmap, pos);
|
|
||||||
// if (tsList != NULL) {
|
|
||||||
// colDataAppendInt64(pTsOutput, pos, &tsList[i]);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// numOfElems += 1;
|
|
||||||
// }
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// int32_t v = *(int32_t*)colDataGetData(pInputCol, i);
|
|
||||||
|
|
||||||
// pDiffInfo->prev.i64 = v;
|
|
||||||
// pDiffInfo->hasPrev = true;
|
|
||||||
numOfElems++;
|
numOfElems++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1436,7 +1419,7 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// initial value is not set yet
|
// initial value is not set yet
|
||||||
if (!pDiffInfo->hasPrev || numOfElems <= 0) {
|
if (numOfElems <= 0) {
|
||||||
/*
|
/*
|
||||||
* 1. current block and blocks before are full of null
|
* 1. current block and blocks before are full of null
|
||||||
* 2. current block may be null value
|
* 2. current block may be null value
|
||||||
|
@ -1444,15 +1427,7 @@ int32_t diffFunction(SqlFunctionCtx* pCtx) {
|
||||||
assert(pCtx->hasNull);
|
assert(pCtx->hasNull);
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
// for (int t = 0; t < pCtx->tagInfo.numOfTagCols; ++t) {
|
return (isFirstBlock) ? numOfElems - 1 : numOfElems;
|
||||||
// SqlFunctionCtx* tagCtx = pCtx->tagInfo.pTagCtxList[t];
|
|
||||||
// if (tagCtx->functionId == TSDB_FUNC_TAG_DUMMY) {
|
|
||||||
// aAggs[TSDB_FUNC_TAGPRJ].xFunction(tagCtx);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
int32_t forwardStep = (isFirstBlock) ? numOfElems - 1 : numOfElems;
|
|
||||||
return forwardStep;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue