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:
Closeable
,AutoCloseable
,ByteChannel
,Channel
,GatheringByteChannel
,InterruptibleChannel
,ReadableByteChannel
,ScatteringByteChannel
,SeekableByteChannel
,WritableByteChannel
Uses memory mapped files.
The file size is limited to 2 GB.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.nio.channels.FileChannel
FileChannel.MapMode
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate FileChannel
private long
private static final int
private MappedByteBuffer
private final FileChannel.MapMode
private final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
checkFileSizeLimit
(long length) void
force
(boolean metaData) void
protected void
implTruncate
(long newLength) The truncate implementation.int
read
(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()
toString()
tryLock
(long position, long size, boolean shared) private void
unMap()
int
write
(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.FileChannel
lock, map, open, open, read, tryLock, write
Methods inherited from class java.nio.channels.spi.AbstractInterruptibleChannel
begin, close, end, isOpen
-
Field Details
-
GC_TIMEOUT_MS
private static final int GC_TIMEOUT_MS- See Also:
-
name
-
mode
-
channel
-
mapped
-
fileLength
private long fileLength
-
-
Constructor Details
-
FileNioMapped
FileNioMapped(String fileName, String mode) throws IOException - Throws:
IOException
-
-
Method Details
-
unMap
- Throws:
IOException
-
reMap
Re-map byte buffer into memory, called when file size has changed or file was created.- Throws:
IOException
-
checkFileSizeLimit
- Throws:
IOException
-
implCloseChannel
- Overrides:
implCloseChannel
in classFileBase
- Throws:
IOException
-
toString
-
size
- Specified by:
size
in interfaceSeekableByteChannel
- Specified by:
size
in classFileChannel
- Throws:
IOException
-
read
- Overrides:
read
in classFileBase
- Throws:
IOException
-
implTruncate
Description copied from class:FileBaseDefault
The truncate implementation.- Specified by:
implTruncate
in classFileBaseDefault
- Parameters:
newLength
- the new size- Throws:
IOException
- on failure
-
setFileLength
- Throws:
IOException
-
force
- Overrides:
force
in classFileBase
- Throws:
IOException
-
write
- Overrides:
write
in classFileBase
- Throws:
IOException
-
tryLock
- Overrides:
tryLock
in classFileBase
- Throws:
IOException
-