Class AbstractKafkaAvroSerializer

java.lang.Object
io.confluent.kafka.serializers.AbstractKafkaSchemaSerDe
io.confluent.kafka.serializers.AbstractKafkaAvroSerializer
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.kafka.common.ClusterResourceListener, org.apache.kafka.common.metrics.Monitorable
Direct Known Subclasses:
KafkaAvroSerializer

public abstract class AbstractKafkaAvroSerializer extends AbstractKafkaSchemaSerDe
  • Field Details

    • normalizeSchema

      protected boolean normalizeSchema
    • autoRegisterSchema

      protected boolean autoRegisterSchema
    • propagateSchemaTags

      protected boolean propagateSchemaTags
    • removeJavaProperties

      protected boolean removeJavaProperties
    • useSchemaId

      protected int useSchemaId
    • useSchemaGuid

      protected String useSchemaGuid
    • idCompatStrict

      protected boolean idCompatStrict
    • latestCompatStrict

      protected boolean latestCompatStrict
    • avroReflectionAllowNull

      protected boolean avroReflectionAllowNull
    • avroUseLogicalTypeConverters

      protected boolean avroUseLogicalTypeConverters
    • validationRulesExecution

      protected AbstractKafkaSchemaSerDeConfig.ValidationRulesExecution validationRulesExecution
  • Constructor Details

    • AbstractKafkaAvroSerializer

      public AbstractKafkaAvroSerializer()
  • Method Details

    • configure

      protected void configure(KafkaAvroSerializerConfig config)
    • serializerConfig

      protected KafkaAvroSerializerConfig serializerConfig(Map<String,?> props)
    • serializerConfig

      protected KafkaAvroSerializerConfig serializerConfig(Properties props)
    • serializeImpl

      protected byte[] serializeImpl(String subject, Object object, AvroSchema schema) throws org.apache.kafka.common.errors.SerializationException, org.apache.kafka.common.errors.InvalidConfigurationException
      Throws:
      org.apache.kafka.common.errors.SerializationException
      org.apache.kafka.common.errors.InvalidConfigurationException
    • serializeImpl

      protected byte[] serializeImpl(String subject, String topic, Boolean key, org.apache.kafka.common.header.Headers headers, Object object, AvroSchema schema) throws org.apache.kafka.common.errors.SerializationException, org.apache.kafka.common.errors.InvalidConfigurationException
      Throws:
      org.apache.kafka.common.errors.SerializationException
      org.apache.kafka.common.errors.InvalidConfigurationException
    • getDatumWriter

      protected org.apache.avro.io.DatumWriter<?> getDatumWriter(Object value, org.apache.avro.Schema schema, boolean useLogicalTypes, boolean allowNull)
    • getBinaryEncoder

      protected org.apache.avro.io.BinaryEncoder getBinaryEncoder(ByteArrayOutputStream out, org.apache.avro.io.BinaryEncoder reuse)
      Returns a BinaryEncoder for marshaling output.

      The default implementation returns a non-buffering encoder via EncoderFactory.directBinaryEncoder(java.io.OutputStream, org.apache.avro.io.BinaryEncoder), preserving existing behavior. Subclasses may override this method to supply a reused BinaryEncoder instance, for example, via a ThreadLocal, to eliminate per-record encoder allocation on high-throughput marshal paths. Furthermore, subclasses may wish to use a buffering BinaryEncoder instead and should override entirely to call EncoderFactory.binaryEncoder(java.io.OutputStream, org.apache.avro.io.BinaryEncoder) directly, which is likely the better choice in reuse scenarios.

      Note: if a subclass were to call super.getBinaryEncoder(), the reuse argument must be a DirectBinaryEncoder instance for actual reuse to occur; the factory performs an exact class equality check and will allocate a new DirectBinaryEncoder if the provided instance is of any other type.

      @see EncoderFactory

      Parameters:
      out - the OutputStream to initialize to. Cannot be null.
      reuse - the BinaryEncoder to attempt to reuse. If null, a new instance is returned.
      Returns:
      a BinaryEncoder that uses out as its data output.