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, waitMethods inherited from interface io.servicetalk.serializer.api.StreamingDeserializer
deserializeMethods 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- TheSerializerDeserializerused to serialize/deserialize individual objects.bytesEstimator- Estimates the length in bytes for eachVarIntLengthStreamingSerializerbeing serialized.
-
-
Method Details
-
deserialize
Description copied from interface:StreamingDeserializer- Specified by:
deserializein interfaceStreamingDeserializer<T>- Parameters:
serializedData- the serialized stream of data represented in aPublisherofBuffer.allocator- theBufferAllocatorto use if allocation is required.- Returns:
- The deserialized
PublisherofStreamingDeserializers.
-
serialize
Description copied from interface:StreamingSerializer- Specified by:
serializein interfaceStreamingSerializer<T>- Parameters:
toSerialize- the deserialized stream of data represented in aPublisherofStreamingSerializer.allocator- theBufferAllocatorto use if allocation is required.- Returns:
- the serialized stream of data represented in a
PublisherofBuffer.
-