Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Previously (<= v0.2.1), Transducers.jl was using val isa Reduced && return reduced(complete(rf, unreduced(val))) everywhere. Or more precisely an equivalent macro: @return_if_reduced complete(rf, val) This actually was a bad idea because `complete` can call `next` hence the reducing function at the "bottom." This violates the purpose of `Reduced`; the reducing function must not be called after returning a `Reduced`. So, the correct way to do this is simply val isa Reduced && return val (I was initially doing this but it was changed to the v0.2.1 form apparently to "Improve PartitionBy" 12dd581.) Fixing this requires some related changes: * Previously, the private state of the transducers are `unwrap`'ed during the `complete` phase. However, now that `complete` will not be called always _by the transducible processes_ (e.g., `foldl`), the `unwrap`ping has to be done during the `next` call chain where the `Reduced` is created. This is treated by changing `wrap(rf, state, iresult::Reduced)`. * Now that the transducible processes are not responsible for calling `complete`, aborting transducers must initiate `complete` for inner reducing functions (e.g., in `Take(4) |> TakeLast(2)`, transducer `Take(4)` must call `complete` for `TakeLast(2)` to flush the buffer and invoke the downstream reducing functions). This change is introduced to `Take`, `TakeWhile`, and `Inject`.
- Loading branch information
Showing
7 changed files
with
96 additions
and
42 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
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