Avro C#
Loading...
Searching...
No Matches
Avro.Generic.PreresolvingDatumReader< T > Class Template Referenceabstract

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

Inheritance diagram for Avro.Generic.PreresolvingDatumReader< T >:
Avro.Generic.DatumReader< T > Avro.Generic.GenericDatumReader< T > Avro.Specific.SpecificDatumReader< T >

Classes

interface  RecordAccess
 Defines the interface for a class that provides access to a record implementation. More...
interface  EnumAccess
 Defines the interface for a class that provides access to an enum implementation. More...
interface  FixedAccess
 Defines the interface for a class that provides access to a fixed implementation. More...
interface  ArrayAccess
 Defines the interface for a class that provides access to an array implementation. More...
interface  MapAccess
 Defines the interface for a class that provides access to a map implementation. More...

Public Member Functions

T Read (T reuse, Decoder decoder)
 Read a datum. Traverse the schema, depth-first, reading all leaf values in the schema into a datum that is returned. If the provided datum is non-null it may be reused and returned.
Parameters
reuseOptional object to deserialize the datum into. May be null.
decoderDecoder to read data from.
Returns
Deserialized datum.

object CreateRecord (object reuse)
 Creates a new record object. Derived classes can override this to return an object of their choice.
object GetField (object record, string fieldName, int fieldPos)
 Used by the default implementation of ReadRecord() to get the existing field of a record object. The derived classes can override this to make their own interpretation of the record object.
void AddField (object record, string fieldName, int fieldPos, object fieldValue)
 Used by the default implementation of ReadRecord() to add a field to a record object. The derived classes can override this to suit their own implementation of the record object.
object CreateEnum (object reuse, int ordinal)
 Creates an enum value.
object CreateFixed (object reuse)
 Returns a fixed object.
byte[] GetFixedBuffer (object f)
 Returns a buffer of appropriate size to read data into.
object Create (object reuse)
 Creates a new array object. The initial size of the object could be anything.
void EnsureSize (ref object array, int targetSize)
 Hint that the array should be able to handle at least targetSize elements. The array is not required to be resized.
void Resize (ref object array, int targetSize)
 Resizes the array to the new value.
void AddElements (object array, int elements, int index, ReadItem itemReader, Decoder decoder, bool reuse)
 Adds elements to the given array by reading values from the decoder.
object Create (object reuse)
 Creates a new map object.
void AddElements (object map, int elements, ReadItem itemReader, Decoder decoder, bool reuse)
 Adds elements to the given map by reading values from the decoder.
 SchemaPair (Schema writerSchema, Schema readerSchema)
override bool Equals (object obj)
override int GetHashCode ()

Protected Member Functions

delegate object ReadItem (object reuse, Decoder dec)
 Defines the signature for a function that reads an item from a decoder.
 PreresolvingDatumReader (Schema writerSchema, Schema readerSchema)
 Initializes a new instance of the PreresolvingDatumReader<T> class.
ArrayAccess GetArrayAccess (ArraySchema readerSchema)
 Returns an ArrayAccess implementation for the given schema.
EnumAccess GetEnumAccess (EnumSchema readerSchema)
 Returns an EnumAccess implementation for the given schema.
MapAccess GetMapAccess (MapSchema readerSchema)
 Returns a MapAccess implementation for the given schema.
RecordAccess GetRecordAccess (RecordSchema readerSchema)
 Returns a RecordAccess implementation for the given schema.
FixedAccess GetFixedAccess (FixedSchema readerSchema)
 Returns a FixedAccess implementation for the given schema.
virtual bool IsReusable (Schema.Type tag)
 Indicates if it's possible to reuse an object of the specified type. Generally false for immutable objects like int, long, string, etc but may differ between the Specific and Generic implementations. Used to avoid retrieving the existing value if it's not reusable.
bool Equals (SchemaPair other)

Static Protected Member Functions

static Schema FindBranch (UnionSchema us, Schema s)
 Finds the branch of the union schema associated with the given schema.

Properties

Schema ReaderSchema [get]
 Schema used to read the data.
Schema WriterSchema [get]
 Schema that was used to write the data.

Detailed Description

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

Member Function Documentation

◆ AddElements() [1/2]

