Avro C#
Classes | Public Member Functions | Protected Member Functions | List of all members
Avro.Generic.GenericDatumWriter< T > Class Template Reference

PreresolvingDatumWriter for writing data from GenericRecords or primitive types. For more information about performance considerations for choosing this implementation More...

Inheritance diagram for Avro.Generic.GenericDatumWriter< T >:
Avro.Generic.PreresolvingDatumWriter< T > Avro.Generic.DatumWriter< T >

Public Member Functions

 GenericDatumWriter (Schema schema)
 Initializes a new instance of the GenericDatumWriter<T> class. More...
 
- Public Member Functions inherited from Avro.Generic.PreresolvingDatumWriter< T >
void Write (T datum, Encoder encoder)
 Write a datum. Traverse the schema, depth first, writing each leaf value in the schema from the datum to the output.
 

Protected Member Functions

override void WriteRecordFields (object recordObj, RecordFieldWriter[] writers, Encoder encoder)
 Writes each field of a record to the encoder.
 
override void EnsureRecordObject (RecordSchema recordSchema, object value)
 Ensures that the given value is a record and that it corresponds to the given schema. Throws an exception if either of those assertions are false.
 
override void WriteField (object record, string fieldName, int fieldPos, WriteItem writer, Encoder encoder)
 Writes a field from the record to the encoder using the writer .
 
override WriteItem ResolveEnum (EnumSchema es)
 Serializes an enumeration.
 
override void WriteFixed (FixedSchema es, object value, Encoder encoder)
 Serialized a fixed object. The default implementation requires that the value is a GenericFixed object with an identical schema as es.
 
override bool UnionBranchMatches (Schema sc, object obj)
 Tests whether the given schema an object are compatible. More...
 
- Protected Member Functions inherited from Avro.Generic.PreresolvingDatumWriter< T >
delegate void WriteItem (object value, Encoder encoder)
 Defines the signature for a method that writes a value to an encoder. More...
 
 PreresolvingDatumWriter (Schema schema, ArrayAccess arrayAccess, MapAccess mapAccess)
 Initializes a new instance of the PreresolvingDatumWriter<T> class. More...
 
void WriteNull (object value, Encoder encoder)
 Serializes a "null" More...
 
void Write< TValue > (object value, Schema.Type tag, Writer< TValue > writer)
 A generic method to serialize primitive Avro types. More...
 
WriteItem ResolveArray (ArraySchema schema)
 Creates a WriteItem delegate that serializes an array. The default implementation calls EnsureArrayObject() to ascertain that the given value is an array. It then calls GetArrayLength() and GetArrayElement() to access the members of the array and then serialize them. More...
 
WriteItem ResolveLogical (LogicalSchema schema)
 Serializes a logical value object by using the underlying logical type to convert the value to its base value. More...
 
void WriteMap (WriteItem itemWriter, object value, Encoder encoder)
 Serializes a map. The default implementation first ensure that the value is indeed a map and then uses GetMapSize() and GetMapElements() to access the contents of the map. More...
 
int ResolveUnion (UnionSchema us, Schema[] branchSchemas, object obj)
 Finds the branch within the given UnionSchema that matches the given object. The default implementation calls Matches() method in the order of branches within the UnionSchema. If nothing matches, throws an exception. More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from Avro.Generic.PreresolvingDatumWriter< T >
static AvroException TypeMismatch (object obj, string schemaType, string type)
 Creates a new AvroException and uses the provided parameters to build an exception message indicating there was a type mismatch. More...
 
- Properties inherited from Avro.Generic.PreresolvingDatumWriter< T >
Schema Schema [get]
 
- Properties inherited from Avro.Generic.DatumWriter< T >
Schema Schema [get]
 Schema used to write the data. More...
 

Detailed Description

PreresolvingDatumWriter for writing data from GenericRecords or primitive types. For more information about performance considerations for choosing this implementation

Constructor & Destructor Documentation

◆ GenericDatumWriter()

Initializes a new instance of the GenericDatumWriter<T> class.

Parameters
schemaSchema this writer will use.

Member Function Documentation

◆ UnionBranchMatches()

override bool Avro.Generic.GenericDatumWriter< T >.UnionBranchMatches ( Schema  sc,
object  obj 
)
inlineprotectedvirtual

Tests whether the given schema an object are compatible.

FIXME: This method of determining the Union branch has problems. If the data is IDictionary<string, object> if there are two branches one with record schema and the other with map, it choose the first one. Similarly if the data is byte[] and there are fixed and bytes schemas as branches, it choose the first one that matches. Also it does not recognize the arrays of primitive types.

Parameters
scSchema to compare
objObject to compare
Returns
True if the two parameters are compatible, false otherwise.

Implements Avro.Generic.PreresolvingDatumWriter< T >.


The documentation for this class was generated from the following file: