MemorySegment.mapFromPath vs FileChannel.map
Uwe Schindler
uschindler at apache.org
Fri Apr 24 08:48:25 UTC 2020
Hi,
Thanks for pointing this out. I was in a discussion the last two days about Lucene and it's MmapDirectory (see other thread).
I mentioned this there, too. So I fully agree. The offset is missing which makes the api unsymmetric to FileChannel. It so forces you to map everything of a file, which is not really a memory exhaustion problem than more an address space problem: With large files and address space fragmentation, it might be still a good idea to allow uses to map parts of files.
So +1
Uwe
Am April 24, 2020 8:21:04 AM UTC schrieb Philippe Marschall <kustos at gmx.net>:
>Hello
>
>I noted a difference between MemorySegment.mapFromPath and
>FileChannel.map. MemorySegment.mapFromPath only allows to specify a
>length but not an offset. Is this intentional or an oversight? Only
>having the ability to map a subsgement from the start of the file seems
>strange. Especially given that FileChannelImpl.mapInternal already
>offers an offset.
>
>Also the FileChannel methods use the map mode as the first argument
>whereas MemorySegment uses it as the last.
>
>Cheers
>Philippe
More information about the panama-dev
mailing list