public class UnsafeInput extends Input
Input
that reads data from a byte[] 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.
buffer, capacity, chars, inputStream, limit, position, total, varEncoding
Constructor and Description |
---|
UnsafeInput()
Creates an uninitialized Input,
Input.setBuffer(byte[]) must be called before the Input is used. |
UnsafeInput(byte[] buffer)
Creates a new Input for reading from a byte[] buffer.
|
UnsafeInput(byte[] buffer,
int offset,
int count)
Creates a new Input for reading from a byte[] buffer.
|
UnsafeInput(java.io.InputStream inputStream)
Creates a new Input for reading from an InputStream with a buffer size of 4096.
|
UnsafeInput(java.io.InputStream inputStream,
int bufferSize)
Creates a new Input for reading from an InputStream with the specified buffer size.
|
UnsafeInput(int bufferSize)
Creates a new Input for reading from a byte[] buffer.
|
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.
|
available, canReadInt, canReadLong, canReadVarInt, canReadVarLong, close, end, fill, getBuffer, getInputStream, getVariableLengthEncoding, limit, optional, position, read, read, readBytes, readBytes, readInt, readInts, readLong, readLongs, readShortUnsigned, readString, readStringBuilder, readVarDouble, readVarFloat, readVarInt, readVarIntFlag, readVarIntFlag, readVarLong, require, reset, setBuffer, setBuffer, setInputStream, setLimit, setPosition, setTotal, setVariableLengthEncoding, skip, skip, total
public UnsafeInput()
Input.setBuffer(byte[])
must be called before the Input is used.public UnsafeInput(int bufferSize)
bufferSize
- The size of the buffer. An exception is thrown if more bytes than this are read and
Input.fill(byte[], int, int)
does not supply more bytes.public UnsafeInput(byte[] buffer)
buffer
- An exception is thrown if more bytes than this are read and Input.fill(byte[], int, int)
does not supply
more bytes.public UnsafeInput(byte[] buffer, int offset, int count)
buffer
- An exception is thrown if more bytes than this are read and Input.fill(byte[], int, int)
does not supply
more bytes.public UnsafeInput(java.io.InputStream inputStream)
public UnsafeInput(java.io.InputStream inputStream, int bufferSize)
public int read() throws KryoException
Input
read
in class Input
KryoException
public byte readByte() throws KryoException
Input
readByte
in class Input
KryoException
public int readByteUnsigned() throws KryoException
Input
readByteUnsigned
in class Input
KryoException
public int readInt() throws KryoException
Input
readInt
in class Input
KryoException
public long readLong() throws KryoException
Input
readLong
in class Input
KryoException
public float readFloat() throws KryoException
Input
readFloat
in class Input
KryoException
public double readDouble() throws KryoException
Input
readDouble
in class Input
KryoException
public short readShort() throws KryoException
Input
readShort
in class Input
KryoException
public char readChar() throws KryoException
Input
readChar
in class Input
KryoException
public boolean readBoolean() throws KryoException
Input
readBoolean
in class Input
KryoException
public int[] readInts(int length) throws KryoException
Input
readInts
in class Input
KryoException
public long[] readLongs(int length) throws KryoException
Input
readLongs
in class Input
KryoException
public float[] readFloats(int length) throws KryoException
Input
readFloats
in class Input
KryoException
public double[] readDoubles(int length) throws KryoException
Input
readDoubles
in class Input
KryoException
public short[] readShorts(int length) throws KryoException
Input
readShorts
in class Input
KryoException
public char[] readChars(int length) throws KryoException
Input
readChars
in class Input
KryoException
public boolean[] readBooleans(int length) throws KryoException
Input
readBooleans
in class Input
KryoException
public void readBytes(byte[] bytes, int offset, int count) throws KryoException
Input
readBytes
in class Input
KryoException
public void readBytes(java.lang.Object to, long offset, int count) throws KryoException
KryoException
Copyright © 2019. All Rights Reserved.