org.apache.ignite.internal.mem.file

## 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
`static int` `MAP_RW`

### Constructor Summary

Constructors
Constructor and Description
`MappedFile(File name, long size)`

### Method Summary

Methods
`long` `address()`
`void` `close()`
`RandomAccessFile` `file()` Gets underlying random access file.
`static long` `map(RandomAccessFile f, int mode, long start, long size)` Maps the given region of the file.
`long` `size()`
`DirectMemoryRegion` `slice(long offset)` Gets a sub-region of this region starting from the given offset.
`static void` `unmap(long addr, long size)` Un-maps the given region of the file.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### 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:
  `close` in interface `Closeable`
Specified by:
  `close` in interface `AutoCloseable`
Throws:
  `IOException`

#### address

    public final long address()

Specified by:
  `address` in interface `DirectMemoryRegion`
Returns:
  Region start address.

#### size

    public final long size()

Specified by:
  `size` in interface `DirectMemoryRegion`
Returns:
  Region size.

#### 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.

2017 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.2.0
Release Date | : September 15 2017