Class ValueAndCoderLazySerializable<T>

  • Type Parameters:
    T - element type
    All Implemented Interfaces:
    java.io.Serializable

    public final class ValueAndCoderLazySerializable<T>
    extends java.lang.Object
    implements java.io.Serializable
    A holder object that lets you serialize an element with a Coder with minimal wasted space. Supports both Kryo and Java serialization.

    There are two different representations: a deserialized representation and a serialized representation.

    The deserialized representation stores a Coder and the value. To serialize the value, we write a length-prefixed encoding of value, but do NOT write the Coder used.

    The serialized representation just reads a byte array - the value is not deserialized fully. In order to get at the deserialized value, the caller must pass the Coder used to create this instance via getOrDecode(Coder). This reverts the representation back to the deserialized representation.

    See Also:
    Serialized Form
    • Method Detail

      • getOrDecode

        public T getOrDecode​(org.apache.beam.sdk.coders.Coder<T> coder)