Class MappedFile

    • Constructor Detail

      • MappedFile

        public MappedFile​(File name,
                          long size)
                   throws IOException
        Parameters:
        name - File path.
        size - Expected file size. If size is 0, the existing size will be used.
        Throws:
        IOException - If failed to open the file or memory-map it.
    • Method Detail

      • file

        public final RandomAccessFile file()
        Gets underlying random access file.
        Returns:
        Random access file.
      • address

        public final long address()
        Specified by:
        address in interface DirectMemoryRegion
        Returns:
        Region start address.
      • slice

        public DirectMemoryRegion slice​(long offset)
        Gets a sub-region of this region starting from the given offset.
        Specified by:
        slice in interface DirectMemoryRegion
        Parameters:
        offset - Offset within this region.
        Returns:
        Sub-region.
      • map

        public static long map​(RandomAccessFile f,
                               int mode,
                               long start,
                               long size)
                        throws IOException
        Maps the given region of the file.
        Parameters:
        f - File to map.
        mode - Mode to map.
        start - Mapping start offset within the file.
        size - Size of file to map.
        Returns:
        Pointer to the mapped memory region.
        Throws:
        IOException
      • unmap

        public static void unmap​(long addr,
                                 long size)
        Un-maps the given region of the file.
        Parameters:
        addr - Previously mapped address to un-map.
        size - Size of the mapped file.