feat: add SlidingWindowAggregator, a ring buffer with windowed aggregation - #7591
Merged
DenizAltunkapan merged 1 commit intoSep 6, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7591 +/- ##
============================================
+ Coverage 80.68% 80.74% +0.06%
- Complexity 7529 7573 +44
============================================
Files 817 818 +1
Lines 24162 24257 +95
Branches 4759 4772 +13
============================================
+ Hits 19494 19587 +93
- Misses 3906 3907 +1
- Partials 762 763 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ation A fixed-capacity circular buffer that additionally keeps an aggregate of every element it currently holds, so a sliding window sum, minimum or maximum is available in constant time. Rather than the usual "add the new value, subtract the evicted one" trick, which only works for invertible operators, it uses the two-stack sliding window aggregation algorithm: the window is split into a front section holding suffix aggregates and a back section summarised by a single running aggregate. Every element takes part in at most one rotation between the two, which makes insertion and removal O(1) amortised with no allocation after construction. Any associative operator works, commutative or not, and no identity element is needed. Comes with factories for sum, minimum and maximum, indexed access, a fail-fast iterator, and tests that check the aggregate against a brute force reference under randomly interleaved insertions and removals. Co-authored-by: Oleksandr Klymenko <19151554+alxkm@users.noreply.github.com> Signed-off-by: alxkm <19151554+alxkm@users.noreply.github.com>
alxkm
force-pushed
the
feat/sliding-window-aggregator
branch
from
September 5, 2026 20:18
53a6109 to
e3c7798
Compare
DenizAltunkapan
approved these changes
Sep 6, 2026
Member
|
@alxkm thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A fixed-capacity circular buffer that additionally keeps an aggregate of every element it currently holds, so a sliding window sum, minimum or maximum is available in constant time.
Rather than the usual "add the new value, subtract the evicted one" trick, which only works for invertible operators, it uses the two-stack sliding window aggregation algorithm: the window is split into a front section holding suffix aggregates and a back section summarised by a single running aggregate. Every element takes part in at most one rotation between the two, which makes insertion and removal O(1) amortised with no allocation after construction. Any associative operator works, commutative or not, and no identity element is needed.
Comes with factories for sum, minimum and maximum, indexed access, a fail-fast iterator, and tests that check the aggregate against a brute force reference under randomly interleaved insertions and removals.
clang-format -i --style=file path/to/your/file.java