Remix.run Logo
gavinray 10 hours ago

When you use RandomAccessFile API in JVM one of the flags allows you to mmap the contents

        try (RandomAccessFile file = new RandomAccessFile("example.dat", "rw");
             FileChannel channel = file.getChannel()) {
            
            // Map the file into memory from position 0 up to bufferSize
            MappedByteBuffer buffer = channel.map(FileChannel.MapMode.READ_WRITE, 0, bufferSize);
Once you have a mappedbytebuffer you can use MemoryLayout from FFM to view it as structured data without deserializing