Interface KafkaRecordDeserializationSchema<T>

  • All Superinterfaces:
    org.apache.flink.api.java.typeutils.ResultTypeQueryable<T>, Serializable

    @PublicEvolving
    public interface KafkaRecordDeserializationSchema<T>
    extends Serializable, org.apache.flink.api.java.typeutils.ResultTypeQueryable<T>
    An interface for the deserialization of Kafka records.
    • Method Detail

      • deserialize

        void deserialize​(org.apache.kafka.clients.consumer.ConsumerRecord<byte[],​byte[]> record,
                         org.apache.flink.util.Collector<T> out)
                  throws IOException
        Deserializes the byte message.

        Can output multiple records through the Collector. Note that number and size of the produced records should be relatively small. Depending on the source implementation records can be buffered in memory or collecting records might delay emitting checkpoint barrier.

        Parameters:
        record - The ConsumerRecord to deserialize.
        out - The collector to put the resulting messages.
        Throws:
        IOException
      • valueOnly

        static <V> KafkaRecordDeserializationSchema<V> valueOnly​(org.apache.flink.api.common.serialization.DeserializationSchema<V> valueDeserializationSchema)
        Wraps a DeserializationSchema as the value deserialization schema of the ConsumerRecords. The other fields such as key, headers, timestamp are ignored.

        Note that the DeserializationSchema.isEndOfStream(Object) method will no longer be used to determine the end of the stream.

        Type Parameters:
        V - the type of the deserialized record.
        Parameters:
        valueDeserializationSchema - the DeserializationSchema used to deserialized the value of a ConsumerRecord.
        Returns:
        A KafkaRecordDeserializationSchema that uses the given DeserializationSchema to deserialize a ConsumerRecord from its value.
      • valueOnly

        static <V,​D extends org.apache.kafka.common.serialization.Deserializer<V>> KafkaRecordDeserializationSchema<V> valueOnly​(Class<D> valueDeserializerClass,
                                                                                                                                       Map<String,​String> config)
        Wraps a Kafka Deserializer to a KafkaRecordDeserializationSchema.
        Type Parameters:
        V - the value type.
        D - the type of the deserializer.
        Parameters:
        valueDeserializerClass - the deserializer class used to deserialize the value.
        config - the configuration of the value deserializer. If the deserializer is an implementation of Configurable, the configuring logic will be handled by Configurable.configure(Map) with the given config, otherwise Deserializer.configure(Map, boolean) will be invoked.
        Returns:
        A KafkaRecordDeserializationSchema that deserialize the value with the given deserializer.