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

Maurizio Cimadamore mcimadamore at openjdk.java.net
Wed Apr 21 20:33:45 UTC 2021


> 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.

Maurizio Cimadamore has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains five additional commits since the last revision:

 - Fix reference to parallelStream from javadoc
 - Rename MemorySegment::stream() to elements()
   Drop parallelStream()
 - Merge branch 'foreign-memaccess+abi' into segment+streams
 - Fix javadoc sample
 - Initial push

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

Changes:
  - all: https://git.openjdk.java.net/panama-foreign/pull/494/files
  - new: https://git.openjdk.java.net/panama-foreign/pull/494/files/59033546..c924187e

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=494&range=01
 - incr: https://webrevs.openjdk.java.net/?repo=panama-foreign&pr=494&range=00-01

  Stats: 23952 lines in 408 files changed: 18204 ins; 3700 del; 2048 mod
  Patch: https://git.openjdk.java.net/panama-foreign/pull/494.diff
  Fetch: git fetch https://git.openjdk.java.net/panama-foreign pull/494/head:pull/494

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


More information about the panama-dev mailing list