Class JSONKeyValueDeserializationSchema

  • All Implemented Interfaces:
    Serializable, org.apache.flink.api.java.typeutils.ResultTypeQueryable<com.fasterxml.jackson.databind.node.ObjectNode>, KafkaRecordDeserializationSchema<com.fasterxml.jackson.databind.node.ObjectNode>

    @PublicEvolving
    public class JSONKeyValueDeserializationSchema
    extends Object
    implements KafkaRecordDeserializationSchema<com.fasterxml.jackson.databind.node.ObjectNode>
    DeserializationSchema that deserializes a JSON String into an ObjectNode.

    Key fields can be accessed by calling objectNode.get("key").get(<name>).as(<type>)

    Value fields can be accessed by calling objectNode.get("value").get(<name>).as(<type>)

    Metadata fields can be accessed by calling objectNode.get("metadata").get(<name>).as(<type>) and include the "offset" (long), "topic" (String) and "partition" (int).

    See Also:
    Serialized Form
    • Constructor Detail

      • JSONKeyValueDeserializationSchema

        public JSONKeyValueDeserializationSchema​(boolean includeMetadata)
    • Method Detail

      • deserialize

        public void deserialize​(org.apache.kafka.clients.consumer.ConsumerRecord<byte[],​byte[]> record,
                                org.apache.flink.util.Collector<com.fasterxml.jackson.databind.node.ObjectNode> out)
                         throws IOException
        Description copied from interface: KafkaRecordDeserializationSchema
        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.

        Specified by:
        deserialize in interface KafkaRecordDeserializationSchema<com.fasterxml.jackson.databind.node.ObjectNode>
        Parameters:
        record - The ConsumerRecord to deserialize.
        out - The collector to put the resulting messages.
        Throws:
        IOException
      • getProducedType

        public org.apache.flink.api.common.typeinfo.TypeInformation<com.fasterxml.jackson.databind.node.ObjectNode> getProducedType()
        Specified by:
        getProducedType in interface org.apache.flink.api.java.typeutils.ResultTypeQueryable<com.fasterxml.jackson.databind.node.ObjectNode>