public class UnsafeOutput extends Output
Output
that reads data 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 Output.setVariableLengthEncoding(boolean)
is false.
buffer, capacity, maxCapacity, outputStream, position, total, varEncoding
Constructor and Description |
---|
UnsafeOutput()
Creates an uninitialized Output,
Output.setBuffer(byte[], int) must be called before the Output is used. |
UnsafeOutput(byte[] buffer)
Creates a new Output for writing to a byte[].
|
UnsafeOutput(byte[] buffer,
int maxBufferSize)
Creates a new Output for writing to a byte[].
|
UnsafeOutput(int bufferSize)
Creates a new Output for writing to a byte[].
|
UnsafeOutput(int bufferSize,
int maxBufferSize)
Creates a new Output for writing to a byte[].
|
UnsafeOutput(java.io.OutputStream outputStream)
Creates a new Output for writing to an OutputStream.
|
UnsafeOutput(java.io.OutputStream outputStream,
int bufferSize)
Creates a new Output for writing to an OutputStream with the specified buffer size.
|
Modifier and Type | Method and Description |
---|---|
void |
write(int value)
Writes a byte.
|
void |
writeBoolean(boolean value)
Writes a 1 byte boolean.
|
void |
writeBooleans(boolean[] array,
int offset,
int count)
Writes a boolean array in bulk.
|
void |
writeByte(byte value) |
void |
writeByte(int value) |
void |
writeBytes(byte[] array,
int offset,
int count)
Writes the bytes.
|
void |
writeBytes(java.lang.Object from,
long offset,
int count)
Write count bytes to the byte buffer, reading from the given offset inside the in-memory representation of the object.
|
void |
writeChar(char value)
Writes a 2 byte char.
|
void |
writeChars(char[] array,
int offset,
int count)
Writes a char array in bulk.
|
void |
writeDouble(double value)
Writes an 8 byte double.
|
void |
writeDoubles(double[] array,
int offset,
int count)
Writes a double array in bulk.
|
void |
writeFloat(float value)
Writes a 4 byte float.
|
void |
writeFloats(float[] array,
int offset,
int count)
Writes a float array in bulk.
|
void |
writeInt(int value)
Writes a 4 byte int.
|
void |
writeInts(int[] array,
int offset,
int count)
Writes an int array in bulk.
|
void |
writeLong(long value)
Writes an 8 byte long.
|
void |
writeLongs(long[] array,
int offset,
int count)
Writes a long array in bulk.
|
void |
writeShort(int value)
Writes a 2 byte short.
|
void |
writeShorts(short[] array,
int offset,
int count)
Writes a short array in bulk.
|
close, flush, getBuffer, getMaxCapacity, getOutputStream, getVariableLengthEncoding, intLength, longLength, position, require, reset, setBuffer, setBuffer, setOutputStream, setPosition, setVariableLengthEncoding, toBytes, total, varIntLength, varLongLength, write, write, writeAscii, writeBytes, writeInt, writeInts, writeLong, writeLongs, writeString, writeVarDouble, writeVarFloat, writeVarInt, writeVarIntFlag, writeVarLong
public UnsafeOutput()
Output.setBuffer(byte[], int)
must be called before the Output is used.public UnsafeOutput(int bufferSize)
bufferSize
- The size of the buffer. An exception is thrown if more bytes than this are written and Output.flush()
does not empty the buffer.public UnsafeOutput(int bufferSize, int maxBufferSize)
bufferSize
- The initial size of the buffer.maxBufferSize
- If Output.flush()
does not empty the buffer, the buffer is doubled as needed until it exceeds
maxBufferSize and an exception is thrown. Can be -1 for no maximum.public UnsafeOutput(byte[] buffer)
Output.setBuffer(byte[])
public UnsafeOutput(byte[] buffer, int maxBufferSize)
Output.setBuffer(byte[], int)
public UnsafeOutput(java.io.OutputStream outputStream)
public UnsafeOutput(java.io.OutputStream outputStream, int bufferSize)
public void write(int value) throws KryoException
Output
write
in class Output
KryoException
public void writeByte(byte value) throws KryoException
writeByte
in class Output
KryoException
public void writeByte(int value) throws KryoException
writeByte
in class Output
KryoException
public void writeInt(int value) throws KryoException
Output
writeInt
in class Output
KryoException
public void writeLong(long value) throws KryoException
Output
writeLong
in class Output
KryoException
public void writeFloat(float value) throws KryoException
Output
writeFloat
in class Output
KryoException
public void writeDouble(double value) throws KryoException
Output
writeDouble
in class Output
KryoException
public void writeShort(int value) throws KryoException
Output
writeShort
in class Output
KryoException
public void writeChar(char value) throws KryoException
Output
writeChar
in class Output
KryoException
public void writeBoolean(boolean value) throws KryoException
Output
writeBoolean
in class Output
KryoException
public void writeInts(int[] array, int offset, int count) throws KryoException
Output
writeInts
in class Output
KryoException
public void writeLongs(long[] array, int offset, int count) throws KryoException
Output
writeLongs
in class Output
KryoException
public void writeFloats(float[] array, int offset, int count) throws KryoException
Output
writeFloats
in class Output
KryoException
public void writeDoubles(double[] array, int offset, int count) throws KryoException
Output
writeDoubles
in class Output
KryoException
public void writeShorts(short[] array, int offset, int count) throws KryoException
Output
writeShorts
in class Output
KryoException
public void writeChars(char[] array, int offset, int count) throws KryoException
Output
writeChars
in class Output
KryoException
public void writeBooleans(boolean[] array, int offset, int count) throws KryoException
Output
writeBooleans
in class Output
KryoException
public void writeBytes(byte[] array, int offset, int count) throws KryoException
Output
writeBytes
in class Output
KryoException
public void writeBytes(java.lang.Object from, long offset, int count) throws KryoException
KryoException
Copyright © 2019. All Rights Reserved.