java.lang.Object
tools.jackson.dataformat.avro.AvroSchema
- All Implemented Interfaces:
tools.jackson.core.FormatSchema
Wrapper for Schema information needed to encode and decode Avro-format
data.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AtomicReference<AvroStructureReader>Lazily instantiated value reader for this schema.protected final org.apache.avro.SchemaSchema that was used for writing the data to decode; for simple instance used for reading as well (reader schema).static final StringFormat type id used by Jackson components to refer to Avro Format. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected AvroStructureReaderbooleanorg.apache.avro.SchemaAccessor for "writer schema" contained in this instance.inthashCode()toString()withReaderSchema(AvroSchema readerSchema) Method that will consider this schema instance (used as so-called "Writer Schema"), and specified "Reader Schema" instance, and will either construct a new schema with appropriate translations, to use for reading (if reader and writer schemas are not same); or, if schemas are the same, return `this`.withUnsafeReaderSchema(AvroSchema readerSchema) Similar towithReaderSchema(tools.jackson.dataformat.avro.AvroSchema)but will NOT verify compatibility of schemas: this means that certain problems (such as missing default value for a newly added field) that would be caught at construction may be surfaced later when using schema.
-
Field Details
-
TYPE_ID
Format type id used by Jackson components to refer to Avro Format.- See Also:
-
_writerSchema
protected final org.apache.avro.Schema _writerSchemaSchema that was used for writing the data to decode; for simple instance used for reading as well (reader schema). -
_reader
Lazily instantiated value reader for this schema.
-
-
Constructor Details
-
AvroSchema
public AvroSchema(org.apache.avro.Schema asch)
-
-
Method Details
-
withReaderSchema
public AvroSchema withReaderSchema(AvroSchema readerSchema) throws tools.jackson.databind.DatabindException Method that will consider this schema instance (used as so-called "Writer Schema"), and specified "Reader Schema" instance, and will either construct a new schema with appropriate translations, to use for reading (if reader and writer schemas are not same); or, if schemas are the same, return `this`.Note that neither `this` instance nor `readerSchema` is ever modified: if an altered version is needed, a new schema object will be constructed.
NOTE: this is a relatively expensive operation due to validation (although significant part of cost is deferred until the first call to
getReader()) so it is recommended that these instances are reused whenever possible.- Parameters:
readerSchema- "Reader Schema" to use (in Avro terms): schema that specified how reader wants to see the data; specifies part of translation needed along with this schema (which would be "Writer Schema" in Avro terms).- Throws:
tools.jackson.databind.DatabindException- If given reader schema is incompatible with (writer-) schema this instance was constructed with,
-
withUnsafeReaderSchema
public AvroSchema withUnsafeReaderSchema(AvroSchema readerSchema) throws tools.jackson.databind.DatabindException Similar towithReaderSchema(tools.jackson.dataformat.avro.AvroSchema)but will NOT verify compatibility of schemas: this means that certain problems (such as missing default value for a newly added field) that would be caught at construction may be surfaced later when using schema. This is, however, sometimes necessary to work around potential BUT NOT ACTUAL problems.- Throws:
tools.jackson.databind.DatabindException
-
getSchemaType
- Specified by:
getSchemaTypein interfacetools.jackson.core.FormatSchema
-
getAvroSchema
public org.apache.avro.Schema getAvroSchema()Accessor for "writer schema" contained in this instance. -
getReader
-
_constructReader
-
toString
-
hashCode
public int hashCode() -
equals
-