Skip to content

Fix broken sliding window logic and remove unnecessary finisher in SlidingWindowGatherer - #19290

Open
simpanda01 wants to merge 2 commits into
eugenp:masterfrom
simpanda01:fix-sliding-window-gatherer
Open

Fix broken sliding window logic and remove unnecessary finisher in SlidingWindowGatherer#19290
simpanda01 wants to merge 2 commits into
eugenp:masterfrom
simpanda01:fix-sliding-window-gatherer

Conversation

@simpanda01

Copy link
Copy Markdown

Fixes #18683

Problem:

  • The integrator pushed the window before checking its size and unconditionally removed the first element after every push, so every emitted window had size 1 instead of forming an actual sliding window.
  • The finisher() override was a no-op, duplicating the default behavior already provided by Gatherer.

Fix:

  • Added a WINDOW_SIZE constant. Now elements are removed from the front only once the window exceeds WINDOW_SIZE, and a window is pushed downstream only once it reaches WINDOW_SIZE.
  • Removed the redundant finisher() override and unused BiConsumer import.
  • Kept ArrayDeque for O(1) removeFirst().

Testing: Verified with input 1,2,3,4,5 → correctly produces [1,2,3], [2,3,4], [3,4,5].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unnecessary finisher

1 participant