Class ValueAsBytesSerializer

  • All Implemented Interfaces:
    ElementSerializer<byte[],​byte[]>, java.io.Serializable

    public class ValueAsBytesSerializer
    extends java.lang.Object
    implements ElementSerializer<byte[],​byte[]>
    A ElementSerializer that reads values from kafka (discards keys) and returns values as byte arrays.

    You must subclass this class to create zero-parameter constructor.

    See Also:
    Serialized Form
    • Method Detail

      • setup

        public void setup​(EntityDescriptor entityDescriptor)
        Description copied from interface: ElementSerializer
        Life-cycle method called after being instantiated to be able to parameterize itself from the given EntityDescriptor.
        Specified by:
        setup in interface ElementSerializer<byte[],​byte[]>
        Parameters:
        entityDescriptor - the entity that this serializer will be used for
      • read

        @Nullable
        public StreamElement read​(org.apache.kafka.clients.consumer.ConsumerRecord<byte[],​byte[]> consumerRecord,
                                  EntityDescriptor entityDescriptor)
        Description copied from interface: ElementSerializer
        Parse the raw bytes from Kafka and return a StreamElement.
        Specified by:
        read in interface ElementSerializer<byte[],​byte[]>
        Parameters:
        consumerRecord - a ConsumerRecord to be parsed
        entityDescriptor - descriptor of entity being read
        Returns:
        the StreamElement or null on parse error
      • write

        public org.apache.kafka.clients.producer.ProducerRecord<byte[],​byte[]> write​(java.lang.String topic,
                                                                                           int partition,
                                                                                           StreamElement streamElement)
        Description copied from interface: ElementSerializer
        Convert StreamElement into ProducerRecord.
        Specified by:
        write in interface ElementSerializer<byte[],​byte[]>
        Parameters:
        topic - the target topic
        partition - the target partition
        streamElement - the StreamElement to convert
        Returns:
        the ProducerRecord to write to Kafka
      • keySerde

        public org.apache.kafka.common.serialization.Serde<byte[]> keySerde()
        Description copied from interface: ElementSerializer
        Retrieve Serde for type K.
        Specified by:
        keySerde in interface ElementSerializer<byte[],​byte[]>
        Returns:
        Serde for key
      • valueSerde

        public org.apache.kafka.common.serialization.Serde<byte[]> valueSerde()
        Description copied from interface: ElementSerializer
        Retrieve Serde for type V.
        Specified by:
        valueSerde in interface ElementSerializer<byte[],​byte[]>
        Returns:
        Serde for value