<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000"><div><br></div><div><br></div><hr id="zwchr" data-marker="__DIVIDER__"><div data-marker="__HEADERS__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>From: </b>"Viktor Klang" <viktor.klang@oracle.com><br><b>To: </b>"Paul Sandoz" <paul.sandoz@oracle.com>, "Fabian Meumertzheim" <fabian@buildbuddy.io><br><b>Cc: </b>"core-libs-dev" <core-libs-dev@openjdk.org><br><b>Sent: </b>Thursday, February 13, 2025 11:30:59 PM<br><b>Subject: </b>Re: JDK-8072840: Presizing for Stream Collectors<br></blockquote></div><div><style style="display:none;"> P {margin-top:0;margin-bottom:0;} </style></div><div data-marker="__QUOTED_TEXT__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;">


<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Indeed. I hope I didn't sound discouraging about the possibility to propagate the stream size information.</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I merely want to emphasize that it may necessitate a slightly broader take on the problem of propagation of stream-instance metadata, especially in the face of Gatherers becoming a finalized feature.</div></blockquote><div><br></div><div>We already have an abstraction for propagating metadata, it's the query part of Spliterator (characteristics/estimateSize/comparator etc, technically all abstract methods that does not starts with "try").</div><div>For a Gatherer, we need a way to say if a characteristics is preserved or removed.</div><div>For a collector, we need a way to have a supplier that takes a Spliterator (a synthetic one, not the one that powers the actual stream) so the characteristics can be queried.</div><div><br></div><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;">
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
It's great that you started this conversation, Fabian!</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="Signature" class="elementToProof" style="color: inherit;">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Cheers,<br>
√</div></div></blockquote><div><br></div><div>regards,</div><div>Rémi</div><div><br data-mce-bogus="1"></div><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><div id="Signature" class="elementToProof" style="color: inherit;">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<b><br></b></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<b>Viktor Klang</b></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Software Architect, Java Platform Group<br>
Oracle</div>
</div>

<hr style="display:inline-block;width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> core-libs-dev <core-libs-dev-retn@openjdk.org> on behalf of Paul Sandoz <paul.sandoz@oracle.com><br><b>Sent:</b> Thursday, 13 February 2025 20:18<br><b>To:</b> Fabian Meumertzheim <fabian@buildbuddy.io><br><b>Cc:</b> core-libs-dev <core-libs-dev@openjdk.org><br><b>Subject:</b> Re: JDK-8072840: Presizing for Stream Collectors</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;"><div class="PlainText">Hi Fabian,<br>
<br>
Thanks for sharing and reaching out with the idea before getting too beholden to it.<br>
<br>
I logged this is quite a while ago. It seemed like a possible good idea at the time, although I never liked the duplication of suppliers. I have become less enthusiastic overtime, especially so as Gatherers have been added. (Gatherer is the underlying primitive
 we could not find when we were furiously developing streams and meeting the Java 8 deadline.) My sense is if we are going to address we need to think more broadly about Gatherers. And, Viktor being the lead on Gatherers has a good take on where this might
 head.<br>
<br>
Paul.<br>
<br>
> On Feb 12, 2025, at 2:09 AM, Fabian Meumertzheim <fabian@buildbuddy.io> wrote:<br>
> <br>
> As an avid user of Guava's ImmutableCollections, I have been<br>
> interested in ways to close the efficiency gap between the built-in<br>
> `Stream#toList()` and third-party `Collector` implementations such as<br>
> `ImmutableList#toImmutableList()`. I've found the biggest problem to<br>
> be the lack of sizing information in `Collector`s, which led to me to<br>
> draft a solution to JDK-8072840:<br>
> <a href="https://github.com/openjdk/jdk/pull/23461" target="_blank">https://github.com/openjdk/jdk/pull/23461</a><br>
> <br>
> The benchmark shows pretty significant gains for sized streams that<br>
> mostly reshape data (e.g. slice records or turn a list into a map by<br>
> associating keys), which I've found to be a pretty common use case.<br>
> <br>
> Before I formally send out the PR for review, I would like to gather<br>
> feedback on the design aspects of it (rather than the exact<br>
> implementation). I will thus leave it in draft mode for now, but<br>
> invite anyone to comment on it or on this thread.<br>
> <br>
> Fabian<br>
<br>
</div></span></font></div><br></blockquote></div></div></body></html>