Interface StreamingDeserializer<T>
-
- Type Parameters:
T- Type of object to be deserialized.
- All Superinterfaces:
java.lang.AutoCloseable,GracefulAutoCloseable
public interface StreamingDeserializer<T> extends GracefulAutoCloseable
A contract capable of deserializing a stream ofBuffers into a stream ofStreamingDeserializers. This interface is designed to be used as a function that can convert aBufferinto aStreamingDeserializer.deserialize(Buffer)maybe called multiple times.Implementations are assumed to be stateful since a single
Buffermay not hold enough data to deserialize an entire object. It is expected thatdeserialize(Buffer)ordeserialize(Iterable)may be called multiple times to deserialize a single instance ofStreamingDeserializeras more data is available.Implementations are assumed to be synchronous.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidclose()Disposes thisStreamingDeserializer.java.lang.Iterable<T>deserialize(Buffer toDeserialize)default BlockingIterable<T>deserialize(BlockingIterable<Buffer> toDeserialize)Deserialize the passedBlockingIterableofBuffers into aBlockingIterableofStreamingDeserializers.default java.lang.Iterable<T>deserialize(java.lang.Iterable<Buffer> toDeserialize)booleanhasData()Returnstrueif thisStreamingDeserializercontains any data from a previous invocation ofdeserialize(Buffer)that has not yet been deserialized.-
Methods inherited from interface io.servicetalk.concurrent.GracefulAutoCloseable
closeGracefully
-
-
-
-
Method Detail
-
deserialize
java.lang.Iterable<T> deserialize(Buffer toDeserialize)
Deserialize the passedBufferinto anIterableofStreamingDeserializers. If thisBufferand any previous left over data is insufficient to deserialize to a single instance ofStreamingDeserializerthen the returnedIterablewill be empty, i.e. the returnedIteratorfromIterable.iterator()will always returnfalsefromIterator.hasNext().It is assumed that a single instance of
StreamingDeserializermay receive calls to both this method anddeserialize(Iterable). Any left over data from one call is used by a subsequent call to the same or different method.- Parameters:
toDeserialize-Bufferto deserialize.- Returns:
Iterablecontaining zero or more deserialized instances ofStreamingDeserializer, if any can be deserialized from the data received till now.
-
deserialize
default java.lang.Iterable<T> deserialize(java.lang.Iterable<Buffer> toDeserialize)
Deserialize the passedIterableofBuffers into anIterableofStreamingDeserializers. If theseBuffers and any previous left over data is insufficient to deserialize to a single instance ofStreamingDeserializerthen the returnedIterablewill be empty, i.e. the returnedIteratorfromIterable.iterator()will always returnfalsefromIterator.hasNext().It is assumed that a single instance of
StreamingDeserializermay receive calls to both this method anddeserialize(Buffer). Any left over data from one call is used by a subsequent call to the same or different method.- Parameters:
toDeserialize-IterableofBuffers to deserialize.- Returns:
Iterablecontaining zero or more deserialized instances ofStreamingDeserializer, if any can be deserialized from the data received till now.
-
deserialize
default BlockingIterable<T> deserialize(BlockingIterable<Buffer> toDeserialize)
Deserialize the passedBlockingIterableofBuffers into aBlockingIterableofStreamingDeserializers. If theseBuffers and any previous left over data is insufficient to deserialize to a single instance ofStreamingDeserializerthen the returnedBlockingIterablewill be empty, i.e. the returnedBlockingIterablefromBlockingIterable.iterator()will always returnfalsefromIterator.hasNext().It is assumed that a single instance of
StreamingDeserializermay receive calls to both this method anddeserialize(Buffer). Any left over data from one call is used by a subsequent call to the same or different method.- Parameters:
toDeserialize-BlockingIterableofBuffers to deserialize.- Returns:
BlockingIterablecontaining zero or more deserialized instances ofStreamingDeserializer, if any can be deserialized from the data received till now.
-
hasData
boolean hasData()
Returnstrueif thisStreamingDeserializercontains any data from a previous invocation ofdeserialize(Buffer)that has not yet been deserialized.- Returns:
trueif thisStreamingDeserializercontains any data from a previous invocation ofdeserialize(Buffer)that has not yet been deserialized.
-
close
void close()
Disposes thisStreamingDeserializer. If there is any left-over data left in thisStreamingDeserializerfrom a previous call todeserialize(Buffer)which has not been consumed, this method should throw anSerializationExceptionto indicate that there is more data that is going to be disposed.- Specified by:
closein interfacejava.lang.AutoCloseable- Throws:
SerializationException- If there is some over data left but not consumed as returned byhasData().
-
-