Re: EnumeratedStream

2024-04-21 Thread ІП-24 Олександр Ротань
To clear things up, Issues are related to handling using type erasure, not class generating approach. вс, 21 апр. 2024 г. в 18:45, ІП-24 Олександр Ротань < rotan.olexa...@gmail.com>: > To clear thing up, Issues are related to handling using type erasure, not > class generating approach. > > вс, 2

Re: EnumeratedStream

2024-04-21 Thread ІП-24 Олександр Ротань
I am not really familiar with goals and milestones of Valhalla project, but what I meant by simplification is that there would not be any more need to convert to promotove streams explicitly as Stream would be a thing. If that's what Valhalla is working on, then this would be just great. Performanc

Re: EnumeratedStream

2024-04-21 Thread -
On Sun, Apr 21, 2024 at 5:49 AM ІП-24 Олександр Ротань < rotan.olexa...@gmail.com> wrote: > I have heard your proposal. Your approach indeed for sure has its > advantages. > > One thing I don't like referring to is Valhalla. It's not even a > preview and no one really knows when it will be, relyin

Re: EnumeratedStream

2024-04-21 Thread ІП-24 Олександр Ротань
I have heard your proposal. Your approach indeed for sure has its advantages. One thing I don't like referring to is Valhalla. It's not even a preview and no one really knows when it will be, relying on it when designing API now would be strange to say the least. One possible thing that could dra

Re: EnumeratedStream

2024-04-20 Thread -
On Sat, Apr 20, 2024 at 8:29 PM ІП-24 Олександр Ротань < rotan.olexa...@gmail.com> wrote: > Gatherers could be effectively terminal, but I don't think Gatherer API > designers intended it to be. In related JEP, gatherers are described as a > way to declare custom intermediate operations, and intro

Re: EnumeratedStream

2024-04-20 Thread ІП-24 Олександр Ротань
Gatherers could be effectively terminal, but I don't think Gatherer API designers intended it to be. In related JEP, gatherers are described as a way to declare custom intermediate operations, and introducing "terminal" gatherers would be misleading. Talking about performance, not even considering

Re: EnumeratedStream

2024-04-20 Thread -
On Sat, Apr 20, 2024 at 7:44 PM ІП-24 Олександр Ротань < rotan.olexa...@gmail.com> wrote: > Also enumerated stream should also support index-aware terminal > operations, which getherers are incapable of, so it will also require to > create index-aware collectors. I am not aware if this is even pos

Re: EnumeratedStream

2024-04-20 Thread ІП-24 Олександр Ротань
Also enumerated stream should also support index-aware terminal operations, which getherers are incapable of, so it will also require to create index-aware collectors. I am not aware if this is even possible, but this looks like another separate functionality in different place, and some developers

Re: EnumeratedStream

2024-04-20 Thread ІП-24 Олександр Ротань
Yes, I think every possible intermediate operation could be made index aware using gatherers. The point is: should it be turned? As a developers of jdk itself, we are not limited in a ways we could provide tools for Java users, especially when it comes to adding completely new features and not mod

Re: EnumeratedStream

2024-04-20 Thread -
My point is that we can create Gatherers that gather indexed elements (indexed gatherer), and another factory wraps the Gatherer so the index boxing and automatically performed before sending to the indexed gatherer. All other stream operations, like indexed filter, indexed collect, etc. can all be

Re: EnumeratedStream

2024-04-20 Thread ІП-24 Олександр Ротань
I am sorry, but I feel like I am missing the point of your response and how is it related to what I have said. Regarding wrapping and unwrapping indexed pairs, one of advantages of the approach I have suggested is that EnumeratedStream is still a stream and all index-unaware ops could still be app

Re: EnumeratedStream

2024-04-20 Thread -
We must convert index-processing operations to a `gather(Gatherers.scan(/* index gathering */))` immediate before the operation that uses the index, and immediately unwrap the indices afterwards. Syntactically writing such 3 lines for every index-aware operation would be weird; I actually wonder i

Re: EnumeratedStream

2024-04-20 Thread ІП-24 Олександр Ротань
I would like to correct myself a bit: indexes should be assigned at the moment an element is received from upstream, not when it is passed to processing. Not sure if it will effectively change order of execution in actual implementation, but to put it this way would be more precise вс, 21 апр. 202

Re: EnumeratedStream

2024-04-20 Thread ІП-24 Олександр Ротань
Hello again. I have imagined implementation of enumerated streams in a slightly different way. I think enumerated streams should be a separate kind of stream like parallel, sequential or some primitive stream. This way enumeration could be deferred to the time that index is being consumed, This wo

Re: EnumeratedStream

2024-04-20 Thread -
Hi Oleksandr, I fear that enumeration might not be applicable to all streams, especially parallel ones. If we have a parallel stream, we might not always process all elements in order, and even index generation can be unreliable. In addition, stream merging will become a headache. I think Gatherers

Re: EnumeratedStream

2024-04-20 Thread ІП-24 Олександр Ротань
Yes, your point about enumeration is the best way to do it, i guess, I am also voting for this. This makes the most sense considering the way that method invocation chains should be handled вс, 21 апр. 2024 г. в 00:55, David Alayachew : > I am in full support of this idea. I do also appreciate th

Re: EnumeratedStream

2024-04-20 Thread David Alayachew
I am in full support of this idea. I do also appreciate the functionality of using a BiFunction on the map method instead of a normal Function, R>. As for the actual enumeration logic, my vote is that it should simply enumerate as it arrives, with no context or care given to what came before it. C