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, writeVarLongpublic 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
Outputwrite in class OutputKryoExceptionpublic void writeByte(byte value)
throws KryoException
writeByte in class OutputKryoExceptionpublic void writeByte(int value)
throws KryoException
writeByte in class OutputKryoExceptionpublic void writeInt(int value)
throws KryoException
OutputwriteInt in class OutputKryoExceptionpublic void writeLong(long value)
throws KryoException
OutputwriteLong in class OutputKryoExceptionpublic void writeFloat(float value)
throws KryoException
OutputwriteFloat in class OutputKryoExceptionpublic void writeDouble(double value)
throws KryoException
OutputwriteDouble in class OutputKryoExceptionpublic void writeShort(int value)
throws KryoException
OutputwriteShort in class OutputKryoExceptionpublic void writeChar(char value)
throws KryoException
OutputwriteChar in class OutputKryoExceptionpublic void writeBoolean(boolean value)
throws KryoException
OutputwriteBoolean in class OutputKryoExceptionpublic void writeInts(int[] array,
int offset,
int count)
throws KryoException
OutputwriteInts in class OutputKryoExceptionpublic void writeLongs(long[] array,
int offset,
int count)
throws KryoException
OutputwriteLongs in class OutputKryoExceptionpublic void writeFloats(float[] array,
int offset,
int count)
throws KryoException
OutputwriteFloats in class OutputKryoExceptionpublic void writeDoubles(double[] array,
int offset,
int count)
throws KryoException
OutputwriteDoubles in class OutputKryoExceptionpublic void writeShorts(short[] array,
int offset,
int count)
throws KryoException
OutputwriteShorts in class OutputKryoExceptionpublic void writeChars(char[] array,
int offset,
int count)
throws KryoException
OutputwriteChars in class OutputKryoExceptionpublic void writeBooleans(boolean[] array,
int offset,
int count)
throws KryoException
OutputwriteBooleans in class OutputKryoExceptionpublic void writeBytes(byte[] array,
int offset,
int count)
throws KryoException
OutputwriteBytes in class OutputKryoExceptionpublic void writeBytes(java.lang.Object from,
long offset,
int count)
throws KryoException
KryoExceptionCopyright © 2019. All Rights Reserved.