public final class UnsafeMemoryOutput extends ByteBufferOutput
Important notes:
nativeOrder, niobuffer, varIntsEnabled
buffer, capacity, maxCapacity, outputStream, position, total
Constructor and Description |
---|
UnsafeMemoryOutput()
Creates an uninitialized Output.
|
UnsafeMemoryOutput(int bufferSize)
Creates a new Output for writing to a byte array.
|
UnsafeMemoryOutput(int bufferSize,
int maxBufferSize)
Creates a new Output for writing to a byte array.
|
UnsafeMemoryOutput(long address,
int maxBufferSize) |
UnsafeMemoryOutput(OutputStream outputStream)
Creates a new Output for writing to an OutputStream.
|
UnsafeMemoryOutput(OutputStream outputStream,
int bufferSize)
Creates a new Output for writing to an OutputStream.
|
Modifier and Type | Method and Description |
---|---|
void |
setBuffer(ByteBuffer buffer,
int maxBufferSize)
Sets the buffer that will be written to.
|
void |
writeBoolean(boolean value)
Writes a 1 byte boolean.
|
void |
writeByte(byte value) |
void |
writeByte(int value) |
void |
writeBytes(byte[] bytes)
Writes the bytes.
|
void |
writeBytes(Object obj,
long offset,
long count)
Output count bytes from a memory region starting at the given #{offset} inside the in-memory representation of obj object.
|
void |
writeChar(char value)
Writes a 2 byte char.
|
void |
writeChars(char[] object)
Bulk output of a char array.
|
void |
writeDouble(double value)
Writes an 8 byte double.
|
void |
writeDoubles(double[] object)
Bulk output of a double array.
|
void |
writeFloat(float value)
Writes a 4 byte float.
|
void |
writeFloats(float[] object)
Bulk output of a float array.
|
void |
writeInt(int value)
Writes a 4 byte int.
|
int |
writeInt(int value,
boolean optimizePositive)
Writes a 1-5 byte int.
|
void |
writeInts(int[] object)
Bulk output of an int array.
|
void |
writeInts(int[] object,
boolean optimizePositive)
Bulk output of an int array.
|
void |
writeLong(long value)
Writes an 8 byte long.
|
int |
writeLong(long value,
boolean optimizePositive)
Writes a 1-9 byte long.
|
void |
writeLongs(long[] object)
Bulk output of an long array.
|
void |
writeLongs(long[] object,
boolean optimizePositive)
Bulk output of an long array.
|
void |
writeShort(int value)
Writes a 2 byte short.
|
void |
writeShorts(short[] object)
Bulk output of a short array.
|
int |
writeVarInt(int val,
boolean optimizePositive)
Writes a 1-5 byte int.
|
int |
writeVarLong(long value,
boolean optimizePositive)
Writes a 1-9 byte long.
|
clear, close, flush, getByteBuffer, getOutputStream, getVarIntsEnabled, order, order, release, require, setBuffer, setOutputStream, setPosition, setVarIntsEnabled, toBytes, write, write, write, writeAscii, writeBytes, writeDouble, writeFloat, writeLongS, writeString, writeString
public UnsafeMemoryOutput()
Output.setBuffer(byte[])
must be called before the Output is used.public UnsafeMemoryOutput(int bufferSize)
bufferSize
- The initial and maximum size of the buffer. An exception is thrown if this size is exceeded.public UnsafeMemoryOutput(int bufferSize, int maxBufferSize)
bufferSize
- The initial size of the buffer.maxBufferSize
- The buffer is doubled as needed until it exceeds maxBufferSize and an exception is thrown.public UnsafeMemoryOutput(OutputStream outputStream)
public UnsafeMemoryOutput(OutputStream outputStream, int bufferSize)
public UnsafeMemoryOutput(long address, int maxBufferSize)
public void setBuffer(ByteBuffer buffer, int maxBufferSize)
ByteBufferOutput
OutputStream
is set to null.setBuffer
in class ByteBufferOutput
maxBufferSize
- The buffer is doubled as needed until it exceeds maxCapacity and an exception is thrown.public final void writeInt(int value) throws KryoException
writeInt
in class ByteBufferOutput
KryoException
public final void writeFloat(float value) throws KryoException
writeFloat
in class ByteBufferOutput
KryoException
public final void writeShort(int value) throws KryoException
writeShort
in class ByteBufferOutput
KryoException
public final void writeLong(long value) throws KryoException
writeLong
in class ByteBufferOutput
KryoException
public final void writeByte(int value) throws KryoException
writeByte
in class ByteBufferOutput
KryoException
public void writeByte(byte value) throws KryoException
writeByte
in class ByteBufferOutput
KryoException
public final void writeBoolean(boolean value) throws KryoException
writeBoolean
in class ByteBufferOutput
KryoException
public final void writeChar(char value) throws KryoException
writeChar
in class ByteBufferOutput
KryoException
public final void writeDouble(double value) throws KryoException
writeDouble
in class ByteBufferOutput
KryoException
public final int writeInt(int value, boolean optimizePositive) throws KryoException
Output
writeInt
in class ByteBufferOutput
optimizePositive
- If true, small positive numbers will be more efficient (1 byte) and small negative numbers will be
inefficient (5 bytes).KryoException
public final int writeLong(long value, boolean optimizePositive) throws KryoException
Output
writeLong
in class ByteBufferOutput
optimizePositive
- If true, small positive numbers will be more efficient (1 byte) and small negative numbers will be
inefficient (9 bytes).KryoException
public final int writeVarInt(int val, boolean optimizePositive) throws KryoException
Output
writeVarInt
in class ByteBufferOutput
optimizePositive
- If true, small positive numbers will be more efficient (1 byte) and small negative numbers will be
inefficient (5 bytes).KryoException
public final int writeVarLong(long value, boolean optimizePositive) throws KryoException
Output
writeVarLong
in class ByteBufferOutput
optimizePositive
- If true, small positive numbers will be more efficient (1 byte) and small negative numbers will be
inefficient (9 bytes).KryoException
public final void writeInts(int[] object, boolean optimizePositive) throws KryoException
Output
writeInts
in class Output
KryoException
public final void writeLongs(long[] object, boolean optimizePositive) throws KryoException
Output
writeLongs
in class Output
KryoException
public final void writeInts(int[] object) throws KryoException
ByteBufferOutput
writeInts
in class ByteBufferOutput
KryoException
public final void writeLongs(long[] object) throws KryoException
ByteBufferOutput
writeLongs
in class ByteBufferOutput
KryoException
public final void writeFloats(float[] object) throws KryoException
ByteBufferOutput
writeFloats
in class ByteBufferOutput
KryoException
public final void writeShorts(short[] object) throws KryoException
ByteBufferOutput
writeShorts
in class ByteBufferOutput
KryoException
public final void writeChars(char[] object) throws KryoException
ByteBufferOutput
writeChars
in class ByteBufferOutput
KryoException
public final void writeDoubles(double[] object) throws KryoException
ByteBufferOutput
writeDoubles
in class ByteBufferOutput
KryoException
public void writeBytes(byte[] bytes) throws KryoException
writeBytes
in class ByteBufferOutput
KryoException
public final void writeBytes(Object obj, long offset, long count) throws KryoException
obj
- offset
- count
- KryoException
Copyright © 2018. All rights reserved.