T - Type of object to be deserialized.public interface StreamingDeserializer<T> extends GracefulAutoCloseable
Buffers into a stream of Ts.
This interface is designed to be used as a function that can convert a Buffer into a T.
deserialize(Buffer) maybe called multiple times.
Implementations are assumed to be stateful since a single Buffer may not hold
enough data to deserialize an entire object. It is expected that deserialize(Buffer) or
deserialize(Iterable) may be called multiple times to deserialize a single instance of T as more
data is available.
Implementations are assumed to be synchronous.
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Disposes this
StreamingDeserializer. |
default BlockingIterable<T> |
deserialize(BlockingIterable<Buffer> toDeserialize)
|
java.lang.Iterable<T> |
deserialize(Buffer toDeserialize)
|
default java.lang.Iterable<T> |
deserialize(java.lang.Iterable<Buffer> toDeserialize)
|
boolean |
hasData()
Returns
true if this StreamingDeserializer contains any data from a previous invocation of
deserialize(Buffer) that has not yet been deserialized. |
closeGracefullyjava.lang.Iterable<T> deserialize(Buffer toDeserialize)
Buffer into an Iterable of Ts. If this Buffer and any
previous left over data is insufficient to deserialize to a single instance of T then the returned
Iterable will be empty, i.e. the returned Iterator from Iterable.iterator() will always
return false from Iterator.hasNext().
It is assumed that a single instance of StreamingDeserializer may receive calls to both this method and
deserialize(Iterable). Any left over data from one call is used by a subsequent call to the same or
different method.
toDeserialize - Buffer to deserialize.Iterable containing zero or more deserialized instances of T, if any can be deserialized
from the data received till now.default java.lang.Iterable<T> deserialize(java.lang.Iterable<Buffer> toDeserialize)
Iterable of Buffers into an Iterable of Ts. If these
Buffers and any previous left over data is insufficient to deserialize to a single instance of T
then the returned Iterable will be empty, i.e. the returned Iterator from
Iterable.iterator() will always return false from Iterator.hasNext().
It is assumed that a single instance of StreamingDeserializer may receive calls to both this method and
deserialize(Buffer). Any left over data from one call is used by a subsequent call to the same or
different method.
toDeserialize - Iterable of Buffers to deserialize.Iterable containing zero or more deserialized instances of T, if any can be deserialized
from the data received till now.default BlockingIterable<T> deserialize(BlockingIterable<Buffer> toDeserialize)
BlockingIterable of Buffers into a BlockingIterable of Ts.
If these Buffers and any previous left over data is insufficient to deserialize to a single instance of
T then the returned BlockingIterable will be empty, i.e. the returned BlockingIterable
from BlockingIterable.iterator() will always return false from
Iterator.hasNext().
It is assumed that a single instance of StreamingDeserializer may receive calls to both this method and
deserialize(Buffer). Any left over data from one call is used by a subsequent call to the same or
different method.
toDeserialize - BlockingIterable of Buffers to deserialize.BlockingIterable containing zero or more deserialized instances of T, if any can be
deserialized from the data received till now.boolean hasData()
true if this StreamingDeserializer contains any data from a previous invocation of
deserialize(Buffer) that has not yet been deserialized.true if this StreamingDeserializer contains any data from a previous invocation of
deserialize(Buffer) that has not yet been deserialized.void close()
StreamingDeserializer. If there is any left-over data left in this
StreamingDeserializer from a previous call to deserialize(Buffer) which has not been consumed,
this method should throw an SerializationException to indicate that there is more data that is going to
be disposed.close in interface java.lang.AutoCloseableSerializationException - If there is some over data left but not consumed as returned by
hasData().