Package io.servicetalk.serializer.utils
Class VarIntLengthStreamingSerializer<T>
java.lang.Object
io.servicetalk.serializer.utils.VarIntLengthStreamingSerializer<T>
- Type Parameters:
T
- The type of object to serialize.
- All Implemented Interfaces:
StreamingDeserializer<T>
,StreamingSerializer<T>
,StreamingSerializerDeserializer<T>
public final class VarIntLengthStreamingSerializer<T>
extends Object
implements StreamingSerializerDeserializer<T>
A
StreamingSerializerDeserializer
that uses a SerializerDeserializer
and frames each object by
preceding it with the length in bytes. The length component is variable length and encoded as
base 128 VarInt.-
Constructor Summary
ConstructorsConstructorDescriptionVarIntLengthStreamingSerializer
(SerializerDeserializer<T> serializer, ToIntFunction<T> bytesEstimator) Create a new instance. -
Method Summary
Modifier and TypeMethodDescriptiondeserialize
(Publisher<Buffer> serializedData, BufferAllocator allocator) serialize
(Publisher<T> toSerialize, BufferAllocator allocator) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.servicetalk.serializer.api.StreamingDeserializer
deserialize
Methods inherited from interface io.servicetalk.serializer.api.StreamingSerializer
serialize, serialize
-
Constructor Details
-
VarIntLengthStreamingSerializer
public VarIntLengthStreamingSerializer(SerializerDeserializer<T> serializer, ToIntFunction<T> bytesEstimator) Create a new instance.- Parameters:
serializer
- TheSerializerDeserializer
used to serialize/deserialize individual objects.bytesEstimator
- Estimates the length in bytes for eachVarIntLengthStreamingSerializer
being serialized.
-
-
Method Details
-
deserialize
Description copied from interface:StreamingDeserializer
- Specified by:
deserialize
in interfaceStreamingDeserializer<T>
- Parameters:
serializedData
- the serialized stream of data represented in aPublisher
ofBuffer
.allocator
- theBufferAllocator
to use if allocation is required.- Returns:
- The deserialized
Publisher
ofStreamingDeserializer
s.
-
serialize
Description copied from interface:StreamingSerializer
- Specified by:
serialize
in interfaceStreamingSerializer<T>
- Parameters:
toSerialize
- the deserialized stream of data represented in aPublisher
ofStreamingSerializer
.allocator
- theBufferAllocator
to use if allocation is required.- Returns:
- the serialized stream of data represented in a
Publisher
ofBuffer
.
-