Class JSONKeyValueDeserializationSchema
- java.lang.Object
-
- org.apache.flink.streaming.util.serialization.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 Summary
Constructors Constructor Description JSONKeyValueDeserializationSchema(boolean includeMetadata)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deserialize(org.apache.kafka.clients.consumer.ConsumerRecord<byte[],byte[]> record, org.apache.flink.util.Collector<com.fasterxml.jackson.databind.node.ObjectNode> out)
Deserializes the byte message.org.apache.flink.api.common.typeinfo.TypeInformation<com.fasterxml.jackson.databind.node.ObjectNode>
getProducedType()
void
open(org.apache.flink.api.common.serialization.DeserializationSchema.InitializationContext context)
Initialization method for the schema.
-
-
-
Method Detail
-
open
public void open(org.apache.flink.api.common.serialization.DeserializationSchema.InitializationContext context) throws Exception
Description copied from interface:KafkaRecordDeserializationSchema
Initialization method for the schema. It is called before the actual working methodsKafkaRecordDeserializationSchema.deserialize(org.apache.kafka.clients.consumer.ConsumerRecord<byte[], byte[]>, org.apache.flink.util.Collector<T>)
and thus suitable for one time setup work.The provided
DeserializationSchema.InitializationContext
can be used to access additional features such as e.g. registering user metrics.- Specified by:
open
in interfaceKafkaRecordDeserializationSchema<com.fasterxml.jackson.databind.node.ObjectNode>
- Parameters:
context
- Contextual information that can be used during initialization.- Throws:
Exception
-
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 interfaceKafkaRecordDeserializationSchema<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 interfaceorg.apache.flink.api.java.typeutils.ResultTypeQueryable<com.fasterxml.jackson.databind.node.ObjectNode>
-
-