Class VeniceAvroKafkaSerializer

java.lang.Object
com.linkedin.venice.serialization.avro.VeniceAvroKafkaSerializer
All Implemented Interfaces:
VeniceKafkaSerializer<Object>, Closeable, AutoCloseable, org.apache.kafka.common.serialization.Deserializer<Object>, org.apache.kafka.common.serialization.Serializer<Object>

public class VeniceAvroKafkaSerializer extends Object implements VeniceKafkaSerializer<Object>
This class is a thin wrapper of AvroSerializer and AvroGenericDeserializer. It is necessary to have a separate class responsible for this in this module in order to implement Kafka's interface, which is a dependency we do not want to leak into the schema-common module where the two above classes are located.
  • Constructor Details

    • VeniceAvroKafkaSerializer

      public VeniceAvroKafkaSerializer(String schemaStr)
    • VeniceAvroKafkaSerializer

      public VeniceAvroKafkaSerializer(org.apache.avro.Schema schema)
  • Method Details

    • close

      public void close()
      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 interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface org.apache.kafka.common.serialization.Deserializer<Object>
      Specified by:
      close in interface org.apache.kafka.common.serialization.Serializer<Object>
      Specified by:
      close in interface VeniceKafkaSerializer<Object>
    • configure

      public void configure(Map<String,?> configMap, boolean isKey)
      Configure this class.
      Specified by:
      configure in interface org.apache.kafka.common.serialization.Deserializer<Object>
      Specified by:
      configure in interface org.apache.kafka.common.serialization.Serializer<Object>
      Specified by:
      configure in interface VeniceKafkaSerializer<Object>
      Parameters:
      configMap - configs in key/value pairs
      isKey - whether is for key or value
    • serialize

      public byte[] serialize(String topic, Object object)
      Description copied from interface: VeniceKafkaSerializer
      Construct an array of bytes from the given object
      Specified by:
      serialize in interface org.apache.kafka.common.serialization.Serializer<Object>
      Specified by:
      serialize in interface VeniceKafkaSerializer<Object>
      Parameters:
      topic - Topic to which the object belongs.
      object - The object
      Returns:
      The bytes taken from the object
    • deserialize

      public Object deserialize(String topic, byte[] bytes)
      Description copied from interface: VeniceKafkaSerializer
      Create an object from an array of bytes
      Specified by:
      deserialize in interface org.apache.kafka.common.serialization.Deserializer<Object>
      Specified by:
      deserialize in interface VeniceKafkaSerializer<Object>
      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
    • deserialize

      public Object deserialize(byte[] bytes)
    • deserialize

      public Object deserialize(ByteBuffer byteBuffer)