public abstract class BlockMappedInput extends java.lang.Object implements BasicInput
Note: DO NOT use an instance
of this class from multiple threads - see Unmapper.
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_BLOCKSIZE
Default maximum size in bytes for mapped blocks.
|
static long |
DEFAULT_EXPIRYMILLIS
Default time in milliseconds after which buffers will be discarded.
|
| Modifier | Constructor and Description |
|---|---|
protected |
BlockMappedInput(java.nio.channels.FileChannel channel,
long pos,
long size,
java.lang.String logName,
int blockSize)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract java.nio.MappedByteBuffer |
acquireBlock(int iblock)
Obtains a buffer corresponding to a named block of the stream.
|
static BlockMappedInput |
createInput(java.nio.channels.FileChannel channel,
long pos,
long size,
java.lang.String logName,
boolean caching)
Constructs an instance that does or does not support caching.
|
static BlockMappedInput |
createInput(java.nio.channels.FileChannel channel,
long pos,
long size,
java.lang.String logName,
int blockSize,
long expiryMillis)
Constructs an instance with explicit configuration.
|
int |
getBlockCount()
Returns the number of mapped blocks used.
|
long |
getOffset()
Returns the curent position in this stream
(optional operation).
|
boolean |
isRandom()
Indicates whether this object supports random access.
|
byte |
readByte()
Reads a byte from the stream.
|
double |
readDouble()
Reads an 8-byte floating point value from the stream.
|
float |
readFloat()
Reads a 4-byte floating point value from the stream.
|
int |
readInt()
Reads a 4-byte integer from the stream.
|
long |
readLong()
Reads an 8-byte integer from the stream.
|
short |
readShort()
Reads a 2-byte integer from the stream.
|
void |
seek(long offset)
Moves the current position of this stream to a given byte offset
(optional operation).
|
void |
skip(long nbyte)
Skips a given number of bytes forwards through the stream.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclosepublic static final int DEFAULT_BLOCKSIZE
public static final long DEFAULT_EXPIRYMILLIS
protected BlockMappedInput(java.nio.channels.FileChannel channel,
long pos,
long size,
java.lang.String logName,
int blockSize)
throws java.io.IOException
channel - file channel, preferably read-onlypos - offset into file of stream startsize - number of bytes in streamlogName - name for mapped region used in logging messagesblockSize - (maximum) number of bytes per mapped blockjava.io.IOExceptionpublic byte readByte()
throws java.io.IOException
BasicInputreadByte in interface BasicInputjava.io.IOExceptionpublic short readShort()
throws java.io.IOException
BasicInputreadShort in interface BasicInputjava.io.IOExceptionpublic int readInt()
throws java.io.IOException
BasicInputreadInt in interface BasicInputjava.io.IOExceptionpublic long readLong()
throws java.io.IOException
BasicInputreadLong in interface BasicInputjava.io.IOExceptionpublic float readFloat()
throws java.io.IOException
BasicInputreadFloat in interface BasicInputjava.io.IOExceptionpublic double readDouble()
throws java.io.IOException
BasicInputreadDouble in interface BasicInputjava.io.IOExceptionpublic boolean isRandom()
BasicInputisRandom in interface BasicInputpublic void seek(long offset)
throws java.io.IOException
BasicInputseek in interface BasicInputjava.io.IOExceptionpublic long getOffset()
BasicInputgetOffset in interface BasicInputpublic void skip(long nbyte)
throws java.io.IOException
BasicInputskip in interface BasicInputnbyte - number of bytes to skipjava.io.IOExceptionpublic int getBlockCount()
protected abstract java.nio.MappedByteBuffer acquireBlock(int iblock)
throws java.io.IOException
iblock - block indexjava.io.IOExceptionpublic static BlockMappedInput createInput(java.nio.channels.FileChannel channel, long pos, long size, java.lang.String logName, boolean caching) throws java.io.IOException
channel - file channel, preferably read-onlypos - offset into file of stream startsize - number of bytes in streamlogName - name for mapped region used in logging messagescaching - whether buffers are cachedjava.io.IOExceptionpublic static BlockMappedInput createInput(java.nio.channels.FileChannel channel, long pos, long size, java.lang.String logName, int blockSize, long expiryMillis) throws java.io.IOException
expiryMillis parameter controls caching.
If zero, the current buffer is discarded an unmapped as soon
as a different one is used. Otherwise, an attempt is made to
discard buffers only after they have been unused for a certain
number of milliseconds.channel - file channel, preferably read-onlypos - offset into file of stream startsize - number of bytes in streamlogName - name for mapped region used in logging messagesblockSize - maximum number of bytes per blockexpiryMillis - buffer caching period in millisecondsjava.io.IOExceptionCopyright © 2017 Central Laboratory of the Research Councils. All Rights Reserved.