Class PravegaDeserializationSchema<T>

  • All Implemented Interfaces:
    WrappingSerializer<T>, java.io.Serializable, org.apache.flink.api.common.serialization.DeserializationSchema<T>, org.apache.flink.api.java.typeutils.ResultTypeQueryable<T>

    public class PravegaDeserializationSchema<T>
    extends java.lang.Object
    implements org.apache.flink.api.common.serialization.DeserializationSchema<T>, WrappingSerializer<T>
    A deserialization schema adapter for a Pravega serializer.

    This adapter exposes the Pravega serializer as a Flink Deserialization schema and exposes the produced type (TypeInformation) to allow Flink to configure its internal serialization and persistence stack.

    An additional method extractEvent(EventRead) is provided for applying the metadata in the deserialization. This method can be overriden in the extended class.

    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.apache.flink.api.common.serialization.DeserializationSchema

        org.apache.flink.api.common.serialization.DeserializationSchema.InitializationContext
    • Constructor Summary

      Constructors 
      Constructor Description
      PravegaDeserializationSchema​(java.lang.Class<T> typeClass, io.pravega.client.stream.Serializer<T> serializer)
      Creates a new PravegaDeserializationSchema using the given Pravega serializer, and the type described by the type class.
      PravegaDeserializationSchema​(org.apache.flink.api.common.typeinfo.TypeHint<T> typeHint, io.pravega.client.stream.Serializer<T> serializer)
      Creates a new PravegaDeserializationSchema using the given Pravega serializer, and the type described by the type hint.
      PravegaDeserializationSchema​(org.apache.flink.api.common.typeinfo.TypeInformation<T> typeInfo, io.pravega.client.stream.Serializer<T> serializer)
      Creates a new PravegaDeserializationSchema using the given Pravega serializer, and the given TypeInformation.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T deserialize​(byte[] message)  
      T extractEvent​(io.pravega.client.stream.EventRead<T> eventRead)
      An method for applying the metadata in deserialization.
      org.apache.flink.api.common.typeinfo.TypeInformation<T> getProducedType()  
      io.pravega.client.stream.Serializer<T> getWrappedSerializer()
      Gets the wrapped Pravega Serializer.
      boolean isEndOfStream​(T nextElement)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.apache.flink.api.common.serialization.DeserializationSchema

        deserialize, open
    • Constructor Detail

      • PravegaDeserializationSchema

        public PravegaDeserializationSchema​(java.lang.Class<T> typeClass,
                                            io.pravega.client.stream.Serializer<T> serializer)
        Creates a new PravegaDeserializationSchema using the given Pravega serializer, and the type described by the type class.

        Use this constructor if the produced type is not generic and can be fully described by a class. If the type is generic, use the PravegaDeserializationSchema(TypeHint, Serializer) constructor instead.

        Parameters:
        typeClass - The class describing the deserialized type.
        serializer - The serializer to deserialize the byte messages.
      • PravegaDeserializationSchema

        public PravegaDeserializationSchema​(org.apache.flink.api.common.typeinfo.TypeHint<T> typeHint,
                                            io.pravega.client.stream.Serializer<T> serializer)
        Creates a new PravegaDeserializationSchema using the given Pravega serializer, and the type described by the type hint.

        Use this constructor if the produced type is generic and cannot be fully described by a class alone. The type hint instantiation captures generic type information to make it available at runtime.

        
         DeserializationSchema<Tuple2<String, String>> schema = 
             new PravegaDeserializationSchema<>(new TypeHint<Tuple2<String, String>>(){}, serializer);
         
        Parameters:
        typeHint - The Type Hint describing the deserialized type.
        serializer - The serializer to deserialize the byte messages.
      • PravegaDeserializationSchema

        public PravegaDeserializationSchema​(org.apache.flink.api.common.typeinfo.TypeInformation<T> typeInfo,
                                            io.pravega.client.stream.Serializer<T> serializer)
        Creates a new PravegaDeserializationSchema using the given Pravega serializer, and the given TypeInformation.
        Parameters:
        typeInfo - The TypeInformation describing the deserialized type.
        serializer - The serializer to deserialize the byte messages.
    • Method Detail

      • deserialize

        public T deserialize​(byte[] message)
                      throws java.io.IOException
        Specified by:
        deserialize in interface org.apache.flink.api.common.serialization.DeserializationSchema<T>
        Throws:
        java.io.IOException
      • isEndOfStream

        public boolean isEndOfStream​(T nextElement)
        Specified by:
        isEndOfStream in interface org.apache.flink.api.common.serialization.DeserializationSchema<T>
      • getProducedType

        public org.apache.flink.api.common.typeinfo.TypeInformation<T> getProducedType()
        Specified by:
        getProducedType in interface org.apache.flink.api.java.typeutils.ResultTypeQueryable<T>
      • extractEvent

        public T extractEvent​(io.pravega.client.stream.EventRead<T> eventRead)
        An method for applying the metadata in deserialization. Override it in the custom extended PravegaDeserializationSchema if the Pravega metadata is needed.
        Parameters:
        eventRead - The EventRead structure the client returns which contains metadata
        Returns:
        the deserialized event with metadata