diff --git a/src/client/src/tscStream.c b/src/client/src/tscStream.c index 99669ecd895f10474d70f44cfaa35c73002be433..a1b4ba0bf4994b89758380debef91c3114c361a6 100644 --- a/src/client/src/tscStream.c +++ b/src/client/src/tscStream.c @@ -246,11 +246,7 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf } if (!pStream->isProject) { - if (pStream->intervalTimeUnit == 'y' || pStream->intervalTimeUnit == 'n') { - pStream->stime = taosAddNatualInterval(pStream->stime, pStream->slidingTime, pStream->slidingTimeUnit, pStream->precision); - } else { - pStream->stime += pStream->slidingTime; - } + pStream->stime = taosTimeAdd(pStream->stime, pStream->slidingTime, pStream->slidingTimeUnit, pStream->precision); } // actually only one row is returned. this following is not necessary taos_fetch_rows_a(res, tscProcessStreamRetrieveResult, pStream); diff --git a/src/common/inc/tname.h b/src/common/inc/tname.h index beef9ff375b5339fb3335c60653ac465e40ce3f3..b21d93fe8d24b18a39cc098007051603967c36ea 100644 --- a/src/common/inc/tname.h +++ b/src/common/inc/tname.h @@ -35,7 +35,6 @@ bool tscValidateTableNameLength(size_t len); SColumnFilterInfo* tscFilterInfoClone(const SColumnFilterInfo* src, int32_t numOfFilters); -int64_t taosAddNatualInterval(int64_t key, int64_t intervalTime, char timeUnit, int16_t precision); int32_t taosCountNatualInterval(int64_t skey, int64_t ekey, int64_t intervalTime, char timeUnit, int16_t precision); int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t slidingTime, int64_t intervalTime, char timeUnit, int16_t precision); diff --git a/src/common/src/tname.c b/src/common/src/tname.c index bb18cb6847df3eb748e0a0a38ca4b6d866ce53d9..4193b770d25c2aa6b287e4cd1b06e5831a683c83 100644 --- a/src/common/src/tname.c +++ b/src/common/src/tname.c @@ -99,33 +99,6 @@ SColumnFilterInfo* tscFilterInfoClone(const SColumnFilterInfo* src, int32_t numO return pFilter; } -int64_t taosAddNatualInterval(int64_t key, int64_t intervalTime, char timeUnit, int16_t precision) { - key /= 1000; - if (precision == TSDB_TIME_PRECISION_MICRO) { - key /= 1000; - } - - struct tm tm; - time_t t = (time_t)key; - localtime_r(&t, &tm); - - if (timeUnit == 'y') { - intervalTime *= 12; - } - - int mon = (int)(tm.tm_year * 12 + tm.tm_mon + intervalTime); - tm.tm_year = mon / 12; - tm.tm_mon = mon % 12; - - key = mktime(&tm) * 1000L; - - if (precision == TSDB_TIME_PRECISION_MICRO) { - key *= 1000L; - } - - return key; -} - int32_t taosCountNatualInterval(int64_t skey, int64_t ekey, int64_t intervalTime, char timeUnit, int16_t precision) { skey /= 1000; ekey /= 1000; diff --git a/src/os/src/detail/osTime.c b/src/os/src/detail/osTime.c index c9c61304981050cafffb156b7672fc8fb0bc6ab4..21b972c7c8ada1a7aaf525f0561072f88e02decd 100644 --- a/src/os/src/detail/osTime.c +++ b/src/os/src/detail/osTime.c @@ -496,7 +496,7 @@ int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precisio } } - return taosTimeAdd(start, pInterval->offset, pInterval->intervalUnit, precision); + return taosTimeAdd(start, pInterval->offset, pInterval->offsetUnit, precision); } // internal function, when program is paused in debugger, diff --git a/src/query/src/qFill.c b/src/query/src/qFill.c index 6ae36a160d95aad3912d38684c4c3415579b4c18..d0ecd22739e6363fa66ac4b925f8734aa296c46c 100644 --- a/src/query/src/qFill.c +++ b/src/query/src/qFill.c @@ -108,21 +108,15 @@ void* taosDestoryFillInfo(SFillInfo* pFillInfo) { return NULL; } -static TSKEY taosGetRevisedEndKey(TSKEY ekey, int32_t order, int64_t timeInterval, int8_t slidingTimeUnit, int8_t precision) { - if (order == TSDB_ORDER_ASC) { - return ekey; - } else { - return taosGetIntervalStartTimestamp(ekey, timeInterval, timeInterval, slidingTimeUnit, precision); - } -} - void taosFillSetStartInfo(SFillInfo* pFillInfo, int32_t numOfRows, TSKEY endKey) { if (pFillInfo->fillType == TSDB_FILL_NONE) { return; } - pFillInfo->endKey = taosGetRevisedEndKey(endKey, pFillInfo->order, pFillInfo->interval.sliding, pFillInfo->interval.slidingUnit, - pFillInfo->precision); + pFillInfo->endKey = endKey; + if (pFillInfo->order != TSDB_ORDER_ASC) { + pFillInfo->endKey = taosTimeTruncate(endKey, &pFillInfo->interval, pFillInfo->precision); + } pFillInfo->rowIdx = 0; pFillInfo->numOfRows = numOfRows; @@ -172,8 +166,10 @@ int64_t getFilledNumOfRes(SFillInfo* pFillInfo, TSKEY ekey, int32_t maxNumOfRows int32_t numOfRows = taosNumOfRemainRows(pFillInfo); - TSKEY ekey1 = taosGetRevisedEndKey(ekey, pFillInfo->order, pFillInfo->interval.sliding, pFillInfo->interval.slidingUnit, - pFillInfo->precision); + TSKEY ekey1 = ekey; + if (pFillInfo->order != TSDB_ORDER_ASC) { + pFillInfo->endKey = taosTimeTruncate(ekey, &pFillInfo->interval, pFillInfo->precision); + } int64_t numOfRes = -1; if (numOfRows > 0) { // still fill gap within current data block, not generating data after the result set. @@ -374,12 +370,7 @@ static void doFillResultImpl(SFillInfo* pFillInfo, tFilePage** data, int32_t* nu setTagsValue(pFillInfo, data, *num); } -// TODO natual sliding time - if (pFillInfo->interval.slidingUnit != 'n' && pFillInfo->interval.slidingUnit != 'y') { - pFillInfo->start += (pFillInfo->interval.sliding * step); - } else { - pFillInfo->start = taosAddNatualInterval(pFillInfo->start, pFillInfo->interval.sliding*step, pFillInfo->interval.slidingUnit, pFillInfo->precision); - } + pFillInfo->start = taosTimeAdd(pFillInfo->start, pFillInfo->interval.sliding * step, pFillInfo->interval.slidingUnit, pFillInfo->precision); pFillInfo->numOfCurrent++; (*num) += 1; @@ -486,12 +477,7 @@ int32_t generateDataBlockImpl(SFillInfo* pFillInfo, tFilePage** data, int32_t nu // set the tag value for final result setTagsValue(pFillInfo, data, num); - // TODO natual sliding time - if (pFillInfo->interval.slidingUnit != 'n' && pFillInfo->interval.slidingUnit != 'y') { - pFillInfo->start += (pFillInfo->interval.sliding * step); - } else { - pFillInfo->start = taosAddNatualInterval(pFillInfo->start, pFillInfo->interval.sliding*step, pFillInfo->interval.slidingUnit, pFillInfo->precision); - } + pFillInfo->start = taosTimeAdd(pFillInfo->start, pFillInfo->interval.sliding*step, pFillInfo->interval.slidingUnit, pFillInfo->precision); pFillInfo->rowIdx += 1; pFillInfo->numOfCurrent +=1;