public class HollowBlobInput
extends java.lang.Object
implements java.io.Closeable
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes underlying InputStream/RandomAccessFile and releases any system resources associated with the Hollow Blob Input.
|
BlobByteBuffer |
getBuffer() |
long |
getFilePointer()
Returns the current offset in this input at which the next read would occur.
|
java.lang.Object |
getInput() |
MemoryMode |
getMemoryMode() |
static HollowBlobInput |
modeBasedSelector(MemoryMode mode,
HollowConsumer.Blob blob)
Initialize the Hollow Blob Input object from the Hollow Consumer blob's Input Stream or Random Access File,
depending on the configured memory mode.
|
static HollowBlobInput |
randomAccess(java.io.File f)
Initialize a random access Hollow Blob input object from a file.
|
static HollowBlobInput |
randomAccess(java.io.File f,
int singleBufferCapacity)
Useful for testing with custom buffer capacity
|
int |
read()
Reads the next byte of data from the input stream by relaying the call to the underlying
DataInputStream or
RandomAccessFile . |
int |
read(byte[] b,
int off,
int len)
Reads up to
len bytes of data from the HollowBlobInput by relaying the call to the underlying
DataInputStream or RandomAccessFile into an array of bytes. |
int |
readInt()
Reads 4 bytes from the input (at the current file pointer) into a signed 32-bit int, and advances the offset
in input.
|
long |
readLong()
Reads 8 bytes from the input (at the current file pointer) into a signed 64-bit long, and advances the offset
in input.
|
short |
readShort()
Reads two bytes from the input (at the current file pointer) into a signed 16-bit short, and advances the offset
in input.
|
java.lang.String |
readUTF()
Reads in a string from this file, encoded using modified UTF-8
format, and advances the offset in input.
|
void |
seek(long pos)
Sets the file-pointer to the desired offset measured from the beginning of the file by relaying the call to the
underlying
RandomAccessFile . |
static HollowBlobInput |
serial(byte[] bytes)
Shorthand for calling
serial(InputStream) on a byte[] |
static HollowBlobInput |
serial(java.io.InputStream is)
Initialize a serial access Hollow Blob input object from an input stream.
|
long |
skipBytes(long n)
This method attempts to skip a specified number of bytes and returns the actual number of bytes skipped.
|
public MemoryMode getMemoryMode()
public static HollowBlobInput modeBasedSelector(MemoryMode mode, HollowConsumer.Blob blob) throws java.io.IOException
mode
- Configured memory modeblob
- Hollow Consumer blobjava.io.IOException
- if the Hollow Blob Input couldn't be initializedpublic static HollowBlobInput randomAccess(java.io.File f) throws java.io.IOException
f
- file containing the Hollow blobjava.io.IOException
- if the mmap operation reported an IOExceptionpublic static HollowBlobInput randomAccess(java.io.File f, int singleBufferCapacity) throws java.io.IOException
java.io.IOException
public static HollowBlobInput serial(byte[] bytes)
serial(InputStream)
on a byte[]public static HollowBlobInput serial(java.io.InputStream is)
is
- input stream containing for Hollow blob datapublic int read() throws java.io.IOException
DataInputStream
or
RandomAccessFile
. The byte is returned as an integer in the range 0 to 255.java.io.IOException
- if underlying DataInputStream
or RandomAccessFile
java.lang.UnsupportedOperationException
- if the input type wasn't one of DataInputStream
or RandomAccessFile
public int read(byte[] b, int off, int len) throws java.io.IOException
len
bytes of data from the HollowBlobInput by relaying the call to the underlying
DataInputStream
or RandomAccessFile
into an array of bytes. This method blocks until at
least one byte of input is available.java.io.IOException
- if underlying DataInputStream
or RandomAccessFile
java.lang.UnsupportedOperationException
- if the input type wasn't one of DataInputStream
or RandomAccessFile
public void seek(long pos) throws java.io.IOException
RandomAccessFile
. Operation not supported if the Hollow Blob Input is an DataInputStream
.pos
- the position in bytes from the beginning of the file at which to set the file pointer to.java.io.IOException
- if originated in the underlying RandomAccessFile
implementationjava.lang.UnsupportedOperationException
- if called when Hollow Blob Input is not a RandomAccessFile
public long getFilePointer() throws java.io.IOException
java.io.IOException
- if an I/O error occurs.public final short readShort() throws java.io.IOException
java.io.IOException
- if an I/O error occurs.public final int readInt() throws java.io.IOException
java.io.IOException
- if an I/O error occurs.public final long readLong() throws java.io.IOException
java.io.IOException
- if an I/O error occurs.public final java.lang.String readUTF() throws java.io.IOException
java.io.IOException
- if an I/O error occurs.public long skipBytes(long n) throws java.io.IOException
n
- number of bytes to skipjava.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
public java.lang.Object getInput()
public BlobByteBuffer getBuffer()