Avro C#

Classes | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Properties | List of all members
Avro.Generic.PreresolvingDatumWriter< T > Class Template Referenceabstract

A general purpose writer of data from avro streams. This writer analyzes the writer schema when constructed so that writes can be more efficient. Once constructed, a writer can be reused or shared among threads to avoid incurring more resolution costs. More...

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

## Classes
interface | ArrayAccess
| Defines the interface for a class that provides access to an array implementation. More...
class | DictionaryMapAccess
| Provides access to map properties from an IDictionary. More...
interface | EnumAccess
| Obsolete - This will be removed from the public API in a future version. More...
interface | MapAccess
| Defines the interface for a class that provides access to a map implementation. More...
class | RecordFieldWriter
| Correlates a record field with the writer used to serialize that field. More...

## Public Member Functions
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
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...
abstract void | WriteRecordFields (object record, RecordFieldWriter[] writers, Encoder encoder)
| Writes each field of a record to the encoder. More...
abstract 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. More...
abstract void | WriteField (object record, string fieldName, int fieldPos, WriteItem writer, Encoder encoder)
| Writes a field from the record to the encoder using the writer . More...
abstract WriteItem | ResolveEnum (EnumSchema es)
| Serializes an enumeration. 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...
abstract 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. More...
abstract bool | UnionBranchMatches (Schema sc, object obj)
| Tests whether the given schema an object are compatible. More...

## Static Protected Member Functions
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
Schema | Schema`[get]`
Properties inherited from Avro.Generic.DatumWriter< T >
Schema | Schema`[get]`
| Schema used to write the data. More...

## Detailed Description

A general purpose writer of data from avro streams. This writer analyzes the writer schema when constructed so that writes can be more efficient. Once constructed, a writer can be reused or shared among threads to avoid incurring more resolution costs.

## Constructor & Destructor Documentation

## ◆ PreresolvingDatumWriter()

Avro.Generic.PreresolvingDatumWriter< T >.PreresolvingDatumWriter | ( | Schema | schema,
|  | ArrayAccess | arrayAccess,
|  | MapAccess | mapAccess
| ) |  |
| inline protected

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

Parameters

  schema | Schema used by this writer
  arrayAccess | Object used to access array properties
  mapAccess | Object used to access map properties

## Member Function Documentation

## ◆ EnsureRecordObject()

abstract void Avro.Generic.PreresolvingDatumWriter< T >.EnsureRecordObject | ( | RecordSchema | recordSchema,
|  | object | value
| ) |  |
| protected pure virtual

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.

Parameters

  recordSchema | Schema associated with the record
  value | Ensure this object is a record

Implemented in Avro.Specific.SpecificDatumWriter< T >, and Avro.Generic.GenericDatumWriter< T >.

## ◆ ResolveArray()

WriteItem Avro.Generic.PreresolvingDatumWriter< T >.ResolveArray | ( | ArraySchema | schema | ) |
| inline protected

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.

Parameters

  schema | The ArraySchema for serialization

Returns
  A WriteItem that serializes an array.

## ◆ ResolveEnum()

abstract WriteItem Avro.Generic.PreresolvingDatumWriter< T >.ResolveEnum | ( | EnumSchema | es | ) |
| protected pure virtual

Serializes an enumeration.

Parameters

  es | The EnumSchema for serialization

Implemented in Avro.Generic.GenericDatumWriter< T >, and Avro.Specific.SpecificDatumWriter< T >.

## ◆ ResolveLogical()

WriteItem Avro.Generic.PreresolvingDatumWriter< T >.ResolveLogical | ( | LogicalSchema | schema | ) |
| inline protected

Serializes a logical value object by using the underlying logical type to convert the value to its base value.

Parameters

  schema | The logical schema.

## ◆ ResolveUnion()

int Avro.Generic.PreresolvingDatumWriter< T >.ResolveUnion | ( | UnionSchema | us,
|  | Schema[] | branchSchemas,
|  | object | obj
| ) |  |
| inline protected

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.

Parameters

  us | The UnionSchema to resolve against
  branchSchemas | Schemas for types within the union
  obj | The object that should be used in matching

Returns
  Index of the schema in branchSchemas that matches the obj .

Exceptions

  AvroException | No match found for the object in the union schema.

## ◆ TypeMismatch()

