[foreign-memaccess+abi] RFR: 8264933: Improve stream support in memory segments

Rémi Forax github.com+828220+forax at openjdk.java.net
Fri Apr 9 09:56:27 UTC 2021


On Thu, 8 Apr 2021 15:56:32 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> This patch improves stream support for memory segments - it does so in two ways:
> 
> * first, tweaking the `MemorySegment::spliterator` method to take an *element layout*, instead of a full sequence layout whose size had to match that of the segment.
> * secondly, by adding convenience methods to create streams directly, w/o needing to call `StreamSupport.stream`. As for `Collection`, two methods are provided: `MemorySegment::stream` and `MemorySegment::parallelStream`.
> 
> I've fixed up the documentation in places - I realized that, for example, the javadoc for `MemorySegment::spliterator` was missing a `@throws` clause for when there's a size mismatch between layout and segment.
> Also, I've removed scope liveness check on the spliterator call - after all, a spliterator is going to make slices - a liveness check will occur when the slice is accessed.

I fail to see how a Spliterator that asks a stream to do has many recursive calls/creates as many sub-segments has the number of elements is a good idea ?

-------------

PR: https://git.openjdk.java.net/panama-foreign/pull/494


More information about the panama-dev mailing list