Fix reducers foldcat example to actually fold in parallel#741
Open
kovan wants to merge 1 commit intoclojure:masterfrom
Open
Fix reducers foldcat example to actually fold in parallel#741kovan wants to merge 1 commit intoclojure:masterfrom
kovan wants to merge 1 commit intoclojure:masterfrom
Conversation
The example used (range 100000) which returns a seq. Seqs do not implement CollFold and fall back to single-threaded reduce, making the foldcat example misleading on a page about parallel folding. Wrap with vec so the example actually demonstrates parallel folding. Add a note explaining that seqs must be converted to vectors first. Verified against reducers.clj: Object/coll-fold (line 320) falls back to single reduce, while IPersistentVector/coll-fold (line 326) performs parallel fork-join folding. Fixes clojure#377
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
r/foldcatexample used(range 100000)which returns a seq. Seqs do not implementCollFoldand fall back to single-threaded reduce, making the example misleading on a page about parallel folding.Wraps with
vecso the example actually demonstrates parallel folding, and adds a note explaining the requirement.Verified against
reducers.clj:Object/coll-foldfalls back to single reduce, whileIPersistentVector/coll-foldperforms parallel fork-join folding.Fixes #377