public class UnsafeByteBufferInput extends ByteBufferInput
ByteBufferInput that reads data from direct ByteBuffer (off-heap memory) using sun.misc.Unsafe. Multi-byte primitive
types use native byte order, so the native byte order on different computers which read and write the data must be the same.
Not available on all JVMs. Util.unsafe can be checked before using this class.
This class may be much faster when Input.setVariableLengthEncoding(boolean) is false.
byteBufferbuffer, capacity, chars, inputStream, limit, position, total, varEncoding| Constructor and Description |
|---|
UnsafeByteBufferInput()
Creates an uninitialized Input,
setBuffer(ByteBuffer) must be called before the Input is used. |
UnsafeByteBufferInput(byte[] bytes)
Creates a new Input for reading from a
ByteBuffer which is filled with the specified bytes. |
UnsafeByteBufferInput(byte[] bytes,
int offset,
int count)
Creates a new Input for reading from a
ByteBuffer which is filled with the specified bytes. |
UnsafeByteBufferInput(java.nio.ByteBuffer buffer)
Creates a new Input for reading from a ByteBuffer.
|
UnsafeByteBufferInput(java.io.InputStream inputStream)
Creates a new Input for reading from an InputStream with a buffer size of 4096.
|
UnsafeByteBufferInput(java.io.InputStream inputStream,
int bufferSize)
Creates a new Input for reading from an InputStream with the specified buffer size.
|
UnsafeByteBufferInput(int bufferSize)
Creates a new Input for reading from a direct
ByteBuffer. |
UnsafeByteBufferInput(long address,
int size)
Creates a new Input for reading from a ByteBuffer representing the memory region at the specified address and size.
|
| Modifier and Type | Method and Description |
|---|---|
int |
read()
Reads a single byte as an int from 0 to 255, or -1 if there are no more bytes are available.
|
boolean |
readBoolean()
Reads a 1 byte boolean.
|
boolean[] |
readBooleans(int length)
Reads a boolean array in bulk.
|
byte |
readByte()
Reads a single byte.
|
void |
readBytes(byte[] bytes,
int offset,
int count)
Reads count bytes and writes them to the specified byte[], starting at offset.
|
void |
readBytes(java.lang.Object to,
long offset,
int count)
Read count bytes and write them to the object at the given offset inside the in-memory representation of the object.
|
int |
readByteUnsigned()
Reads a byte as an int from 0 to 255.
|
char |
readChar()
Reads a 2 byte char.
|
char[] |
readChars(int length)
Reads a char array in bulk.
|
double |
readDouble()
Reads an 8 byte double.
|
double[] |
readDoubles(int length)
Reads a double array in bulk.
|
float |
readFloat()
Reads a 4 byte float.
|
float[] |
readFloats(int length)
Reads a float array in bulk.
|
int |
readInt()
Reads a 4 byte int.
|
int[] |
readInts(int length)
Reads an int array in bulk.
|
long |
readLong()
Reads an 8 byte long.
|
long[] |
readLongs(int length)
Reads a long array in bulk.
|
short |
readShort()
Reads a 2 byte short.
|
short[] |
readShorts(int length)
Reads a short array in bulk.
|
void |
setBuffer(java.nio.ByteBuffer buffer)
Sets a new buffer to read from.
|
canReadVarInt, canReadVarLong, close, fill, getBuffer, getByteBuffer, optional, read, read, readBytes, readShortUnsigned, readString, readStringBuilder, readVarInt, readVarIntFlag, readVarIntFlag, readVarLong, require, reset, setBuffer, setBuffer, setInputStream, setLimit, setPosition, skip, skipavailable, canReadInt, canReadLong, end, fill, getInputStream, getVariableLengthEncoding, limit, position, readBytes, readInt, readInts, readLong, readLongs, readVarDouble, readVarFloat, setTotal, setVariableLengthEncoding, totalpublic UnsafeByteBufferInput()
setBuffer(ByteBuffer) must be called before the Input is used.public UnsafeByteBufferInput(int bufferSize)
ByteBuffer.bufferSize - The size of the buffer. An exception is thrown if more bytes than this are read and
ByteBufferInput.fill(ByteBuffer, int, int) does not supply more bytes.public UnsafeByteBufferInput(byte[] bytes)
ByteBuffer which is filled with the specified bytes.public UnsafeByteBufferInput(byte[] bytes,
int offset,
int count)
ByteBuffer which is filled with the specified bytes.public UnsafeByteBufferInput(java.nio.ByteBuffer buffer)
public UnsafeByteBufferInput(long address,
int size)
public UnsafeByteBufferInput(java.io.InputStream inputStream)
public UnsafeByteBufferInput(java.io.InputStream inputStream,
int bufferSize)
public void setBuffer(java.nio.ByteBuffer buffer)
ByteBufferInputInputStream is set to null.setBuffer in class ByteBufferInputpublic int read()
throws KryoException
Inputread in class ByteBufferInputKryoExceptionpublic byte readByte()
throws KryoException
InputreadByte in class ByteBufferInputKryoExceptionpublic int readByteUnsigned()
throws KryoException
InputreadByteUnsigned in class ByteBufferInputKryoExceptionpublic int readInt()
throws KryoException
InputreadInt in class ByteBufferInputKryoExceptionpublic long readLong()
throws KryoException
InputreadLong in class ByteBufferInputKryoExceptionpublic float readFloat()
throws KryoException
InputreadFloat in class ByteBufferInputKryoExceptionpublic double readDouble()
throws KryoException
InputreadDouble in class ByteBufferInputKryoExceptionpublic short readShort()
throws KryoException
InputreadShort in class ByteBufferInputKryoExceptionpublic char readChar()
throws KryoException
InputreadChar in class ByteBufferInputKryoExceptionpublic boolean readBoolean()
throws KryoException
InputreadBoolean in class ByteBufferInputKryoExceptionpublic int[] readInts(int length)
throws KryoException
InputreadInts in class ByteBufferInputKryoExceptionpublic long[] readLongs(int length)
throws KryoException
InputreadLongs in class ByteBufferInputKryoExceptionpublic float[] readFloats(int length)
throws KryoException
InputreadFloats in class ByteBufferInputKryoExceptionpublic double[] readDoubles(int length)
throws KryoException
InputreadDoubles in class ByteBufferInputKryoExceptionpublic short[] readShorts(int length)
throws KryoException
InputreadShorts in class ByteBufferInputKryoExceptionpublic char[] readChars(int length)
throws KryoException
InputreadChars in class ByteBufferInputKryoExceptionpublic boolean[] readBooleans(int length)
throws KryoException
InputreadBooleans in class ByteBufferInputKryoExceptionpublic void readBytes(byte[] bytes,
int offset,
int count)
throws KryoException
InputreadBytes in class ByteBufferInputKryoExceptionpublic void readBytes(java.lang.Object to,
long offset,
int count)
throws KryoException
KryoExceptionCopyright © 2019. All Rights Reserved.