Class KafkaKeySerializer
- java.lang.Object
-
- com.linkedin.venice.serialization.KafkaKeySerializer
-
- All Implemented Interfaces:
VeniceKafkaSerializer<KafkaKey>
,java.io.Closeable
,java.lang.AutoCloseable
,org.apache.kafka.common.serialization.Deserializer<KafkaKey>
,org.apache.kafka.common.serialization.Serializer<KafkaKey>
public class KafkaKeySerializer extends java.lang.Object implements VeniceKafkaSerializer<KafkaKey>
VeniceKafkaSerializer
to encode/decodeKafkaKey
for Venice customized kafka message Used by Kafka to convert to/from byte arrays.KafkaKey
Schema (in order) - Key header byte - Either 0 (PUT or DELETE), or 2 (CONTROL_MESSAGE) - Payload (Key Object)
-
-
Constructor Summary
Constructors Constructor Description KafkaKeySerializer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close this serializer.void
configure(java.util.Map<java.lang.String,?> configMap, boolean isKey)
Configure this class.KafkaKey
deserialize(java.lang.String topic, byte[] bytes)
Create an object from an array of bytesbyte[]
serialize(java.lang.String topic, KafkaKey kafkaKey)
Construct an array of bytes from the given object
-
-
-
Method Detail
-
deserialize
public KafkaKey deserialize(java.lang.String topic, byte[] bytes)
Description copied from interface:VeniceKafkaSerializer
Create an object from an array of bytes- Specified by:
deserialize
in interfaceorg.apache.kafka.common.serialization.Deserializer<KafkaKey>
- Specified by:
deserialize
in interfaceVeniceKafkaSerializer<KafkaKey>
- Parameters:
topic
- Topic to which the array of bytes belongs.bytes
- An array of bytes with the objects data- Returns:
- A java object serialzed from the bytes
-
serialize
public byte[] serialize(java.lang.String topic, KafkaKey kafkaKey)
Description copied from interface:VeniceKafkaSerializer
Construct an array of bytes from the given object- Specified by:
serialize
in interfaceorg.apache.kafka.common.serialization.Serializer<KafkaKey>
- Specified by:
serialize
in interfaceVeniceKafkaSerializer<KafkaKey>
- Parameters:
topic
- Topic to which the object belongs.kafkaKey
- The object- Returns:
- The bytes taken from the object
-
configure
public void configure(java.util.Map<java.lang.String,?> configMap, boolean isKey)
Description copied from interface:VeniceKafkaSerializer
Configure this class.- Specified by:
configure
in interfaceorg.apache.kafka.common.serialization.Deserializer<KafkaKey>
- Specified by:
configure
in interfaceorg.apache.kafka.common.serialization.Serializer<KafkaKey>
- Specified by:
configure
in interfaceVeniceKafkaSerializer<KafkaKey>
- Parameters:
configMap
- configs in key/value pairsisKey
- whether is for key or value
-
close
public void close()
Description copied from interface:VeniceKafkaSerializer
Close this serializer. This method has to be idempotent if the serializer is used in KafkaProducer because it might be called multiple times.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in interfaceorg.apache.kafka.common.serialization.Deserializer<KafkaKey>
- Specified by:
close
in interfaceorg.apache.kafka.common.serialization.Serializer<KafkaKey>
- Specified by:
close
in interfaceVeniceKafkaSerializer<KafkaKey>
-
-