fix(query): fix interp + fill(linear) start from middle of interpolation

range issue
This commit is contained in:
Ganlin Zhao 2022-08-08 21:09:25 +08:00
parent 7aeaa79f4e
commit e16b2fafbe
1 changed files with 46 additions and 19 deletions

View File

@ -2416,29 +2416,56 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
// in case of interpolation window starts and ends between two datapoints, fill(prev) need to interpolate // in case of interpolation window starts and ends between two datapoints, fill(prev) need to interpolate
doKeepPrevRows(pSliceInfo, pBlock, i); doKeepPrevRows(pSliceInfo, pBlock, i);
if (i < pBlock->info.rows - 1) { if (pSliceInfo->fillType == TSDB_FILL_LINEAR) {
// in case of interpolation window starts and ends between two datapoints, fill(next) need to interpolate doKeepLinearInfo(pSliceInfo, pBlock, i);
doKeepNextRows(pSliceInfo, pBlock, i + 1); //pSliceInfo->current =
int64_t nextTs = *(int64_t*)colDataGetData(pTsCol, i + 1); // taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision);
if (nextTs > pSliceInfo->current) { if (i < pBlock->info.rows - 1) {
while (pSliceInfo->current < nextTs && pSliceInfo->current <= pSliceInfo->win.ekey) { int64_t nextTs = *(int64_t*)colDataGetData(pTsCol, i + 1);
genInterpolationResult(pSliceInfo, &pOperator->exprSupp, pBlock, pResBlock); if (nextTs > pSliceInfo->current) {
pSliceInfo->current = while (pSliceInfo->current < nextTs && pSliceInfo->current <= pSliceInfo->win.ekey) {
taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision); genInterpolationResult(pSliceInfo, &pOperator->exprSupp, pBlock, pResBlock);
if (pResBlock->info.rows >= pResBlock->info.capacity) { pSliceInfo->current =
taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision);
if (pResBlock->info.rows >= pResBlock->info.capacity) {
break;
}
}
if (pSliceInfo->current > pSliceInfo->win.ekey) {
doSetOperatorCompleted(pOperator);
break; break;
} }
} else {
// ignore current row, and do nothing
} }
} else { // it is the last row of current block
if (pSliceInfo->current > pSliceInfo->win.ekey) { }
doSetOperatorCompleted(pOperator); } else { // non-linear interpolation
break; if (i < pBlock->info.rows - 1) {
} // in case of interpolation window starts and ends between two datapoints, fill(next) need to interpolate
} else { doKeepNextRows(pSliceInfo, pBlock, i + 1);
// ignore current row, and do nothing int64_t nextTs = *(int64_t*)colDataGetData(pTsCol, i + 1);
if (nextTs > pSliceInfo->current) {
while (pSliceInfo->current < nextTs && pSliceInfo->current <= pSliceInfo->win.ekey) {
genInterpolationResult(pSliceInfo, &pOperator->exprSupp, pBlock, pResBlock);
pSliceInfo->current =
taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision);
if (pResBlock->info.rows >= pResBlock->info.capacity) {
break;
}
}
if (pSliceInfo->current > pSliceInfo->win.ekey) {
doSetOperatorCompleted(pOperator);
break;
}
} else {
// ignore current row, and do nothing
}
} else { // it is the last row of current block
doKeepPrevRows(pSliceInfo, pBlock, i);
} }
} else { // it is the last row of current block
doKeepPrevRows(pSliceInfo, pBlock, i);
} }
} else { // ts > pSliceInfo->current } else { // ts > pSliceInfo->current
// in case of interpolation window starts and ends between two datapoints, fill(next) need to interpolate // in case of interpolation window starts and ends between two datapoints, fill(next) need to interpolate