Class MappedFile
- java.lang.Object
-
- org.apache.ignite.internal.mem.file.MappedFile
-
- All Implemented Interfaces:
Closeable,AutoCloseable,DirectMemoryRegion
public class MappedFile extends Object implements Closeable, DirectMemoryRegion
-
-
Field Summary
Fields Modifier and Type Field Description static intMAP_RW
-
Constructor Summary
Constructors Constructor Description MappedFile(File name, long size)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description longaddress()voidclose()RandomAccessFilefile()Gets underlying random access file.static longmap(RandomAccessFile f, int mode, long start, long size)Maps the given region of the file.longsize()DirectMemoryRegionslice(long offset)Gets a sub-region of this region starting from the given offset.static voidunmap(long addr, long size)Un-maps the given region of the file.
-
-
-
Field Detail
-
MAP_RW
public static final int MAP_RW
- See Also:
- Constant Field Values
-
-
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.
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
address
public final long address()
- Specified by:
addressin interfaceDirectMemoryRegion- Returns:
- Region start address.
-
size
public final long size()
- Specified by:
sizein interfaceDirectMemoryRegion- Returns:
- Region size.
-
slice
public DirectMemoryRegion slice(long offset)
Gets a sub-region of this region starting from the given offset.- Specified by:
slicein interfaceDirectMemoryRegion- 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.
-
-