From 7a921f66e66bf0ec78a7e3ba16b63017a82b02c6 Mon Sep 17 00:00:00 2001 From: zjbztianya Date: Mon, 4 Jan 2021 22:11:18 +0800 Subject: [PATCH] simple rolling windows code (#346) --- core/collection/rollingwindow.go | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/core/collection/rollingwindow.go b/core/collection/rollingwindow.go index 63203090..a7dc51bd 100644 --- a/core/collection/rollingwindow.go +++ b/core/collection/rollingwindow.go @@ -79,20 +79,9 @@ func (rw *RollingWindow) updateOffset() { } offset := rw.offset - start := offset + 1 - steps := start + span - var remainder int - if steps > rw.size { - remainder = steps - rw.size - steps = rw.size - } - // reset expired buckets - for i := start; i < steps; i++ { - rw.win.resetBucket(i) - } - for i := 0; i < remainder; i++ { - rw.win.resetBucket(i) + for i := 0; i < span; i++ { + rw.win.resetBucket(offset + 1 + i) } rw.offset = (offset + span) % rw.size