Streams design strawman
Brian Goetz
brian.goetz at oracle.com
Sun Apr 22 07:52:08 PDT 2012
Think "histograms." The idea is you are taking a stream of values and
categorizing them. Say you have a collection of classes. One way to do
this is by returning a map-stream:
classes.groupBy(c -> c.getSuperClass())
yields
Object => AbstractList, AbstractSet, AbstractMap
AbstractList => LinkedList, ArrayList
etc.
The "keys" of the new bi-stream are not (necessarily) elements of the
original stream; they are drawn from the range of the mapping function
passed to groupBy.
We could synthesize this kind of group-by by composing a mapping
operation (map element to synthetic key), producing a stream of pairs,
and then a "collect" operation that collects elements mapped to a given
synthetic key, and that collection operation could concatenate into a
stream, count them up, etc.
On 4/22/2012 6:45 AM, Rémi Forax wrote:
> Hi Brian, hi all,
> Trying to catch up ...
> I've some troubles to understand why groupBy() returns a stream (or a
> bi-stream).
>
> Rémi
>
>
> On 04/19/2012 04:49 AM, Brian Goetz wrote:
>> I've posted a strawman writeup of the key concepts we're thinking about
>> for the libraries at:
>>
>> http://cr.openjdk.java.net/~briangoetz/lambda/collections-overview.html
>>
>> The design is still rough, and we've started checking in an even rougher
>> implementation into the lambda repository. There are lots of omissions,
>> errors, and open questions. But it is at a point where we've got a
>> consistent enough strawman for people to start playing with it, and
>> share their experience.
>>
>> As the document suggests, there are a large number of open issues, and
>> we've temporarily ignored these for the purposes of pulling together
>> something that captures the basic functionality. We've deliberately
>> deferred addressing many sticky issues including attachment to
>> collections, primitive specialization, checked exceptions, infinite
>> streams, IO-backed streams, nulls, and of course, naming.
>>
>> These are all sticky issues, and we'll get to them, but for now, I'd
>> like to leave them be for a little while longer, so that we can shake
>> out the key functionality first.
>>
>> What I am asking of the community is: TRY OUT THE CODE. *The single
>> most valuable thing that the community can do to help move this effort
>> forward, and improve the quality of the result, is to try out the code
>> early and often.* (A single practical experience report is worth many
>> armchair observations and suggestions!)
>>
>> What's in the lambda repo right now is still a little rough, but within
>> the next few days it should be cleaned up enough for people to be able
>> to try it out on their code. We would love it if people could try to
>> lambdify some small bit of their code base, and report back on how it
>> worked -- whether it worked great, or not. Also valuable is where you
>> got stuck, such as "I had trouble converting this pattern to use the new
>> libraries."
>>
>>
>>
>>
>>
>
>
More information about the lambda-dev
mailing list