To use the latest Kryo release, use this dependency entry in your The Kryo class performs the serialization automatically.The Output and Input classes handle buffering bytes and optionally flushing to a stream.Variable length encoding can be disabled for the unsafe buffers or only for specific fields (when using Field Serializer).
However, small negative numbers are the worst case at 5 bytes.
When not optimized for positive, these ranges are shifted down by half.
This is done by using the 8th bit of each byte to indicate if more bytes follow, which means a varint uses 1-5 bytes and a varlong uses 1-9 bytes.
Using variable length encoding is more expensive but makes the serialized data much smaller.
The zero argument Input constructor creates an uninitialized Input. The Byte Buffer Output and Byte Buffer Input classes work exactly like Output and Input, except they use a Byte Buffer rather than a byte array. The downside to using unsafe buffers is that the native endianness and representation of numeric types of the system performing the serialization affects the serialized data.
The Unsafe Output, Unsafe Input, Unsafe Byte Buffer Output, and Unsafe Byte Buffer Input classes work exactly like their non-unsafe counterparts, except they use For example, deserialization will fail if the data is written on X86 and read on SPARC.
The project is useful any time objects need to be persisted, whether to a file, database, or over the network.
Kryo can also perform automatic deep and shallow copying/cloning.
This buffer can be set directly, if reading from a byte array is desired.
If the Input is given an Input Stream, it will fill the buffer from the stream when all the data in the buffer has been read.
There are also methods to allow the buffer to decide whether a fixed size or variable length value is written.