apache / rocketmq-streams

Apache rocketmq
https://rocketmq.apache.org/
Apache License 2.0
171 stars 82 forks source link

Why the termination condition is 'start > valueTime - sizeInterval' instead of 'start >= valueTime - sizeInterval' ? #289

Closed starmilkxin closed 1 year ago

starmilkxin commented 1 year ago
    protected List<Window> calculateWindow(WindowInfo windowInfo, long valueTime) {
        long sizeInterval = windowInfo.getWindowSize().toMillSecond();
        long slideInterval = windowInfo.getWindowSlide().toMillSecond();

        List<Window> result = new ArrayList<>((int) (sizeInterval / slideInterval));
        long lastStart = valueTime - (valueTime + slideInterval) % slideInterval;

        for (long start = lastStart; start > valueTime - sizeInterval; start -= slideInterval) {
            long end = start + sizeInterval;
            Window window = new Window(start, end);
            result.add(window);
        }
        return result;
    }
ni-ze commented 1 year ago

if the expression is >=, the result of fellow is: image

if the expression is >, the result of fellow is: image

1970-01-01 08:00:40 must be in one window, so I think > is better.