Skip to content

Add an accumulator type to the Absorb trait#138

Closed
rs-sac wants to merge 1 commit intojonhoo:mainfrom
rs-sac:20260306-acc
Closed

Add an accumulator type to the Absorb trait#138
rs-sac wants to merge 1 commit intojonhoo:mainfrom
rs-sac:20260306-acc

Conversation

@rs-sac
Copy link
Copy Markdown

@rs-sac rs-sac commented Mar 6, 2026

When applying several operations to the same value, certain operations may be faster to compute once at the end rather than incrementally after each change. E.g. if values are Vec<u64>, it would be faster to compute an average or to sort once, after all updates are applied, rather than incrementally after each update.

Add an associated type to the trait for the accumulator, pass it to the absorb methods, and call a new finalize method at the end of each absorb loop. If not needed, the accumulator can be set to () and the finalize method can be left with its default no-op implementation.


This change is Reviewable

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 8, 2026

Codecov Report

❌ Patch coverage is 83.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.8%. Comparing base (a9758d4) to head (22adb1f).
⚠️ Report is 22 commits behind head on main.

Files with missing lines Patch % Lines
src/lib.rs 33.3% 2 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
src/write.rs 71.9% <100.0%> (+2.0%) ⬆️
src/lib.rs 86.6% <33.3%> (+8.0%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

When applying several operations to the same value, certain operations
may be faster to compute once at the end rather than incrementally after
each change.  E.g. if values are `Vec<u64>`, it would be faster to
compute an average or to sort once, after all updates are applied,
rather than incrementally after each update.

Add an associated type to the trait for the accumulator, pass it to the
absorb methods, and call a new finalize method at the end of each absorb
loop.  If not needed, the accumulator can be set to `()` and the
finalize method can be left with its default no-op implementation.
@jonhoo
Copy link
Copy Markdown
Owner

jonhoo commented Apr 4, 2026

@rs-sac After we discussed this offline, do you still think you need this?

For anyone reading this, the quick summary was to change the Op type to instead be "batches" of operations, which would then allow you do this special handling directly in absorb, rather than needing to pass state between absorb calls.

@rs-sac
Copy link
Copy Markdown
Author

rs-sac commented Apr 6, 2026

We don't need this for now. The jury may still be a little out, but I implemented batching and merging outside of left-right.

@rs-sac rs-sac closed this Apr 6, 2026
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.

2 participants