Class GenericDatumReader
Reads Avro binary data into AvroValues for one schema. The schema is compiled once into a tree of typed reader nodes, so reading does not inspect the schema; instances are cached per schema and are thread-safe.
public sealed class GenericDatumReader
- Inheritance
-
GenericDatumReader
- Inherited Members
Remarks
Create(AvroSchema, GenericDatumReaderOptions?) reads data with the schema it was written with. Create(AvroSchema, AvroSchema, GenericDatumReaderOptions?) reads data written with one schema version as another (schema resolution), following the specification's rules.
Properties
- ReaderSchema
Gets the schema that values are read as: the same as WriterSchema unless resolving between versions.
- WriterSchema
Gets the schema the data was written with.
Methods
- Create(AvroSchema, GenericDatumReaderOptions?)
Gets the reader for
schema, compiling it on first use. Readers with the default options are cached per schema; readers with custom options are created each time, so keep and reuse them.
- Create(AvroSchema, AvroSchema, GenericDatumReaderOptions?)
Gets a reader for data written with
writerSchemathat returns values ofreaderSchema, resolving the differences the specification allows:- record fields are matched by name or by the reader field's aliases; writer fields the reader does not have are skipped, and reader fields the writer does not have take their default value;
- named types match by full name, unqualified name, or the reader's aliases;
- numbers are promoted (
inttolong,floatordouble;longtofloatordouble;floattodouble), andstringandbytesconvert to each other; - enum symbols are matched by name, and a symbol the reader lacks takes the reader's enum default;
- a writer union reads each branch as the reader schema (or the first matching branch of a reader union), and a non-union writer schema is read as the first matching branch of a reader union.
- Read(ref AvroReader)
Reads one value.
- Read(in ReadOnlySequence<byte>)
Reads one value from a sequence of buffers.
- Read(ReadOnlySpan<byte>)
Reads one value from contiguous data.