[External] : Re: JEP 473: Stream Gatherers (Second Preview)
Viktor Klang
viktor.klang at oracle.com
Mon Apr 8 20:10:32 UTC 2024
>"could" not "would"?
If the operation is strictly many-to-one, then it will always emit a single element, this means that it might need to track as a part of its state whether it has emitted something in its integrator and if not then emit it in the finisher.
But I, guess that one could reason about it from multiple levels of zoom: a Stream can have end-to-end a specific N:M-ratio, a Gatherer could have a specific N:M-ratio, and an Integrator itself could have a specific N:M-ratio.
Think of something like a `sort()`-Gatherer, it would not be able to emit anything until it has consumed all upstream elements, and it would only know that all upstream elements have been consumed once its finisher is invoked, and as a response to that it could then iterate over the entire sorted set of elements and emit them in the new order downstream.
>Other than at initialization or finish, is it possible to have an "empty" input?
No, not an empty as in "absense of". You'd have to emit in the finisher then.
Cheers,
√
Viktor Klang
Software Architect, Java Platform Group
Oracle
________________________________
From: Ernie Rael <errael at raelity.com>
Sent: Sunday, 7 April 2024 18:31
To: Viktor Klang <viktor.klang at oracle.com>; core-libs-dev at openjdk.org <core-libs-dev at openjdk.org>
Subject: [External] : Re: JEP 473: Stream Gatherers (Second Preview)
On 24/04/07 9:11 AM, Viktor Klang wrote:
Hi Ernie,
"Many" in this case refers to "N", which is "0 ... N",
OK, I was wondering about "many" including "0".
so I'd say while it is techincally correct as-is, perhaps more precise would be to say "1-to-0..1" gatherer, since for every element in, there is 0 or 1 element out.
I see.
Many-to-one would be 0..N -> 1, which means that an empty input would
"could" not "would"?
yield a single output.
Out of curiosity, is either correct technically?
Other than at initialization or finish, is it possible to have an "empty" input?
-ernie
Cheers,
√
Viktor Klang
Software Architect, Java Platform Group
Oracle
________________________________
From: core-libs-dev <core-libs-dev-retn at openjdk.org><mailto:core-libs-dev-retn at openjdk.org> on behalf of Ernie Rael <errael at raelity.com><mailto:errael at raelity.com>
Sent: Sunday, 7 April 2024 18:06
To: core-libs-dev at openjdk.org<mailto:core-libs-dev at openjdk.org> <core-libs-dev at openjdk.org><mailto:core-libs-dev at openjdk.org>
Subject: JEP 473: Stream Gatherers (Second Preview)
This is about what might be a minor doc issue.
In https://openjdk.org/jeps/473 it says
As another example, Stream::filter takes a predicate that determines whether an input element should be passed downstream; this is simply a stateless one-to-many gatherer.
Shouldn't this be "many-to-one"?
-ernie
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20240408/6da6416c/attachment-0001.htm>
More information about the core-libs-dev
mailing list