Skip to content

Commit 9739f21

Browse files
committed
fix:修复Trigger未清除过期数据问题
1 parent 4528d1f commit 9739f21

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

window/sliding_window.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -658,16 +658,13 @@ func (sw *SlidingWindow) Trigger() {
658658
}
659659

660660
// Retain data that could be in future windows
661-
// For sliding windows, we need to keep data that falls within:
662-
// - Current window end + size (for overlapping windows)
663-
// - Next window end + size (for future windows)
664-
// Actually, we should keep all data that could be in any future window
665-
// The latest window that could contain a data point is: next.End + size
666-
cutoffTime := next.End.Add(sw.size)
661+
// For sliding windows, we need to keep data that falls within future windows
662+
// Future windows start at next.Start or later (next.Start + k * slide)
663+
// So any data with timestamp < next.Start cannot be in any future window
667664
newData := make([]types.Row, 0)
668665
for _, item := range sw.data {
669-
// Keep data that could be in future windows (before cutoffTime)
670-
if item.Timestamp.Before(cutoffTime) {
666+
// Keep data that could be in future windows (>= next.Start)
667+
if !item.Timestamp.Before(*next.Start) {
671668
newData = append(newData, item)
672669
}
673670
}

0 commit comments

Comments
 (0)