Skip to content
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

add split operation on indexed parallel iterators #513

Open
nikomatsakis opened this issue Jan 24, 2018 · 5 comments
Open

add split operation on indexed parallel iterators #513

nikomatsakis opened this issue Jan 24, 2018 · 5 comments
Assignees

Comments

@nikomatsakis
Copy link
Member

Currently given an IndexedParallelIterator there is no way to divide it up other than skip/take which have side-effects. We were discussing the possibility of a split that takes an indexed iterator and yields back two of them around a particular index.

@cuviper
Copy link
Member

cuviper commented Jan 24, 2018

Hmm, I started implementing this, but it's awkward for iterators that own their data, like rayon::vec::IntoIter. (Whereas its VecProducer only holds &mut [T], which can split.)

@nikomatsakis
Copy link
Member Author

@cuviper ah, interesting -- very good point =)

The fundamental thing that makes it awkward is that the two returned iterators need to be able to be dropped independently (per this design).

You really would prefer to be iterating over this stuff in place though. Hmm.

@cuviper
Copy link
Member

cuviper commented Jan 24, 2018

Once is also awkward to return (Self, Self), unless we allow one of those to not actually iterate once.

Enumerate will have to track its start index, which it doesn't now until it's a Producer. And similar to Once, would it be weird to have an instance of Enumerate floating around that doesn't start at 0?

Or an Interleave that starts with an item from the second iterator? Or an Intersperse that starts with the interspersed item?

@nikomatsakis
Copy link
Member Author

It seems to me that there are enough design questions that it is worth taking this off the 1.0 milestone and iterating separately -- we can always add a SplittableIndexedIterator or something.

In any case, I think we are going to want this to be a callback style, like producer, so that the types can vary and not be limited by associated types.

@cuviper cuviper removed this from the 1.0 milestone Jan 26, 2018
@cuviper
Copy link
Member

cuviper commented Jan 26, 2018

Ah, add a separate trait because we're talking about a required method -- right.

I agree on delaying it. When we get an RFC process going, this will be a good one to chew on. I'm also playing with a simpler trim like I mentioned in #352, or maybe called slice or range...

willcrozi added a commit to willcrozi/rayon that referenced this issue Feb 22, 2021
While we wait for a thought out solution for rayon-rs#513.
This commit causes 'skipped' sections of the Skip to be ignored completely
and no iteration will be performed on those sections. This breaks promise
of the Skip API that side-effects of the iteration are honored. The upside
is that 'skipped' sections of the iterator are essentially zero-cost.

For 'pure functional' workloads (deterministic workloads without IO) only.

rayon-rs#513
see also: rayon-rs#352
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants