-
Notifications
You must be signed in to change notification settings - Fork 501
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
Added A par_chunk_by
method
#925
Conversation
Thanks, it's an interesting feature! Do you think you'll try a mutable version as well? And yes, we'll want to wait for the API to stabilize in the standard library so we can match it. |
That should be the mutable version. |
Just for reference, that |
I'm interested in this, but I found a bug in it, the following call: let data = vec![1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4];
let groups: Vec<_> = data.par_group_by(|&a, &b| a == b).collect::<Vec<_>>();
println!("{:?}", groups); will result in 5 groups instead of the expected 4, these groups are:
|
I think that fixed it |
It did, nice job! |
FYI, that stabilization just landed with a rename to |
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.
I wonder if this can be refactored to use the internal SplitProducer
infrastructure, because that's basically what this iterator is doing overall, splitting on a pair-predicate. That API won't work directly as-is, but I've also been working on modifications to add split_inclusive
, which might be instructive on how to extend it.
In particular, this now ensures we only call the predicate once on each pair of items.
I didn't find a good way to shoehorn this into |
Thanks @jakeKonrad! Hope you don't mind that I wrapped this up myself. |
Hello, I found this method useful in my code and thought it could be used here. However it relies on #![feature(slice_group_by)] unstable feature of the rust std library and you would probably want to wait for that method to be stabilized anyways so as to stay consistent with whatever naming they choose. This pull request is here for when that happens. Also if any one has any comments on the code I'd really appreciate hearing them.