Package io.apicurio.registry.serde.avro
Class AvroSerializer<U>
java.lang.Object
io.apicurio.registry.serde.AbstractSerializer<org.apache.avro.Schema,U>
io.apicurio.registry.serde.avro.AvroSerializer<U>
- All Implemented Interfaces:
AutoCloseable
-
Constructor Summary
ConstructorsConstructorDescriptionAvroSerializer(io.apicurio.registry.resolver.client.RegistryClientFacade clientFacade) AvroSerializer(io.apicurio.registry.resolver.client.RegistryClientFacade clientFacade, io.apicurio.registry.resolver.SchemaResolver<org.apache.avro.Schema, U> schemaResolver) AvroSerializer(io.apicurio.registry.resolver.client.RegistryClientFacade clientFacade, io.apicurio.registry.resolver.strategy.ArtifactReferenceResolverStrategy<org.apache.avro.Schema, U> artifactResolverStrategy, io.apicurio.registry.resolver.SchemaResolver<org.apache.avro.Schema, U> schemaResolver) AvroSerializer(io.apicurio.registry.resolver.SchemaResolver<org.apache.avro.Schema, U> schemaResolver) -
Method Summary
Modifier and TypeMethodDescriptionvoidconfigure(SerdeConfig configs, boolean isKey) protected ObjectgetSchemaCacheKey(U data) For Avro SpecificRecord, the schema is tied to the class, so we use the class as cache key.io.apicurio.registry.resolver.SchemaParser<org.apache.avro.Schema, U> voidserializeData(io.apicurio.registry.resolver.ParsedSchema<org.apache.avro.Schema> schema, U data, OutputStream out) voidsetEncoding(AvroEncoding encoding) Methods inherited from class io.apicurio.registry.serde.AbstractSerializer
close, getSerdeConfigurer, serializeData
-
Constructor Details
-
AvroSerializer
public AvroSerializer() -
AvroSerializer
public AvroSerializer(io.apicurio.registry.resolver.client.RegistryClientFacade clientFacade) -
AvroSerializer
public AvroSerializer(io.apicurio.registry.resolver.SchemaResolver<org.apache.avro.Schema, U> schemaResolver) -
AvroSerializer
public AvroSerializer(io.apicurio.registry.resolver.client.RegistryClientFacade clientFacade, io.apicurio.registry.resolver.SchemaResolver<org.apache.avro.Schema, U> schemaResolver) -
AvroSerializer
public AvroSerializer(io.apicurio.registry.resolver.client.RegistryClientFacade clientFacade, io.apicurio.registry.resolver.strategy.ArtifactReferenceResolverStrategy<org.apache.avro.Schema, U> artifactResolverStrategy, io.apicurio.registry.resolver.SchemaResolver<org.apache.avro.Schema, U> schemaResolver)
-
-
Method Details
-
setEncoding
-
getEncoding
-
configure
- Overrides:
configurein classAbstractSerializer<org.apache.avro.Schema,U>
-
schemaParser
- Specified by:
schemaParserin classAbstractSerializer<org.apache.avro.Schema,U> - See Also:
-
getSchemaCacheKey
For Avro SpecificRecord, the schema is tied to the class, so we use the class as cache key. For GenericRecord/GenericContainer, caching by Schema is not safe because: 1. Schema.hashCode() is based only on type and props (name, namespace), not on fields 2. This causes hash collisions for evolved schemas with the same name but different fields 3. Schema evolution tests fail when the wrong cached result is returned- Overrides:
getSchemaCacheKeyin classAbstractSerializer<org.apache.avro.Schema,U>
-
serializeData
public void serializeData(io.apicurio.registry.resolver.ParsedSchema<org.apache.avro.Schema> schema, U data, OutputStream out) throws IOException - Specified by:
serializeDatain classAbstractSerializer<org.apache.avro.Schema,U> - Throws:
IOException- See Also:
-