Location of getStreamState [it2-bootstrap]
Deepak S Patwardhan
deepak.patwardhan at itaas.com
Mon Jul 30 23:22:01 PDT 2012
Thanks Brian,
Another question. It seems like moving the stream (or bulk) operations from
Iterable to Streamable have caused one of them - groupBy - to not be lazy
(if it ever was completely lazy).
The return type of Streamable.groupBy is Map<U, Streamable<T>>. So, I guess
it is either completely eager or half eager (for the keys) and half lazy
(for the values). Which one is it ? If it is the latter, would the return
type Map<U, Stream<T>> be more suitable ?
Regards,
Deepak S Patwardhan.
-----Original Message-----
From: Brian Goetz [mailto:brian.goetz at oracle.com]
Sent: 31 July 2012 10:17
To: Deepak S Patwardhan
Cc: lambda-dev at openjdk.java.net
Subject: Re: Location of getStreamState [it2-bootstrap]
One of the central themes of Iteration 2 is that streams are NOT Iterables.
They are more like Iterators.
It has nothing to do with 'discouraging external iteration'. It has to do
with presenting the right user model. (Think about streams backed by IO or
a hardware random number generator. They're more like Iterator than
Iterable.)
What you want to do is:
names.filter(.)
.forEach(.);
On Jul 30, 2012, at 8:59 PM, Deepak S Patwardhan wrote:
> Hello,
>
> The following code works in the current lambda implementation (filter
> returns Iterable)
>
> Collection<String> names = ...
> for (String name : names.filter(s -> s.length() > 10)) {...}
>
> However, it will not work with it2-bootstrap because filter will
> return Stream, which is not an Iterable.
>
> Is this just a side-effect of the way Stream API has been (currently)
> written OR is it a design goal to discourage external iteration on Stream?
>
> Regards,
> Deepak S Patwardhan.
>
> -----Original Message-----
> From: Brian Goetz [mailto:brian.goetz at oracle.com]
> Sent: 30 July 2012 18:29
> To: Deepak S Patwardhan
> Cc: lambda-dev at openjdk.java.net
> Subject: Re: Location of getStreamState [it2-bootstrap]
>
>> I am trying to understand the relation between Streamable and Stream
>> interfaces. I see that Streamable has a method named getStreamState -
>> should this not be in Stream ?
>
> The role of getStreamState is still under discussion. It may be
> exposed, or removed. Right now it exists only for the implementation, not
the API.
>
>> On a lighter note, I was wondering if the *main* interface inside
>> java.util.streams is Stream or is it StreamOps?
>
> Note that StreamOps is not a public class.
>
>
>
More information about the lambda-dev
mailing list