Class FileMappedMemoryRegion

    • Constructor Detail

      • FileMappedMemoryRegion

        public FileMappedMemoryRegion​(File pFile,
                                      long pLengthInBytes,
                                      StandardOpenOption... pStandardOpenOption)
                               throws IOException
        Instanciates a file mapped memory region given a file, length in bytes, and standard open options.
        Parameters:
        pFile - file
        pLengthInBytes - length in bytes
        pStandardOpenOption - standard open options
        Throws:
        IOException - thrown if problem while creating file or memory mapping
      • FileMappedMemoryRegion

        public FileMappedMemoryRegion​(File pFile,
                                      long pPositionInBytes,
                                      long pLengthInBytes,
                                      StandardOpenOption... pStandardOpenOption)
                               throws IOException
        Instanciates a file mapped memory region given a file, position in file, length in bytes, and standard open options.
        Parameters:
        pFile - file
        pPositionInBytes - position in bytes within file
        pLengthInBytes - length in bytes
        pStandardOpenOption - standard open options
        Throws:
        IOException - thrown if problem while creating file or memory mapping
      • FileMappedMemoryRegion

        public FileMappedMemoryRegion​(FileChannel pFileChannel,
                                      long pPositionInBytes,
                                      long pLengthInBytes,
                                      StandardOpenOption... pStandardOpenOption)
                               throws IOException
        Instanciates a file mapped memory region given a file channel, position in file, length in bytes, and standard open options.
        Parameters:
        pFileChannel - file channel
        pPositionInBytes - position in bytes within file
        pLengthInBytes - length in bytes
        pStandardOpenOption - standard open options
        Throws:
        IOException - thrown if problem while creating file or memory mapping
    • Method Detail

      • createNewFileMappedMemoryRegion

        public FileMappedMemoryRegion createNewFileMappedMemoryRegion​(File pFile,
                                                                      long pLengthInBytes)
                                                               throws IOException
        Creates a new file of given length and maps it to memory.
        Parameters:
        pFile - file length
        pLengthInBytes - length in bytes
        Returns:
        file mapped memory region
        Throws:
        IOException - thrown if problem while creating file or memory mapping
      • createNewSparseFileMappedMemoryRegion

        public FileMappedMemoryRegion createNewSparseFileMappedMemoryRegion​(File pFile,
                                                                            long pLengthInBytes)
                                                                     throws IOException
        Creates new sparse file and maps it to memory.
        Parameters:
        pFile - file
        pLengthInBytes - length in bytes
        Returns:
        file mapped memory region
        Throws:
        IOException - thrown if problem while creating file or memory mapping
      • openExistingFileMappedMemoryRegion

        public FileMappedMemoryRegion openExistingFileMappedMemoryRegion​(File pFile,
                                                                         long pLengthInBytes)
                                                                  throws IOException
        Opens an existing file and maps it to memory
        Parameters:
        pFile - file
        pLengthInBytes - length in bytes
        Returns:
        file mapped memory region
        Throws:
        IOException - thrown if problem while creating file or memory mapping
      • openExistingFileMappedMemoryRegion

        public FileMappedMemoryRegion openExistingFileMappedMemoryRegion​(File pFile,
                                                                         long pPositionInBytes,
                                                                         long pLengthInBytes)
                                                                  throws IOException
        Opens an existing file and maps it to memory.
        Parameters:
        pFile - file
        pPositionInBytes - position in bytes
        pLengthInBytes - length in bytes
        Returns:
        file mapped memory region
        Throws:
        IOException - thrown if problem while creating file or memory mapping
      • openReadOnlyExistingFileMappedMemoryRegion

        public FileMappedMemoryRegion openReadOnlyExistingFileMappedMemoryRegion​(File pFile,
                                                                                 long pLengthInBytes)
                                                                          throws IOException
        Opens an existing file read-only and maps it to memory.
        Parameters:
        pFile - file
        pLengthInBytes - length in bytes
        Returns:
        file mapped memory region
        Throws:
        IOException - thrown if problem while creating file or memory mapping
      • openReadOnlyExistingFileMappedMemoryRegion

        public FileMappedMemoryRegion openReadOnlyExistingFileMappedMemoryRegion​(File pFile,
                                                                                 long pPositionInBytes,
                                                                                 long pLengthInBytes)
                                                                          throws IOException
        Opens an existing file read-only and maps it to memory.
        Parameters:
        pFile - file
        pPositionInBytes - position in bytes
        pLengthInBytes - length in bytes
        Returns:
        file mapped memory region
        Throws:
        IOException - thrown if problem while creating file or memory mapping
      • force

        public void force()
        Description copied from interface: MappableMemory
        TODO: figue out what this is really about
        Specified by:
        force in interface MappableMemory
      • subRegion

        public OffHeapMemory subRegion​(long pOffset,
                                       long pLenghInBytes)
        Description copied from interface: ContiguousMemoryInterface
        Returns a contiguous memory object representing for a memory sub region.
        Specified by:
        subRegion in interface ContiguousMemoryInterface
        Parameters:
        pOffset - offset in bytes
        pLenghInBytes - length in bytes
        Returns:
        contiguous memory for sub region
      • resize

        public long resize​(long pNewLength)
        Description copied from interface: Resizable
        Resizes this memory object.
        Specified by:
        resize in interface Resizable
        Parameters:
        pNewLength - new length.
        Returns:
        new length
      • free

        public void free()
        Description copied from interface: Freeable
        Free this object, which means that the underlying ressources are released.
        Specified by:
        free in interface Freeable
        Overrides:
        free in class MemoryBase
      • getCleaner

        public Cleaner getCleaner()
        Description copied from interface: Cleanable
        Returns the cleaner for this object.
        Specified by:
        getCleaner in interface Cleanable
        Returns:
        cleaner runnable