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

Accessibility of Splitter.remaining #218

Open
mbovel opened this issue Apr 25, 2022 · 2 comments
Open

Accessibility of Splitter.remaining #218

mbovel opened this issue Apr 25, 2022 · 2 comments

Comments

@mbovel
Copy link
Member

mbovel commented Apr 25, 2022

Hi,

Scala parallel collections docs and MOOC mention a .remaining method on Splitter and a .splitter method on collections returning a Splitter:

* All of the parallel operations are implemented as tasks within this trait. Tasks rely
* on the concept of splitters, which extend iterators. Every parallel collection defines:
*
* {{{
* def splitter: IterableSplitter[T]
* }}}
*
* which returns an instance of `IterableSplitter[T]`, which is a subtype of `Splitter[T]`.
* Splitters have a method `remaining` to check the remaining number of elements,
* and method `split` which is defined by splitters. Method `split` divides the splitters
* iterate over into disjunct subsets:

In practice, .remaining is actually defined on IterableSplitter:

And the .splitter method is package-private:

protected[parallel] def splitter: IterableSplitter[T]

Why is that?

Is there a way to obtain an IterableSplitter from a collection using the public API?

In particular, a slide of the MOOC suggests this implementation of .fold on a Splitter:

image

How could I use it in practice, say on a ParVector?

@mbovel
Copy link
Member Author

mbovel commented Apr 25, 2022

My use case is this example: https://scastie.scala-lang.org/ZmMbFnGHRnuO5c3ByKxT7A. I'd like to avoid the dirty hack to access a private method.

@SethTisue
Copy link
Member

it's possible @axel22 remembers something

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

No branches or pull requests

2 participants