Class DefaultSerializer

  • All Implemented Interfaces:
    VeniceKafkaSerializer<byte[]>, java.io.Closeable, java.lang.AutoCloseable, org.apache.kafka.common.serialization.Deserializer<byte[]>, org.apache.kafka.common.serialization.Serializer<byte[]>

    public class DefaultSerializer
    extends java.lang.Object
    implements VeniceKafkaSerializer<byte[]>
    Default Kafka VeniceKafkaSerializer
    • 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.
      byte[] deserialize​(java.lang.String topic, byte[] bytes)
      Create an object from an array of bytes
      byte[] serialize​(java.lang.String topic, byte[] bytes)
      Construct an array of bytes from the given object
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.apache.kafka.common.serialization.Deserializer

        deserialize
      • Methods inherited from interface org.apache.kafka.common.serialization.Serializer

        serialize
    • Constructor Detail

      • DefaultSerializer

        public DefaultSerializer()
    • Method Detail

      • 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 interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface org.apache.kafka.common.serialization.Deserializer<byte[]>
        Specified by:
        close in interface org.apache.kafka.common.serialization.Serializer<byte[]>
        Specified by:
        close in interface VeniceKafkaSerializer<byte[]>
      • 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 interface org.apache.kafka.common.serialization.Deserializer<byte[]>
        Specified by:
        configure in interface org.apache.kafka.common.serialization.Serializer<byte[]>
        Specified by:
        configure in interface VeniceKafkaSerializer<byte[]>
        Parameters:
        configMap - configs in key/value pairs
        isKey - whether is for key or value
      • serialize

        public byte[] serialize​(java.lang.String topic,
                                byte[] bytes)
        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<byte[]>
        Specified by:
        serialize in interface VeniceKafkaSerializer<byte[]>
        Parameters:
        topic - Topic to which the object belongs.
        bytes - The object
        Returns:
        The bytes taken from the object
      • deserialize

        public byte[] deserialize​(java.lang.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<byte[]>
        Specified by:
        deserialize in interface VeniceKafkaSerializer<byte[]>
        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