Package org.h2.store.fs.niomapped
Class FileNioMapped
- java.lang.Object
-
- java.nio.channels.spi.AbstractInterruptibleChannel
-
- java.nio.channels.FileChannel
-
- org.h2.store.fs.FileBase
-
- org.h2.store.fs.FileBaseDefault
-
- org.h2.store.fs.niomapped.FileNioMapped
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.nio.channels.ByteChannel
,java.nio.channels.Channel
,java.nio.channels.GatheringByteChannel
,java.nio.channels.InterruptibleChannel
,java.nio.channels.ReadableByteChannel
,java.nio.channels.ScatteringByteChannel
,java.nio.channels.SeekableByteChannel
,java.nio.channels.WritableByteChannel
class FileNioMapped extends FileBaseDefault
Uses memory mapped files. The file size is limited to 2 GB.
-
-
Field Summary
Fields Modifier and Type Field Description private java.nio.channels.FileChannel
channel
private long
fileLength
private static int
GC_TIMEOUT_MS
private java.nio.MappedByteBuffer
mapped
private java.nio.channels.FileChannel.MapMode
mode
private java.lang.String
name
-
Constructor Summary
Constructors Constructor Description FileNioMapped(java.lang.String fileName, java.lang.String mode)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static void
checkFileSizeLimit(long length)
void
force(boolean metaData)
void
implCloseChannel()
protected void
implTruncate(long newLength)
The truncate implementation.int
read(java.nio.ByteBuffer dst, long pos)
private void
reMap()
Re-map byte buffer into memory, called when file size has changed or file was created.void
setFileLength(long newLength)
long
size()
java.lang.String
toString()
java.nio.channels.FileLock
tryLock(long position, long size, boolean shared)
private void
unMap()
int
write(java.nio.ByteBuffer src, long position)
-
Methods inherited from class org.h2.store.fs.FileBaseDefault
position, position, read, truncate, write
-
Methods inherited from class org.h2.store.fs.FileBase
lock, map, read, transferFrom, transferTo, write
-
Methods inherited from class java.nio.channels.spi.AbstractInterruptibleChannel
begin, close, end, isOpen
-
-
-
-
Field Detail
-
GC_TIMEOUT_MS
private static final int GC_TIMEOUT_MS
- See Also:
- Constant Field Values
-
name
private final java.lang.String name
-
mode
private final java.nio.channels.FileChannel.MapMode mode
-
channel
private java.nio.channels.FileChannel channel
-
mapped
private java.nio.MappedByteBuffer mapped
-
fileLength
private long fileLength
-
-
Method Detail
-
unMap
private void unMap() throws java.io.IOException
- Throws:
java.io.IOException
-
reMap
private void reMap() throws java.io.IOException
Re-map byte buffer into memory, called when file size has changed or file was created.- Throws:
java.io.IOException
-
checkFileSizeLimit
private static void checkFileSizeLimit(long length) throws java.io.IOException
- Throws:
java.io.IOException
-
implCloseChannel
public void implCloseChannel() throws java.io.IOException
- Overrides:
implCloseChannel
in classFileBase
- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
size
public long size() throws java.io.IOException
- Specified by:
size
in interfacejava.nio.channels.SeekableByteChannel
- Specified by:
size
in classjava.nio.channels.FileChannel
- Throws:
java.io.IOException
-
read
public int read(java.nio.ByteBuffer dst, long pos) throws java.io.IOException
-
implTruncate
protected void implTruncate(long newLength) throws java.io.IOException
Description copied from class:FileBaseDefault
The truncate implementation.- Specified by:
implTruncate
in classFileBaseDefault
- Parameters:
newLength
- the new size- Throws:
java.io.IOException
- on failure
-
setFileLength
public void setFileLength(long newLength) throws java.io.IOException
- Throws:
java.io.IOException
-
force
public void force(boolean metaData) throws java.io.IOException
-
write
public int write(java.nio.ByteBuffer src, long position) throws java.io.IOException
-
-