Concat operation take 2
paul.sandoz at oracle.com
Fri Sep 21 04:44:09 PDT 2012
I included a parallel implementation. If both the upstream and and concatenating stream are parallel then it is possible to evaluate each one in parallel and concatenate the results.
The StreamOpTestCase is updated to include a little builder, which allows one to provide blocks of code for before/after the test of intermediate operations and select which tests to exercise the operations.
This is useful for testing TeeOp.
Brian, i retained the factory mechanism for now since it otherwise resulted in some nasty proxy contortions to test ConcatOp, mainly due to the lack of a resettable stream.
For a future iteration i think we need to support Streamable in addition to Stream, before deciding if the latter is useful or not.
This will enable concat to be used in detached pipelines and a choice of whether to consume the stream sequentially or in parallel. This may require access to stream flags on Streamable to enable certain optimisations.
On Sep 18, 2012, at 2:12 PM, Paul Sandoz <Paul.Sandoz at oracle.com> wrote:
> Please see here for a first go at implementing concat:
> I chose to implement:
> so that the elements of "anotherStream" are concatenated on to end of "stream".
> This operation has side-effects.
> I am not sure how this operation relates to MapStream.mergeWith.
> I pulled out the concatenating of Iterator<Iterator<T>> from TreeUtils, spruced (no pun intended) it up, and placed it in Iterators for reuse.
> There is only the dumb parallel implementation. One wonders for the parallel case whether concat should be pseudo-random interleave :-)
> I updated the StreamOpTestCase exercise methods to take a Factory<IntermediateOp> since concat has side-effects:
> exerciseFOp(data, () -> ConcatOp.make(data.seqStream()));
> (Another TODO for these test methods is to select which cases to test).
More information about the lambda-dev