-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(exex): backfill stream in batches #9738
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is pretty cool
a few tiny suggestions
// Take the next `batch_size` blocks from the range and calculate the range bounds | ||
let mut range = this.range.by_ref().take(this.batch_size); | ||
let start = range.next(); | ||
let range_bounds = start.zip(range.last().or(start)); | ||
|
||
// Advance the range by `batch_size` blocks | ||
this.range.nth(this.batch_size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will run a few times but should be negligible overhead but range could be wrapped into Peekable and integrated into while condition
but it looks like this is just
https://docs.rs/itertools/latest/itertools/trait.Itertools.html#method.chunks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using itertools' chunks will require having a lifetime on the struct and also storing the original iterator in a field. We can also do (0..batch_size).map_while(|_| this.range.next())
here, but it's more expensive than doing nth
just once.
Didn't get your idea with peekable.
6869a98
to
46ebfe7
Compare
Closes #9735