void Avro.Generic.PreresolvingDatumReader< T >.AddElements ( object array,
int elements,
int index,
ReadItem itemReader,
Decoder decoder,
bool reuse )

Adds elements to the given array by reading values from the decoder.

Parameters
arrayArray to add elements to.
elementsNumber of elements to add.
indexStart adding elements to the array at this index.
itemReaderDelegate to read an item from the decoder.
decoderDecoder to read from.
reuseTrue to reuse each element in the array when deserializing. False to create a new object for each element.

◆ AddElements() [2/2]

void Avro.Generic.PreresolvingDatumReader< T >.AddElements ( object map,
int elements,
ReadItem itemReader,
Decoder decoder,
bool reuse )

Adds elements to the given map by reading values from the decoder.

Parameters
mapMap to add elements to.
elementsNumber of elements to add.
itemReaderDelegate to read an item from the decoder.
decoderDecoder to read from.
reuseTrue to reuse each element in the map when deserializing. False to create a new object for each element.

◆ AddField()

void Avro.Generic.PreresolvingDatumReader< T >.AddField ( object record,
string fieldName,
int fieldPos,
object fieldValue )

Used by the default implementation of ReadRecord() to add a field to a record object. The derived classes can override this to suit their own implementation of the record object.

Parameters
recordThe record object to be probed into. This is guaranteed to be one that was returned by a previous call to CreateRecord.
fieldNameThe name of the field to probe.
fieldPosfield number
fieldValueThe value to be added for the field

◆ Create() [1/2]

object Avro.Generic.PreresolvingDatumReader< T >.Create ( object reuse)

Creates a new map object.

Parameters
reuseIf appropriate, use this map object instead of creating a new one.
Returns
An empty map object.

◆ Create() [2/2]

object Avro.Generic.PreresolvingDatumReader< T >.Create ( object reuse)

Creates a new array object. The initial size of the object could be anything.

Parameters
reuseIf appropriate use this instead of creating a new one.
Returns
An object suitable to deserialize an avro array

◆ CreateEnum()

object Avro.Generic.PreresolvingDatumReader< T >.CreateEnum ( object reuse,
int ordinal )

Creates an enum value.

Parameters
reuseOptional object to reuse as the enum value. May be null.
ordinalOrdinal value of the enum entry.
Returns
An object representing the enum value.

◆ CreateFixed()

object Avro.Generic.PreresolvingDatumReader< T >.CreateFixed ( object reuse)

Returns a fixed object.

Parameters
reuseIf appropriate, uses this object instead of creating a new one.
Returns
A fixed object with an appropriate buffer.

◆ CreateRecord()

object Avro.Generic.PreresolvingDatumReader< T >.CreateRecord ( object reuse)

Creates a new record object. Derived classes can override this to return an object of their choice.

Parameters
reuseIf appropriate, will reuse this object instead of constructing a new one
Returns

◆ EnsureSize()

void Avro.Generic.PreresolvingDatumReader< T >.EnsureSize ( ref object array,
int targetSize )

Hint that the array should be able to handle at least targetSize elements. The array is not required to be resized.

Parameters
arrayArray object who needs to support targetSize elements. This is guaranteed to be something returned by a previous call to CreateArray().
targetSizeThe new size.

◆ FindBranch()

Schema Avro.Generic.PreresolvingDatumReader< T >.FindBranch ( UnionSchema us,
Schema s )
inlinestaticprotected

Finds the branch of the union schema associated with the given schema.

Parameters
usUnion schema.
sSchema to find in the union schema.
Returns
Schema branch in the union schema.

◆ GetArrayAccess()

ArrayAccess Avro.Generic.PreresolvingDatumReader< T >.GetArrayAccess ( ArraySchema readerSchema)
abstractprotected

Returns an ArrayAccess implementation for the given schema.

Parameters
readerSchemaSchema for the array.
Returns
An ArrayAccess implementation.

◆ GetEnumAccess()

EnumAccess Avro.Generic.PreresolvingDatumReader< T >.GetEnumAccess ( EnumSchema readerSchema)
abstractprotected

Returns an EnumAccess implementation for the given schema.

Parameters
readerSchemaSchema for the enum.
Returns
An EnumAccess implementation.

◆ GetField()

