Package org.nuxeo.runtime.codec
Class AvroRecordCodec<T extends Record>
- java.lang.Object
-
- org.nuxeo.runtime.codec.AvroRecordCodec<T>
-
- 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 Summary
Fields Modifier and Type Field Description protected io.confluent.kafka.schemaregistry.client.SchemaRegistryClient
client
protected org.apache.avro.message.RawMessageEncoder<org.apache.avro.generic.GenericRecord>
encoder
protected org.apache.avro.message.RawMessageDecoder<org.apache.avro.generic.GenericRecord>
messageDecoder
protected org.apache.avro.message.RawMessageEncoder<org.apache.avro.generic.GenericRecord>
messageEncoder
protected org.apache.avro.Schema
messageSchema
protected int
messageSchemaId
static String
NAME
static String
RECORD_FLAGS
static String
RECORD_KEY
static String
RECORD_TIMESTAMP
static String
RECORD_WATERMARK
protected org.apache.avro.Schema
schema
protected int
schemaId
protected io.confluent.kafka.serializers.KafkaAvroSerializer
serializer
-
Constructor Summary
Constructors Constructor Description AvroRecordCodec(String messageClassName, String schemaRegistryUrls)
AvroRecordCodec(org.apache.avro.Schema messageSchema, String schemaRegistryUrls)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.apache.avro.Schema
addRecordFieldsToSchema(org.apache.avro.Schema schema)
protected org.apache.avro.generic.GenericRecord
createRecordFromMessage(org.apache.avro.generic.GenericRecord message)
T
decode(byte[] data)
Decodes the byte array returns an object.byte[]
encode(T record)
Encodes the object returns a byte array representation.String
getName()
Returns the codec name
-
-
-
Field Detail
-
NAME
public static final String NAME
- See Also:
- Constant Field Values
-
RECORD_KEY
public static final String RECORD_KEY
- See Also:
- Constant Field Values
-
RECORD_WATERMARK
public static final String RECORD_WATERMARK
- See Also:
- Constant Field Values
-
RECORD_TIMESTAMP
public static final String RECORD_TIMESTAMP
- See Also:
- Constant Field Values
-
RECORD_FLAGS
public static final String RECORD_FLAGS
- See Also:
- Constant Field Values
-
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
-
-
Constructor Detail
-
AvroRecordCodec
public AvroRecordCodec(org.apache.avro.Schema messageSchema, String schemaRegistryUrls)
-
AvroRecordCodec
public AvroRecordCodec(String messageClassName, String schemaRegistryUrls) throws ClassNotFoundException
- Throws:
ClassNotFoundException
-
-
Method Detail
-
encode
public byte[] encode(T record)
Description copied from interface:Codec
Encodes the object returns a byte array representation.
-
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)
-
-