<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Greetings,</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
As you may have already seen, <b>Stream Gatherers</b> is now a <a href="https://openjdk.org/jeps/461" title="https://openjdk.org/jeps/461" id="LPlnk995248" class="OWAAutoLink">
Preview JEP with Candidate status</a></div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof ContentPasted0">
Work-in-progress (interfaces, implementation, tests, benches, and documentation) for JEP-461 is currently available
<a href="https://github.com/viktorklang-ora/jdk/tree/gatherer" title="https://github.com/viktorklang-ora/jdk/tree/gatherer" id="OWA8ab01dac-cb46-bda0-009f-d3a4a0a6e81e" class="OWAAutoLink ContentPasted0">
here</a>.<br>
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof ContentPasted2">
While <a href="https://cr.openjdk.org/~vklang/Gatherers.html" title="https://cr.openjdk.org/~vklang/Gatherers.html " id="LPlnk332869" class="OWAAutoLink">
the design</a> has held up well, there are some important improvements made since the original design document was written.<br>
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Notable changes (without any particular order):</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<ul data-editing-info="{"orderedStyleType":1,"unorderedStyleType":1}">
<li style="list-style-type: disc;"><b>Stream::gather()</b> now has a default implementation.<br>
<br>
<span></span></li><li style="list-style-type: disc;"><b><span>Gatherer</span><span></span>::supplier()
</b>was renamed to <b>Gatherer::initializer()</b> to better reflect intent.<br>
<br>
</li><li style="list-style-type: disc;"><b>Gatherer.Sink<R></b> was renamed to <b>Gatherer.Downstream<R></b> to better signal what it represents.<br>
<br>
</li><li style="list-style-type: disc;"><b>Gatherer::collect(Collector)</b> and its companion type
<b>Gatherer.ThenCollector</b> was dropped due to compatibility concerns with existing code which operates on
<b>Collector</b>.<br>
<br>
</li><li style="list-style-type: disc;">
<div><span><b>Gatherer.Characteristics</b> have been eliminated and superseded by having default values that are used as sentinels.<br>
</span></div>
 (discussed further down the list)<br>
<div><span>This is important because with the Characteristics-model keeping alignment between Characteristics and actual implementation proved brittle, and under composition of Gatherers computing the union was inefficient and mostly lead to an empty set in
 the end.<br>
<br>
</span></div>
</li><li style="list-style-type: disc;"><span><b>Gatherer.defaultInitializer()</b>, <b>
Gatherer.defaultCombiner()</b>, and <b>Gatherer.defaultFinisher()</b> were added as static methods—these are the sentinels used to elide calling the initializer, to elide calling the combiner (avoid parallelization), and to elide calling the finisher, respectively.<br>
<br>
</span></li><li style="list-style-type: disc;"><span><b>Gatherer::initializer()</b>, <b>Gatherer::combiner()</b>, and
<b>Gatherer::finisher()</b> default implementations return the respective sentinels.<br>
<br>
</span></li><li style="list-style-type: disc;"><span>A subtype of <b>Integrator</b> named <b>
Greedy</b> was added, together with a factory method to guide lambda-to-nominal-type conversion. This allows creators of Gatherers to signal that an
<b>Integrator</b> will never initiate a short-circuit (but may relay one from downstream), and that is available during evaluation to determine if the operation can short-circuit or not.</span>
<div style="list-style-type: disc;"><br>
<span></span></div>
</li><li style="list-style-type: disc;"><span>Factories for creating anonymous Gatherers were expanded upon to include
<b>Gatherer.of()</b> and <b>Gatherer.ofSequential()</b> with different sets of parameters, primarily to make it more ergonomical and easier to read and write the code using those factories.</span>
<div style="list-style-type: disc;"><br>
<span></span></div>
</li><li style="list-style-type: disc;"><span>A curated set of initial built-in Gatherers is located in
<b>java.util.stream.Gatherers</b><br>
</span></li></ul>
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof ContentPasted1">
I recently presented <a href="https://www.youtube.com/watch?v=8fMFa6OqlY8" title="https://www.youtube.com/watch?v=8fMFa6OqlY8" id="LPlnkOWALinkPreview_2" class="OWAAutoLink">
Gatherers at Devoxx</a>, which I'd recommend watching for an introduction to the feature.<br>
</div>
<div class="_Entity _EType_OWALinkPreview _EId_OWALinkPreview_8 _EReadonly_1">
<div id="LPBorder_BVTaHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g:dj04Zk1GYTZPcWxZOA.." class="LPBorder874039" style="width: 100%; margin-top: 16px; margin-bottom: 16px; position: relative; max-width: 800px; min-width: 424px;">
<table id="LPContainer874039" role="presentation" style="padding: 12px 36px 12px 12px; width: 100%; border-width: 1px; border-style: solid; border-color: rgb(200, 200, 200); border-radius: 2px;">
<tbody>
<tr style="border-spacing: 0px;" valign="top">
<td>
<div id="LPImageContainer874039" style="position: relative; margin-right: 12px; height: 180px; overflow: hidden; width: 240px;">
<a target="_blank" id="LPImageAnchor874039" href="https://www.youtube.com/watch?v=8fMFa6OqlY8"><img id="LPThumbnailImageId874039" alt="" style="display: block;" width="240" height="180" data-outlook-trace="F:1|T:1" src="cid:d048f613-b144-4ff9-a2d3-98e0765aab57"></a></div>
</td>
<td style="width: 100%;">
<div id="LPTitle874039" style="font-size: 21px; font-weight: 300; margin-right: 8px; font-family: "wf_segoe-ui_light", "Segoe UI Light", "Segoe WP Light", "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; margin-bottom: 12px;">
<a target="_blank" id="LPUrlAnchor874039" href="https://www.youtube.com/watch?v=8fMFa6OqlY8" style="text-decoration: none;">Teaching old Streams new tricks By Viktor Klang</a></div>
<div id="LPDescription874039" style="font-size: 14px; max-height: 100px; font-family: "wf_segoe-ui_normal", "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; margin-bottom: 12px; margin-right: 8px; overflow: hidden; color: rgb(102, 102, 102);">
Have you ever wanted to perform an operation on a java.util.stream.Stream only to find that the existing set of operations didn't provide what you needed—forcing you to break out early from the Stream and perform the logic outside of it? As a matter of fact,
 java.util.stream was the first JDK API designed with lambdas in mind and was ...</div>
<div id="LPMetadata874039" style="font-size: 14px; font-weight: 400; font-family: "wf_segoe-ui_normal", "Segoe UI", "Segoe WP", Tahoma, Arial, sans-serif; color: rgb(166, 166, 166);">
www.youtube.com</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<span>      </span><br>
</div>
<div class="elementToProof">
<div 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">
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Cheers,<br>
√</div>
<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<br>
</div>
</div>
</div>
</div>
</body>
</html>