Class AvroRecordCodec<T extends Record>

  • All Implemented Interfaces:
    Codec<T>

    public class AvroRecordCodec<T extends Record>
    extends Object
    implements Codec<T>
    Instead of having an Avro Record envelop that contains a data encoded in Avro, this structure is a flat Avro message joining schemas of the Record and data. This encoding can then be read by any Confluent Avro reader.
    Since:
    11.4
    • Field Detail

      • schema

        protected final org.apache.avro.Schema schema
      • schemaId

        protected final int schemaId
      • messageSchema

        protected final org.apache.avro.Schema messageSchema
      • messageSchemaId

        protected final int messageSchemaId
      • messageDecoder

        protected final org.apache.avro.message.RawMessageDecoder<org.apache.avro.generic.GenericRecord> messageDecoder
      • messageEncoder

        protected final org.apache.avro.message.RawMessageEncoder<org.apache.avro.generic.GenericRecord> messageEncoder
      • serializer

        protected final io.confluent.kafka.serializers.KafkaAvroSerializer serializer
      • encoder

        protected final org.apache.avro.message.RawMessageEncoder<org.apache.avro.generic.GenericRecord> encoder
      • client

        protected final io.confluent.kafka.schemaregistry.client.SchemaRegistryClient client
    • Method Detail

      • getName

        public String getName()
        Description copied from interface: Codec
        Returns the codec name
        Specified by:
        getName in interface Codec<T extends Record>
      • encode

        public byte[] encode​(T record)
        Description copied from interface: Codec
        Encodes the object returns a byte array representation.
        Specified by:
        encode in interface Codec<T extends Record>
      • createRecordFromMessage

        protected org.apache.avro.generic.GenericRecord createRecordFromMessage​(org.apache.avro.generic.GenericRecord message)
      • addRecordFieldsToSchema

        protected org.apache.avro.Schema addRecordFieldsToSchema​(org.apache.avro.Schema schema)
      • decode

        public T decode​(byte[] data)
        Description copied from interface: Codec
        Decodes the byte array returns an object.
        Specified by:
        decode in interface Codec<T extends Record>