From 610e378a43d27e50f1f252cf830dab91332f752c Mon Sep 17 00:00:00 2001 From: Ginbo <827337771@qq.com> Date: Mon, 15 Dec 2025 22:33:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DTrigger=E6=9C=AA=E6=B8=85?= =?UTF-8?q?=E9=99=A4=E8=BF=87=E6=9C=9F=E6=95=B0=E6=8D=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- window/sliding_window.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/window/sliding_window.go b/window/sliding_window.go index 12b0a20..717abb9 100644 --- a/window/sliding_window.go +++ b/window/sliding_window.go @@ -650,12 +650,6 @@ func (sw *SlidingWindow) Trigger() { // Extract Data fields to form []interface{} type data for current window resultData := make([]types.Row, 0) - for _, item := range sw.data { - if sw.currentSlot.Contains(item.Timestamp) { - item.Slot = sw.currentSlot - resultData = append(resultData, item) - } - } // Retain data that could be in future windows // For sliding windows, we need to keep data that falls within: @@ -666,8 +660,12 @@ func (sw *SlidingWindow) Trigger() { cutoffTime := next.End.Add(sw.size) newData := make([]types.Row, 0) for _, item := range sw.data { - // Keep data that could be in future windows (before cutoffTime) - if item.Timestamp.Before(cutoffTime) { + if sw.currentSlot.Contains(item.Timestamp) { + item.Slot = sw.currentSlot + resultData = append(resultData, item) + } + // Keep data that could be in future windows (before cutoffTime && After next.Start) + if item.Timestamp.Before(cutoffTime) && item.Timestamp.After(*next.Start) && item.Timestamp.Equal(*next.Start) { newData = append(newData, item) } }