Stream concatenation sugestion

Paul Sandoz paul.sandoz at oracle.com
Wed Apr 3 00:48:15 PDT 2013


Hi,

It seems reasonable to allow more than 2 streams to be concatenated together.

I don't think Streams.concat requires a parallel boolean parameter. As you note you can use parallel() on the concatenated stream if you really want to ensure that stream be parallel. Otherwise the documented behaviour will be the concatenated stream will be parallel if one or more of the streams to concatenate is parallel.

This ain't a very high priority at the moment so please remind me later! 

We are focusing on getting the code together to push to TL and also doing some internal refactoring to improve the fixed cost performance and organization of the code.

Paul.

On Apr 2, 2013, at 3:31 PM, Boaz Nahum <boaznahum at gmail.com> wrote:

> I want to join the request.
> I already have the need to implenet it by myself.
> 
> I would to add
> *    @SafeVarargs
> *    public static <T> Stream<T> concat(Stream<? extends T> ...
> streams, *boolean
> parallel*) {
> 
> Because the decision:
> 
> return (a.isParallel() || b.isParallel())
>               ? parallelStream(split)
>               : stream(split);
> 
> is sometimes just wrong. Two streams can be 'sequential' but processed in
> parallel ?
> 
> [Of course one always do concat(s1,s2).parallel()  ]
> 
> 
> 
> 
> On Tue, Apr 2, 2013 at 4:18 PM, Jose <jgetino at telefonica.net> wrote:
> 
>> 
>> 
>> Please, consider allowing varag argument in stream concatenation
>> 
>> Stream<T> concat(Stream<? extends T> ...streams)
>> 
>> It would save repetitive code in some cases.
>> 
>> 
>> Regards
>> 
>> 
>> 
> 



More information about the lambda-dev mailing list