public class NIOByteBufferProvider extends 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(FileChannel channel,
FileChannel.MapMode mapMode)
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
ByteBuffer |
allocate(long bufferStartPosition,
int newSize)
Allocates or maps the desired file data into memory.
|
protected ByteBuffer |
allocateDirect(long bufferStartPosition,
int newSize)
Allocates memory and copies the desired file data into it.
|
protected ByteBuffer |
allocateMappedByteBuffer(long bufferStartPosition,
int newSize)
Memory maps the desired file data into memory.
|
public static final int MINIMUM_JAVA_VERSION
public NIOByteBufferProvider(FileChannel channel, 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 ByteBuffer allocate(long bufferStartPosition, int newSize) throws IOException
bufferStartPosition - The absolute position of the start of the
buffer.newSize - The buffer size.IOException - If there is an issue mapping, aligning or allocating
the buffer.protected ByteBuffer allocateDirect(long bufferStartPosition, int newSize) throws IOException
bufferStartPosition - The absolute position of the start of the
buffer.newSize - The buffer size.IOException - If there is an issue aligning or allocating
the buffer.protected ByteBuffer allocateMappedByteBuffer(long bufferStartPosition, int newSize) throws IOException
bufferStartPosition - The absolute position of the start of the
buffer.newSize - The buffer size.IOException - If there is an issue mapping, aligning or allocating
the buffer.Copyright © 2015 Open Microscopy Environment