Hi David,

Thank you for the write-up—sharing your experience with us.

I'm happy you've had much success with `windowBy`, and we're going to have to 
wait and see what other feedback on Gatherers and potential unmet needs in the 
roster of baked-in Gatherers.

Gatherers is scheduled to have a second preview in Java 23, in order to give 
users a chance to try it out and share their experience.

Cheers,
√


Viktor Klang
Software Architect, Java Platform Group
Oracle
________________________________
From: David Alayachew <davidalayac...@gmail.com>
Sent: Sunday, 4 August 2024 09:14
To: core-libs-dev <core-libs-dev@openjdk.org>
Cc: Remi Forax <fo...@univ-mlv.fr>; Viktor Klang <viktor.kl...@oracle.com>
Subject: [External] : Gatherers -- windowBy

Hello Core Libs Dev Team,

Apologies for the massive delay. I have been juggling many severe personal 
emergencies, and thus, did not have time or strength to follow up on the 
previous thread -- 
https://mail.openjdk.org/pipermail/core-libs-dev/2024-January/117718.html

As mentioned in my previous thread, I have been extremely happy with the new 
Gatherers API, and have found numerous uses for it.

I did want to add one addition to the list of premade gatherers provided by the 
standard library in java.util.stream.Gatherers API -- a windowBy gatherer.

The result of the thread was that, while the feature had nothing wrong with it, 
evidence needed to be provided of its utility. This email is that evidence. 
Specifically, this email is providing all of the situations where I used this 
windowBy Gatherer that Viktor Klang made for me, with the hope that it is 
strong enough evidence to push this method into the Gatherers API.

Here we go.

  1.  Advent of Code 2020 -- Day 14 [1] -- and here is my code [2] -- here is a 
link to the line that actually used the gatherer [3]
     *   This cleaned up my solution CONSIDERABLY. If I was doing this with for 
loops, I would have to do index manipulation to jump ahead my for loop index 
wise. Here, all I am doing is telling it how to split apart the stream. Way 
more clear and elegant. Which was critical because this AOC day was extremely 
difficult for me. Solution is not yet done, but making great progress.
  2.  Service Health Analytics -- Work project, so I can't share the code
     *   This was a super basic use case, but long story short, I'm tracing 
down yet another network issue, and I wanted to know what was occurring before 
the network outage, to see if there was a correlation. I ended up scrapping 
this solution in favor of another one, but I was quite happy with how easy the 
Gatherer made it to grab exactly what I wanted. It was just a windowBy followed 
by a sliding window, and then extracting some info by comparing the 2 chunks.
  3.  Typing Metrics [4] -- here is the link to the method that uses the 
Gatherer [5]
     *   This is where I really put the Gatherer through its paces. I had some 
semi-complex examples, but I got them all to work out well. It made my logic 
simpler than the imperative equivalent, while also keeping things concise. Now, 
one point that caused me some difficulty was recognizing that the Gatherer has 
a surprisingly large number of edge cases. For example, when looking at the 
data in aggregate, you notice a pattern -- the first element of every window is 
the FALSE case of your predicate, while all remaining members of that window 
are the TRUE case of the predicate. However, it's very possible for the first 
window to be a single element TRUE case window. I think this is the first time 
I found a valid use for the Stream::dropWhile method lol. But otherwise, this 
feature REALLY helped me move forward, and I am very happy with it!

My biggest takeaway from using this Gatherer is that, when dealing with a 
Stream of events that you want to get metrics of, this gatherer is going to be 
a critical tool in the arsenal. This Gatherer also pairs BEAUTIFULLY with 
slidingWindow, to where I feel it made sliding window even stronger. I break up 
my stream into chunks using the windowBy, then slide over those chunks using 
sliding window. I kept finding myself using this strategy to aggregate and 
analyze. To use an analogy, it feels almost like making a database view of a 
larger database table.

This is my experience using the windowBy Gatherer that Viktor Klang gave me. 
Please let me know if there are any questions, comments, or concerns.

Thank you for your time, patience, and understanding!
David Alayachew

[1] = 
https://adventofcode.com/2020/day/14<https://urldefense.com/v3/__https://adventofcode.com/2020/day/14__;!!ACWV5N9M2RV99hQ!LEBjZbZKNTq2ifo9CYK0RE3c2wwJMxmUlb7ZWZ88j3Dgq50_x3z_2hX4j2GAL_hicf5s05xDzgM8__xH7_1j6kToUsc$>
[2] = 
https://github.com/davidalayachew/Advent_of_Code/blob/1f054282d610af444dd27be4dfb374e10ac76db4/AOC/AOC_2020.java#L334<https://urldefense.com/v3/__https://github.com/davidalayachew/Advent_of_Code/blob/1f054282d610af444dd27be4dfb374e10ac76db4/AOC/AOC_2020.java*L334__;Iw!!ACWV5N9M2RV99hQ!LEBjZbZKNTq2ifo9CYK0RE3c2wwJMxmUlb7ZWZ88j3Dgq50_x3z_2hX4j2GAL_hicf5s05xDzgM8__xH7_1jakXmB9k$>
[3] = 
https://github.com/davidalayachew/Advent_of_Code/blob/1f054282d610af444dd27be4dfb374e10ac76db4/AOC/AOC_2020.java#L468<https://urldefense.com/v3/__https://github.com/davidalayachew/Advent_of_Code/blob/1f054282d610af444dd27be4dfb374e10ac76db4/AOC/AOC_2020.java*L468__;Iw!!ACWV5N9M2RV99hQ!LEBjZbZKNTq2ifo9CYK0RE3c2wwJMxmUlb7ZWZ88j3Dgq50_x3z_2hX4j2GAL_hicf5s05xDzgM8__xH7_1jWHufk2U$>
[4] = 
https://github.com/davidalayachew/HowFastCanYouType<https://urldefense.com/v3/__https://github.com/davidalayachew/HowFastCanYouType__;!!ACWV5N9M2RV99hQ!LEBjZbZKNTq2ifo9CYK0RE3c2wwJMxmUlb7ZWZ88j3Dgq50_x3z_2hX4j2GAL_hicf5s05xDzgM8__xH7_1jOKot3vY$>
[5] = 
https://github.com/davidalayachew/HowFastCanYouType/blob/main/src/main/java/HowFastCanYouTypeModule/HowFastCanYouTypePackage/GUI.java#L151<https://urldefense.com/v3/__https://github.com/davidalayachew/HowFastCanYouType/blob/main/src/main/java/HowFastCanYouTypeModule/HowFastCanYouTypePackage/GUI.java*L151__;Iw!!ACWV5N9M2RV99hQ!LEBjZbZKNTq2ifo9CYK0RE3c2wwJMxmUlb7ZWZ88j3Dgq50_x3z_2hX4j2GAL_hicf5s05xDzgM8__xH7_1jXX46EYs$>

Reply via email to