未验证 提交 499f6749 编写于 作者: M Minglei Jin 提交者: GitHub

Merge pull request #15893 from taosdata/fix/TS-1739-2.6

fix: count the number of aligned time intervals properly
......@@ -565,15 +565,23 @@ int64_t taosTimeSub(int64_t t, int64_t duration, char unit, int32_t precision) {
return (int64_t)(mktime(&tm) * TSDB_TICK_PER_SECOND(precision));
}
int32_t taosTimeCountInterval(int64_t skey, int64_t ekey, int64_t interval, char unit, int32_t precision) {
if (ekey < skey) {
int64_t tmp = ekey;
ekey = skey;
skey = tmp;
}
#ifdef _MSC_VER
#if _MSC_VER >= 1900
int64_t timezone = _timezone;
#endif
#endif
int64_t tz_offset = -1 * timezone * TSDB_TICK_PER_SECOND(precision);
if (unit != 'n' && unit != 'y') {
return (int32_t)((ekey - skey) / interval);
return (int32_t)((ekey+tz_offset)/interval - (skey+tz_offset)/interval) + 1;
}
skey /= (int64_t)(TSDB_TICK_PER_SECOND(precision));
......@@ -592,7 +600,7 @@ int32_t taosTimeCountInterval(int64_t skey, int64_t ekey, int64_t interval, char
interval *= 12;
}
return (emon - smon) / (int32_t)interval;
return (int32_t)(emon/interval - smon/interval) + 1;
}
int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precision) {
......
......@@ -463,7 +463,6 @@ void taosFillSetInputDataBlock(SFillInfo* pFillInfo, const SSDataBlock* pInput)
pFillInfo->interval.sliding,
pFillInfo->interval.slidingUnit,
pFillInfo->precision);
numOfRes += 1;
if(numOfRes < numOfRows || pFillInfo->currentKey < lastKey) {
// set currentKey max
pFillInfo->currentKey = tsList[0];
......@@ -504,7 +503,6 @@ int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, TSKEY ekey, int32_t ma
pFillInfo->interval.sliding,
pFillInfo->interval.slidingUnit,
pFillInfo->precision);
numOfRes += 1;
assert(numOfRes >= numOfRows);
} else { // reach the end of data
if ((ekey1 < pFillInfo->currentKey && FILL_IS_ASC_FILL(pFillInfo)) ||
......@@ -517,7 +515,6 @@ int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, TSKEY ekey, int32_t ma
pFillInfo->interval.sliding,
pFillInfo->interval.slidingUnit,
pFillInfo->precision);
numOfRes += 1;
}
return (numOfRes > maxNumOfRows) ? maxNumOfRows : numOfRes;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册