static AvroException Avro.Generic.PreresolvingDatumWriter< T >.TypeMismatch | ( | object | obj,
|  | string | schemaType,
|  | string | type
| ) |  |
| inline static protected

Creates a new AvroException and uses the provided parameters to build an exception message indicating there was a type mismatch.

Parameters

  obj | Object whose type does not the expected type
  schemaType | Schema that we tried to write against
  type | Type that we expected

Returns
  A new AvroException indicating a type mismatch.

## ◆ UnionBranchMatches()

abstract bool Avro.Generic.PreresolvingDatumWriter< T >.UnionBranchMatches | ( | Schema | sc,
|  | object | obj
| ) |  |
| protected pure virtual

Tests whether the given schema an object are compatible.

Parameters

  sc | Schema to compare
  obj | Object to compare

Returns
  True if the two parameters are compatible, false otherwise.

Implemented in Avro.Specific.SpecificDatumWriter< T >, and Avro.Generic.GenericDatumWriter< T >.

## ◆ Write< TValue >()

void Avro.Generic.PreresolvingDatumWriter< T >.Write< TValue > | ( | object | value,
|  | Schema.Type | tag,
|  | Writer< TValue > | writer
| ) |  |
| inline protected

A generic method to serialize primitive Avro types.

Template Parameters

  TValue | Type of the C# type to be serialized

Parameters

  value | The value to be serialized
  tag | The schema type tag
  writer | The writer which should be used to write the given type.

## ◆ WriteField()

abstract void Avro.Generic.PreresolvingDatumWriter< T >.WriteField | ( | object | record,
|  | string | fieldName,
|  | int | fieldPos,
|  | WriteItem | writer,
|  | Encoder | encoder
| ) |  |
| protected pure virtual

Writes a field from the record to the encoder using the writer .

Parameters

  record | The record value from which the field needs to be extracted
  fieldName | The name of the field in the record
  fieldPos | The position of field in the record
  writer | Used to write the field value to the encoder
  encoder | Encoder to write to

Implemented in Avro.Generic.GenericDatumWriter< T >, and Avro.Specific.SpecificDatumWriter< T >.

## ◆ WriteFixed()

abstract void Avro.Generic.PreresolvingDatumWriter< T >.WriteFixed | ( | FixedSchema | es,
|  | object | value,
|  | Encoder | encoder
| ) |  |
| protected pure virtual

Serialized a fixed object. The default implementation requires that the value is a GenericFixed object with an identical schema as es.

Parameters

  es | The schema for serialization
  value | The value to be serialized
  encoder | The encoder for serialization

Implemented in Avro.Specific.SpecificDatumWriter< T >, and Avro.Generic.GenericDatumWriter< T >.

## ◆ WriteItem()

delegate void Avro.Generic.PreresolvingDatumWriter< T >.WriteItem | ( | object | value,
|  | Encoder | encoder
| ) |  |
| protected

Defines the signature for a method that writes a value to an encoder.

Parameters

  value | Value to write
  encoder | Encoder to write to

## ◆ WriteMap()

void Avro.Generic.PreresolvingDatumWriter< T >.WriteMap | ( | WriteItem | itemWriter,
|  | object | value,
|  | Encoder | encoder
| ) |  |
| inline protected

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.

Parameters

  itemWriter | Delegate used to write each map item.
  value | The value to be serialized
  encoder | The encoder for serialization

## ◆ WriteNull()

void Avro.Generic.PreresolvingDatumWriter< T >.WriteNull | ( | object | value,
|  | Encoder | encoder
| ) |  |
| inline protected

Serializes a "null"

Parameters

  value | The object to be serialized using null schema
  encoder | The encoder to use while serialization

## ◆ WriteRecordFields()

abstract void Avro.Generic.PreresolvingDatumWriter< T >.WriteRecordFields | ( | object | record,
|  | RecordFieldWriter[] | writers,
|  | Encoder | encoder
| ) |  |
| protected pure virtual

Writes each field of a record to the encoder.

Parameters

  record | Record to write
  writers | Writers for each field in the record
  encoder | Encoder to write to

Implemented in Avro.Generic.GenericDatumWriter< T >, and Avro.Specific.SpecificDatumWriter< T >.

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

- src/apache/main/Generic/PreresolvingDatumWriter.cs