Class FileMappedMemoryRegion
- java.lang.Object
-
- net.haesleinhuepf.clij.coremem.rgc.FreeableBase
-
- net.haesleinhuepf.clij.coremem.MemoryBase
-
- net.haesleinhuepf.clij.coremem.MappedMemoryBase
-
- net.haesleinhuepf.clij.coremem.memmap.FileMappedMemoryRegion
-
- All Implemented Interfaces:
ContiguousMemoryInterface,BridJPointerWrappable,ByteBufferWrappable,Copyable<ContiguousMemoryInterface>,CopyFromToJavaArray,CopyFromToNIOBuffers,CopyRangeFromToJavaArray,JNAPointerWrappable,MappableMemory,MemoryTyped,PointerAccessible,RangeCopyable<MemoryBase>,ReadAt,ReadAtAligned,ReadWriteBytesFileChannel,Resizable,SizedInBytes,WriteAt,WriteAtAligned,Cleanable,Freeable
public class FileMappedMemoryRegion extends MappedMemoryBase implements MappableMemory, Resizable, SizedInBytes, ContiguousMemoryInterface, Freeable
File mapped memory region. Implements the contiguous memory interface but is stored in a file.- Author:
- royer
-
-
Field Summary
-
Fields inherited from class net.haesleinhuepf.clij.coremem.MemoryBase
mAddressInBytes, mIsFree, mLengthInBytes
-
-
Constructor Summary
Constructors Constructor Description FileMappedMemoryRegion(File pFile, long pPositionInBytes, long pLengthInBytes, StandardOpenOption... pStandardOpenOption)Instanciates a file mapped memory region given a file, position in file, length in bytes, and standard open options.FileMappedMemoryRegion(File pFile, long pLengthInBytes, StandardOpenOption... pStandardOpenOption)Instanciates a file mapped memory region given a file, length in bytes, and standard open options.FileMappedMemoryRegion(FileChannel pFileChannel, long pPositionInBytes, long pLengthInBytes, StandardOpenOption... pStandardOpenOption)Instanciates a file mapped memory region given a file channel, position in file, length in bytes, and standard open options.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FileMappedMemoryRegioncreateNewFileMappedMemoryRegion(File pFile, long pLengthInBytes)Creates a new file of given length and maps it to memory.FileMappedMemoryRegioncreateNewSparseFileMappedMemoryRegion(File pFile, long pLengthInBytes)Creates new sparse file and maps it to memory.voidforce()TODO: figue out what this is really aboutvoidfree()Free this object, which means that the underlying ressources are released.CleanergetCleaner()Returns the cleaner for this object.MemoryTypegetMemoryType()Returns this memory object type.longmap()Maps this memory object.FileMappedMemoryRegionopenExistingFileMappedMemoryRegion(File pFile, long pLengthInBytes)Opens an existing file and maps it to memoryFileMappedMemoryRegionopenExistingFileMappedMemoryRegion(File pFile, long pPositionInBytes, long pLengthInBytes)Opens an existing file and maps it to memory.FileMappedMemoryRegionopenReadOnlyExistingFileMappedMemoryRegion(File pFile, long pLengthInBytes)Opens an existing file read-only and maps it to memory.FileMappedMemoryRegionopenReadOnlyExistingFileMappedMemoryRegion(File pFile, long pPositionInBytes, long pLengthInBytes)Opens an existing file read-only and maps it to memory.longresize(long pNewLength)Resizes this memory object.OffHeapMemorysubRegion(long pOffset, long pLenghInBytes)Returns a contiguous memory object representing for a memory sub region.StringtoString()voidunmap()Unmaps this memory object.-
Methods inherited from class net.haesleinhuepf.clij.coremem.MappedMemoryBase
isCurrentlyMapped, setCurrentlyMapped
-
Methods inherited from class net.haesleinhuepf.clij.coremem.MemoryBase
copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyRangeTo, copyTo, copyTo, copyTo, copyTo, copyTo, copyTo, copyTo, copyTo, copyTo, copyTo, copyTo, copyTo, copyTo, copyTo, copyTo, copyTo, getAddress, getBridJPointer, getByte, getByteAligned, getByteBuffer, getChar, getCharAligned, getDouble, getDoubleAligned, getFloat, getFloatAligned, getInt, getIntAligned, getJNAPointer, getLong, getLongAligned, getShort, getShortAligned, getSizeInBytes, isFree, readBytesFromFileChannel, readBytesFromFileChannel, setByte, setByteAligned, setChar, setCharAligned, setDouble, setDoubleAligned, setFloat, setFloatAligned, setInt, setIntAligned, setLong, setLongAligned, setShort, setShortAligned, writeBytesToFileChannel, writeBytesToFileChannel
-
Methods inherited from class net.haesleinhuepf.clij.coremem.rgc.FreeableBase
complainIfFreed
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.haesleinhuepf.clij.coremem.interfaces.BridJPointerWrappable
getBridJPointer
-
Methods inherited from interface net.haesleinhuepf.clij.coremem.interfaces.ByteBufferWrappable
getByteBuffer
-
Methods inherited from interface net.haesleinhuepf.clij.coremem.interfaces.Copyable
copyFrom, copyTo
-
Methods inherited from interface net.haesleinhuepf.clij.coremem.interfaces.CopyFromToJavaArray
copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyTo, copyTo, copyTo, copyTo, copyTo, copyTo, copyTo
-
Methods inherited from interface net.haesleinhuepf.clij.coremem.interfaces.CopyFromToNIOBuffers
copyFrom, copyTo
-
Methods inherited from interface net.haesleinhuepf.clij.coremem.interfaces.CopyRangeFromToJavaArray
copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyFrom, copyTo, copyTo, copyTo, copyTo, copyTo, copyTo, copyTo
-
Methods inherited from interface net.haesleinhuepf.clij.coremem.rgc.Freeable
complainIfFreed, isFree
-
Methods inherited from interface net.haesleinhuepf.clij.coremem.interfaces.JNAPointerWrappable
getJNAPointer
-
Methods inherited from interface net.haesleinhuepf.clij.coremem.interfaces.MappableMemory
isCurrentlyMapped
-
Methods inherited from interface net.haesleinhuepf.clij.coremem.interfaces.PointerAccessible
getAddress
-
Methods inherited from interface net.haesleinhuepf.clij.coremem.interfaces.ReadAt
getByte, getChar, getDouble, getFloat, getInt, getLong, getShort
-
Methods inherited from interface net.haesleinhuepf.clij.coremem.interfaces.ReadAtAligned
getByteAligned, getCharAligned, getDoubleAligned, getFloatAligned, getIntAligned, getLongAligned, getShortAligned
-
Methods inherited from interface net.haesleinhuepf.clij.coremem.interfaces.ReadWriteBytesFileChannel
readBytesFromFileChannel, readBytesFromFileChannel, writeBytesToFileChannel, writeBytesToFileChannel
-
Methods inherited from interface net.haesleinhuepf.clij.coremem.interfaces.SizedInBytes
getSizeInBytes
-
Methods inherited from interface net.haesleinhuepf.clij.coremem.interfaces.WriteAt
setByte, setChar, setDouble, setFloat, setInt, setLong, setShort
-
Methods inherited from interface net.haesleinhuepf.clij.coremem.interfaces.WriteAtAligned
setByteAligned, setCharAligned, setDoubleAligned, setFloatAligned, setIntAligned, setLongAligned, setShortAligned
-
-
-
-
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- filepLengthInBytes- length in bytespStandardOpenOption- 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- filepPositionInBytes- position in bytes within filepLengthInBytes- length in bytespStandardOpenOption- 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 channelpPositionInBytes- position in bytes within filepLengthInBytes- length in bytespStandardOpenOption- 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 lengthpLengthInBytes- 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- filepLengthInBytes- 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- filepLengthInBytes- 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- filepPositionInBytes- position in bytespLengthInBytes- 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- filepLengthInBytes- 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- filepPositionInBytes- position in bytespLengthInBytes- length in bytes- Returns:
- file mapped memory region
- Throws:
IOException- thrown if problem while creating file or memory mapping
-
map
public long map()
Description copied from interface:MappableMemoryMaps this memory object.- Specified by:
mapin interfaceMappableMemory- Specified by:
mapin classMappedMemoryBase- Returns:
- mapping address
-
force
public void force()
Description copied from interface:MappableMemoryTODO: figue out what this is really about- Specified by:
forcein interfaceMappableMemory
-
unmap
public void unmap()
Description copied from interface:MappableMemoryUnmaps this memory object.- Specified by:
unmapin interfaceMappableMemory- Specified by:
unmapin classMappedMemoryBase
-
subRegion
public OffHeapMemory subRegion(long pOffset, long pLenghInBytes)
Description copied from interface:ContiguousMemoryInterfaceReturns a contiguous memory object representing for a memory sub region.- Specified by:
subRegionin interfaceContiguousMemoryInterface- Parameters:
pOffset- offset in bytespLenghInBytes- length in bytes- Returns:
- contiguous memory for sub region
-
getMemoryType
public MemoryType getMemoryType()
Description copied from interface:MemoryTypedReturns this memory object type.- Specified by:
getMemoryTypein interfaceMemoryTyped- Specified by:
getMemoryTypein classMemoryBase- Returns:
- memory type.
-
resize
public long resize(long pNewLength)
Description copied from interface:ResizableResizes this memory object.
-
free
public void free()
Description copied from interface:FreeableFree this object, which means that the underlying ressources are released.- Specified by:
freein interfaceFreeable- Overrides:
freein classMemoryBase
-
getCleaner
public Cleaner getCleaner()
Description copied from interface:CleanableReturns the cleaner for this object.- Specified by:
getCleanerin interfaceCleanable- Returns:
- cleaner runnable
-
-