object Avro.Generic.PreresolvingDatumReader< T >.GetField ( object record,
string fieldName,
int fieldPos )

Used by the default implementation of ReadRecord() to get the existing field of a record object. The derived classes can override this to make their own interpretation of the record object.

Parameters
recordThe record object to be probed into. This is guaranteed to be one that was returned by a previous call to CreateRecord.
fieldNameThe name of the field to probe.
fieldPosfield number
Returns
The value of the field, if found. Null otherwise.

◆ GetFixedAccess()

FixedAccess Avro.Generic.PreresolvingDatumReader< T >.GetFixedAccess ( FixedSchema readerSchema)
abstractprotected

Returns a FixedAccess implementation for the given schema.

Parameters
readerSchemaSchema for the fixed.
Returns
A FixedAccess implementation.

◆ GetFixedBuffer()

byte[] Avro.Generic.PreresolvingDatumReader< T >.GetFixedBuffer ( object f)

Returns a buffer of appropriate size to read data into.

Parameters
fThe fixed object. It is guaranteed that this is something that has been previously returned by CreateFixed
Returns
A byte buffer of fixed's size.

◆ GetMapAccess()

MapAccess Avro.Generic.PreresolvingDatumReader< T >.GetMapAccess ( MapSchema readerSchema)
abstractprotected

Returns a MapAccess implementation for the given schema.

Parameters
readerSchemaSchema for the map.
Returns
A MapAccess implementation.

◆ GetRecordAccess()

RecordAccess Avro.Generic.PreresolvingDatumReader< T >.GetRecordAccess ( RecordSchema readerSchema)
abstractprotected

Returns a RecordAccess implementation for the given schema.

Parameters
readerSchemaSchema for the record.
Returns
A RecordAccess implementation.

◆ IsReusable()

virtual bool Avro.Generic.PreresolvingDatumReader< T >.IsReusable ( Schema.Type tag)
inlineprotectedvirtual

Indicates if it's possible to reuse an object of the specified type. Generally false for immutable objects like int, long, string, etc but may differ between the Specific and Generic implementations. Used to avoid retrieving the existing value if it's not reusable.

Parameters
tagSchema type to test for reusability.

Reimplemented in Avro.Generic.GenericDatumReader< T >, and Avro.Specific.SpecificDatumReader< T >.

◆ PreresolvingDatumReader()

Avro.Generic.PreresolvingDatumReader< T >.PreresolvingDatumReader ( Schema writerSchema,
Schema readerSchema )
inlineprotected

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

Parameters
writerSchemaSchema that was used to write the data.
readerSchemaSchema to use to read the data.

◆ Read()

T Avro.Generic.PreresolvingDatumReader< T >.Read ( T reuse,
Decoder decoder )
inline

Read a datum. Traverse the schema, depth-first, reading all leaf values in the schema into a datum that is returned. If the provided datum is non-null it may be reused and returned.

Parameters
reuseOptional object to deserialize the datum into. May be null.
decoderDecoder to read data from.
Returns
Deserialized datum.

Implements Avro.Generic.DatumReader< T >.

◆ ReadItem()

delegate object Avro.Generic.PreresolvingDatumReader< T >.ReadItem ( object reuse,
Decoder dec )
protected

Defines the signature for a function that reads an item from a decoder.

Parameters
reuseOptional object to deserialize the datum into. May be null.
decDecoder to read data from.
Returns
Deserialized datum.

◆ Resize()

void Avro.Generic.PreresolvingDatumReader< T >.Resize ( ref object array,
int targetSize )

Resizes the array to the new value.

Parameters
arrayArray object whose size is required. This is guaranteed to be something returned by a previous call to CreateArray().
targetSizeThe new size.

Property Documentation

◆ ReaderSchema

Schema Avro.Generic.PreresolvingDatumReader< T >.ReaderSchema
get

Schema used to read the data.

Implements Avro.Generic.DatumReader< T >.

◆ WriterSchema

Schema Avro.Generic.PreresolvingDatumReader< T >.WriterSchema
get

Schema that was used to write the data.

Implements Avro.Generic.DatumReader< T >.


The documentation for this class was generated from the following file:
  • src/apache/main/Generic/PreresolvingDatumReader.cs