fix: recalcuate window ekey
This commit is contained in:
parent
ba2ba0a8cb
commit
b4b4400958
|
@ -449,7 +449,13 @@ STimeWindow getAlignQueryTimeWindow(const SInterval* pInterval, int64_t key) {
|
||||||
* if the realSkey > INT64_MAX - pInterval->interval, the query duration between
|
* if the realSkey > INT64_MAX - pInterval->interval, the query duration between
|
||||||
* realSkey and realEkey must be less than one interval.Therefore, no need to adjust the query ranges.
|
* realSkey and realEkey must be less than one interval.Therefore, no need to adjust the query ranges.
|
||||||
*/
|
*/
|
||||||
win.ekey = taosTimeAdd(win.skey, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1;
|
if (pInterval->offset > 0) {
|
||||||
|
int64_t slideStart = taosTimeAdd(win.skey, -1 * pInterval->offset, pInterval->offsetUnit, pInterval->precision);
|
||||||
|
int64_t slideEnd = taosTimeAdd(slideStart, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1;
|
||||||
|
win.ekey = taosTimeAdd(slideEnd, pInterval->offset, pInterval->offsetUnit, pInterval->precision);
|
||||||
|
} else {
|
||||||
|
win.ekey = taosTimeAdd(win.skey, pInterval->interval, pInterval->intervalUnit, pInterval->precision) - 1;
|
||||||
|
}
|
||||||
if (win.ekey < win.skey) {
|
if (win.ekey < win.skey) {
|
||||||
win.ekey = INT64_MAX;
|
win.ekey = INT64_MAX;
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,6 +164,11 @@ TEST(testCase, timewindow_natural) {
|
||||||
int32_t precision = TSDB_TIME_PRECISION_MILLI;
|
int32_t precision = TSDB_TIME_PRECISION_MILLI;
|
||||||
|
|
||||||
SInterval interval2 = createInterval(17, 17, 13392000000, 'n', 'n', 0, precision);
|
SInterval interval2 = createInterval(17, 17, 13392000000, 'n', 'n', 0, precision);
|
||||||
|
int64_t key = 1648970865984;
|
||||||
|
STimeWindow w0 = getAlignQueryTimeWindow(&interval2, key);
|
||||||
|
printTimeWindow(&w0, precision, key);
|
||||||
|
ASSERT_GE(w0.ekey, key);
|
||||||
|
|
||||||
int64_t key1 = 1633446027072;
|
int64_t key1 = 1633446027072;
|
||||||
STimeWindow w1 = {0};
|
STimeWindow w1 = {0};
|
||||||
getInitialStartTimeWindow(&interval2, key1, &w1, true);
|
getInitialStartTimeWindow(&interval2, key1, &w1, true);
|
||||||
|
|
Loading…
Reference in New Issue