public abstract class Compressor extends Serializer
Kryo.register(Class, Serializer)
Constructor and Description |
---|
Compressor(Serializer serializer)
Creates a compressor with compress and decompress set to true and bufferSize set to 2048.
|
Compressor(Serializer serializer,
int bufferSize) |
Modifier and Type | Method and Description |
---|---|
abstract void |
compress(java.nio.ByteBuffer inputBuffer,
java.lang.Object object,
java.nio.ByteBuffer outputBuffer)
The compressor should read the input buffer from the current position to the limit, compress the data, and put the result in
the output buffer.
|
abstract void |
decompress(java.nio.ByteBuffer inputBuffer,
java.lang.Class type,
java.nio.ByteBuffer outputBuffer)
The compressor should read the input buffer from the current position to the limit, decompress the data, and put the result
in the output buffer.
|
<T> T |
readObjectData(java.nio.ByteBuffer buffer,
java.lang.Class<T> type)
Reads an object from the buffer.
|
void |
setCompress(boolean compress)
Sets whether the compressor will compress data after serialization.
|
void |
setDecompress(boolean decompress)
Sets whether the compressor will decompress data before serialization.
|
void |
writeObjectData(java.nio.ByteBuffer buffer,
java.lang.Object object)
Writes the object to the buffer.
|
isFinal, newInstance, readObject, setCanBeNull, writeObject
public Compressor(Serializer serializer)
serializer
- public Compressor(Serializer serializer, int bufferSize)
bufferSize
- The maximum size in bytes of an object that can be read or written.public void setCompress(boolean compress)
public void setDecompress(boolean decompress)
public void writeObjectData(java.nio.ByteBuffer buffer, java.lang.Object object)
Serializer
writeObjectData
in class Serializer
object
- Cannot be null.public <T> T readObjectData(java.nio.ByteBuffer buffer, java.lang.Class<T> type)
Serializer
readObjectData
in class Serializer
public abstract void compress(java.nio.ByteBuffer inputBuffer, java.lang.Object object, java.nio.ByteBuffer outputBuffer)
outputBuffer
- A non-direct buffer.public abstract void decompress(java.nio.ByteBuffer inputBuffer, java.lang.Class type, java.nio.ByteBuffer outputBuffer)
outputBuffer
- A non-direct buffer.