Concat operation take 2

Paul Sandoz paul.sandoz at oracle.com
Fri Sep 21 04:44:09 PDT 2012


http://cr.openjdk.java.net/~psandoz/lambda/concat/webrev/

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.

Paul.

On Sep 18, 2012, at 2:12 PM, Paul Sandoz <Paul.Sandoz at oracle.com> wrote:

> Hi,
> 
> Please see here for a first go at implementing concat:
> 
>  http://cr.openjdk.java.net/~psandoz/lambda/concat/webrev/
> 
> I chose to implement:
> 
>  stream.concat(anotherStream)
> 
> 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).
> 
> Paul.
> 



More information about the lambda-dev mailing list