-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generic
Reduced
handling in parallel reduce (#172)
Previously, `Reduced` did not have a meaningful behavior in parallel `reduce` when the reducing function is not `right`: julia> tcollect(TakeWhile(x -> x < 5), 1:10; basesize=1) Empty{Array{T,1} where T}() julia> tcollect(TakeWhile(x -> x < 5), 1:10; basesize=2) 1-element Array{Int64,1}: 4 julia> tcollect(TakeWhile(x -> x < 5), 1:10; basesize=4) 2-element Array{Int64,1}: 3 4 julia> tcollect(TakeWhile(x -> x < 5), 1:10; basesize=5) 4-element Array{Int64,1}: 1 2 3 4 This PR fixes it by properly formulating how to execute the reducing function when combined with `Reduced`. This is done by "augmenting" the reducing function `*`: Given a semigroup `*(::T, ::T) :: T` where `!(Reduced <: T)`, fold functions in Transducers.jl act on an "augmented" semigroup `*′(::T′, ::T′) :: T′` where `T′ = Union{T, Reduced{T}}` defined by *′(a::Reduced, _) = a *′(a::T, b::Reduced) = reduced(a * unreduced(b)) *′(a::T, b::T) = a * b If `*` is a monoid with the identity element `e`, the "augmented" semigroup `*′` is also a monoid with the identity element `e′`.
- Loading branch information
1 parent
149fe18
commit 9a84bb3
Showing
4 changed files
with
33 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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