public class NIOByteBufferProvider
extends java.lang.Object
FileChannel.map()
usage on platforms where it's unlikely to
give us problems and heap allocation where it is. References:
Modifier and Type | Field and Description |
---|---|
static int |
MINIMUM_JAVA_VERSION
The minimum Java version we know is safe for memory mapped I/O.
|
Constructor and Description |
---|
NIOByteBufferProvider(java.nio.channels.FileChannel channel,
java.nio.channels.FileChannel.MapMode mapMode)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
java.nio.ByteBuffer |
allocate(long bufferStartPosition,
int newSize)
Allocates or maps the desired file data into memory.
|
protected java.nio.ByteBuffer |
allocateDirect(long bufferStartPosition,
int newSize)
Allocates memory and copies the desired file data into it.
|
protected java.nio.ByteBuffer |
allocateMappedByteBuffer(long bufferStartPosition,
int newSize)
Memory maps the desired file data into memory.
|
public static final int MINIMUM_JAVA_VERSION
public NIOByteBufferProvider(java.nio.channels.FileChannel channel, java.nio.channels.FileChannel.MapMode mapMode)
channel
- File channel to allocate or map byte buffers from.mapMode
- The map mode. Required but only used if memory mapped I/O
is to occur.public java.nio.ByteBuffer allocate(long bufferStartPosition, int newSize) throws java.io.IOException
bufferStartPosition
- The absolute position of the start of the
buffer.newSize
- The buffer size.java.io.IOException
- If there is an issue mapping, aligning or allocating
the buffer.protected java.nio.ByteBuffer allocateDirect(long bufferStartPosition, int newSize) throws java.io.IOException
bufferStartPosition
- The absolute position of the start of the
buffer.newSize
- The buffer size.java.io.IOException
- If there is an issue aligning or allocating
the buffer.protected java.nio.ByteBuffer allocateMappedByteBuffer(long bufferStartPosition, int newSize) throws java.io.IOException
bufferStartPosition
- The absolute position of the start of the
buffer.newSize
- The buffer size.java.io.IOException
- If there is an issue mapping, aligning or allocating
the buffer.Copyright © 2014 Open Microscopy Environment