Memory Mapped file segment (file is empty)
Paul Sandoz
paul.sandoz at oracle.com
Thu Jun 25 00:04:30 UTC 2020
Hi Johannes,
This is the correct list. Feedback on the API and its usability is very important, as well as whether the implementation works as expected.
This was fixed in https://bugs.openjdk.java.net/browse/JDK-8246095 <https://bugs.openjdk.java.net/browse/JDK-8246095>
https://github.com/openjdk/panama-foreign/blob/foreign-memaccess/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/MappedMemorySegmentImpl.java#L102 <https://github.com/openjdk/panama-foreign/blob/foreign-memaccess/src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/MappedMemorySegmentImpl.java#L102>
What JDK build are you using?
Paul.
> On Jun 24, 2020, at 3:48 PM, Johannes Lichtenberger <lichtenberger.johannes at gmail.com> wrote:
>
> Hi,
>
> I guess that's not the right mailinglist to ask for help with the API, but
> maybe you can point me at least somewhere.
>
> Currently I face the problem, that I can't get a memory segment on an empty
> file when I want to memory map a file. However, a writer would write to the
> memory mapped file.
>
> I want to be able to swap a rather old RandomAccessFile based
> implementation with a memory mapped file implementation. The two classes
> (actually three, but only the FileReader and FileWriter matters) are rather
> simple.
>
> The old package:
>
> https://github.com/sirixdb/sirix/tree/master/bundles/sirix-core/src/main/java/org/sirix/io/file
>
>
> and the new package
>
> https://github.com/sirixdb/sirix/tree/master/bundles/sirix-core/src/main/java/org/sirix/io/memorymapped
>
> This line fails if the underlying file size is 0:
>
> https://github.com/sirixdb/sirix/blob/7bdbd5d17a034f02902f8f7dd0ef7012d89c81fb/bundles/sirix-core/src/main/java/org/sirix/io/memorymapped/MemoryMappedFileWriter.java#L83
>
> Stacktrace (Precondition fails, so I'm not using the API in the intended
> way):
>
> java.lang.IllegalArgumentException: Requested bytes size must be > 0.
>
> at
> jdk.incubator.foreign/jdk.internal.foreign.Utils.makeMappedSegment(Utils.java:140)
> at
> jdk.incubator.foreign/jdk.incubator.foreign.MemorySegment.mapFromPath(MemorySegment.java:398)
> at
> org.sirix.io.memorymapped.MemoryMappedFileWriter.<init>(MemoryMappedFileWriter.java:83)
>
>
> So, it might be easiest to write a more or less direct conversion to the
> Foreign Memory API. Maybe someone can help or point me to a helpful
> Mailinglist/Forum/whatever.
>
> Kind regards
> Johannes
More information about the panama-dev
mailing list