Class AbstractKafkaAvroSerializer
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.kafka.common.ClusterResourceListener,org.apache.kafka.common.metrics.Monitorable
- Direct Known Subclasses:
KafkaAvroSerializer
-
Nested Class Summary
Nested classes/interfaces inherited from class io.confluent.kafka.serializers.AbstractKafkaSchemaSerDe
AbstractKafkaSchemaSerDe.ExtendedSchema, AbstractKafkaSchemaSerDe.Migration, AbstractKafkaSchemaSerDe.SubjectSchema -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected Stringprotected intFields inherited from class io.confluent.kafka.serializers.AbstractKafkaSchemaSerDe
config, configOriginals, contextNameStrategy, DEFAULT_CACHE_CAPACITY, enableRuleServiceLoader, executionEnv, isKey, keySchemaIdDeserializer, keySchemaIdSerializer, keySubjectNameStrategy, latestVersions, latestWithMetadata, metadata, ruleActions, ruleExecutors, schemaRegistry, ticker, useLatestVersion, useSchemaReflection, valueSchemaIdDeserializer, valueSchemaIdSerializer, valueSubjectNameStrategy -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidconfigure(KafkaAvroSerializerConfig config) protected org.apache.avro.io.BinaryEncodergetBinaryEncoder(ByteArrayOutputStream out, org.apache.avro.io.BinaryEncoder reuse) Returns aBinaryEncoderfor marshaling output.protected org.apache.avro.io.DatumWriter<?>getDatumWriter(Object value, org.apache.avro.Schema schema, boolean useLogicalTypes, boolean allowNull) protected byte[]serializeImpl(String subject, Object object, AvroSchema schema) protected byte[]serializeImpl(String subject, String topic, Boolean key, org.apache.kafka.common.header.Headers headers, Object object, AvroSchema schema) protected KafkaAvroSerializerConfigserializerConfig(Map<String, ?> props) protected KafkaAvroSerializerConfigserializerConfig(Properties props) Methods inherited from class io.confluent.kafka.serializers.AbstractKafkaSchemaSerDe
clearKey, close, configureClientProperties, executeMigrations, executeRules, executeRules, executeRules, executeRules, executeValidationRules, getById, getBySubjectAndId, getContextName, getContextName, getLatestWithMetadata, getMigrations, getOldSubjectName, getRuleActions, getRuleExecutors, getSchemaById, getSchemaBySchemaId, getSchemaBySubjectAndId, getSchemaEntityBySubjectAndId, getSchemaRegistryClient, getSubjectName, initValidationRuleExecutor, isKey, key, latestVersionsCache, latestWithMetadataCache, lookupLatestVersion, lookupLatestVersion, lookupSchemaByGuid, lookupSchemaBySubjectAndId, lookupSchemaEntityBySubjectAndId, onUpdate, postOp, register, register, register, registerWithResponse, schemaIdDeserializer, schemaIdSerializer, setKey, strategyUsesSchema, ticker, toKafkaException, withPluginMetrics
-
Field Details
-
normalizeSchema
protected boolean normalizeSchema -
autoRegisterSchema
protected boolean autoRegisterSchema -
propagateSchemaTags
protected boolean propagateSchemaTags -
removeJavaProperties
protected boolean removeJavaProperties -
useSchemaId
protected int useSchemaId -
useSchemaGuid
-
idCompatStrict
protected boolean idCompatStrict -
latestCompatStrict
protected boolean latestCompatStrict -
avroReflectionAllowNull
protected boolean avroReflectionAllowNull -
avroUseLogicalTypeConverters
protected boolean avroUseLogicalTypeConverters -
validationRulesExecution
-
-
Constructor Details
-
AbstractKafkaAvroSerializer
public AbstractKafkaAvroSerializer()
-
-
Method Details
-
configure
-
serializerConfig
-
serializerConfig
-
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.SerializationExceptionorg.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.SerializationExceptionorg.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 aBinaryEncoderfor 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 aThreadLocal, 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 callEncoderFactory.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
reuseargument 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
outas its data output.
-