The default implementation for the generic reader. It constructs new .NET objects for avro objects on the stream and returns the .NET object. Users can directly use this class or, if they want to customize the object types for differnt Avro schema types, can derive from this class. There are enough hooks in this class to allow customization. More...
Public Member Functions | |
DefaultReader (Schema writerSchema, Schema readerSchema) | |
Constructs the default reader for the given schemas using the DefaultReader. If the reader's and writer's schemas are different this class performs the resolution. This default implemenation maps Avro types to .NET types as follows: More... | |
T | Read< T > (T reuse, Decoder decoder) |
Reads an object off the stream. More... | |
object | Read (object reuse, Schema writerSchema, Schema readerSchema, Decoder d) |
Protected Member Functions | |
virtual object | ReadNull (Schema readerSchema, Decoder d) |
Deserializes a null from the stream. More... | |
S | Read< S > (Schema.Type tag, Schema readerSchema, Reader< S > reader) |
A generic function to read primitive types More... | |
virtual object | ReadRecord (object reuse, RecordSchema writerSchema, Schema readerSchema, Decoder dec) |
Deserializes a record from the stream. More... | |
virtual object | CreateRecord (object reuse, RecordSchema readerSchema) |
Creates a new record object. Derived classes can override this to return an object of their choice. More... | |
virtual bool | TryGetField (object record, string fieldName, int fieldPos, out object value) |
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. More... | |
virtual 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. More... | |
virtual object | ReadEnum (object reuse, EnumSchema writerSchema, Schema readerSchema, Decoder d) |
Deserializes a enum. Uses CreateEnum to construct the new enum object. More... | |
virtual object | CreateEnum (object reuse, EnumSchema es, string symbol) |
Used by the default implementation of ReadEnum to construct a new enum object. More... | |
virtual object | ReadArray (object reuse, ArraySchema writerSchema, Schema readerSchema, Decoder d) |
Deserializes an array and returns an array object. It uses CreateArray() and works on it before returning it. It also uses GetArraySize(), ResizeArray(), SetArrayElement() and GetArrayElement() methods. Derived classes can override these methods to customize their behavior. More... | |
virtual object | CreateArray (object reuse, ArraySchema rs) |
Creates a new array object. The initial size of the object could be anything. The users should use GetArraySize() to determine the size. The default implementation creates an object[] . More... | |
virtual int | GetArraySize (object array) |
Returns the size of the given array object. More... | |
virtual void | ResizeArray (ref object array, int n) |
Resizes the array to the new value. More... | |
virtual void | SetArrayElement (object array, int index, object value) |
Assigns a new value to the object at the given index More... | |
virtual object | GetArrayElement (object array, int index) |
Returns the element at the given index. More... | |
virtual object | ReadMap (object reuse, MapSchema writerSchema, Schema readerSchema, Decoder d) |
Deserialized an avro map. The default implemenation creats a new map using CreateMap() and then adds elements to the map using AddMapEntry(). More... | |
virtual object | CreateMap (object reuse, MapSchema ms) |
Used by the default implementation of ReadMap() to create a fresh map object. The default implementaion of this method returns a IDictionary<string, map>. More... | |
virtual void | AddMapEntry (object map, string key, object value) |
Adds an entry to the map. More... | |
virtual object | ReadUnion (object reuse, UnionSchema writerSchema, Schema readerSchema, Decoder d) |
Deserialized an object based on the writer's uninon schema. More... | |
virtual object | ReadFixed (object reuse, FixedSchema writerSchema, Schema readerSchema, Decoder d) |
Deserializes a fixed object and returns the object. The default implementation uses CreateFixed() and GetFixedBuffer() and returns what CreateFixed() returned. More... | |
virtual object | CreateFixed (object reuse, FixedSchema rs) |
Returns a fixed object. More... | |
virtual byte[] | GetFixedBuffer (object f) |
Returns a buffer of appropriate size to read data into. More... | |
virtual void | Skip (Schema writerSchema, Decoder d) |
Static Protected Member Functions | |
static Schema | findBranch (UnionSchema us, Schema s) |
Properties | |
Schema | ReaderSchema [get] |
Schema | WriterSchema [get] |
The default implementation for the generic reader. It constructs new .NET objects for avro objects on the stream and returns the .NET object. Users can directly use this class or, if they want to customize the object types for differnt Avro schema types, can derive from this class. There are enough hooks in this class to allow customization.
Avro Type | .NET Type |
---|---|
null | null reference |
Constructs the default reader for the given schemas using the DefaultReader. If the reader's and writer's schemas are different this class performs the resolution. This default implemenation maps Avro types to .NET types as follows:
writerSchema | The schema used while generating the data |
readerSchema | The schema desired by the reader |
|
inlineprotectedvirtual |
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.
record | The record object to be probed into. This is guaranteed to be one that was returned by a previous call to CreateRecord. |
fieldName | The name of the field to probe. |
fieldValue | The value to be added for the field |
|
inlineprotectedvirtual |
Adds an entry to the map.
map | A map object, which is guaranteed to be one returned by a previous call to CreateMap(). |
key | The key to add. |
value | The value to add. |
|
inlineprotectedvirtual |
Creates a new array object. The initial size of the object could be anything. The users should use GetArraySize() to determine the size. The default implementation creates an object[]
.
reuse | If appropriate use this instead of creating a new one. |
|
inlineprotectedvirtual |
Used by the default implementation of ReadEnum to construct a new enum object.
reuse | If appropriate, use this enum object instead of a new one. |
es | The enum schema used by the reader. |
symbol | The symbol that needs to be used. |
|
inlineprotectedvirtual |
Returns a fixed object.
reuse | If appropriate, uses this object instead of creating a new one. |
rs | The reader's FixedSchema. |
|
inlineprotectedvirtual |
Used by the default implementation of ReadMap() to create a fresh map object. The default implementaion of this method returns a IDictionary<string, map>.
reuse | If appropriate, use this map object instead of creating a new one. |
|
inlineprotectedvirtual |
Creates a new record object. Derived classes can override this to return an object of their choice.
reuse | If appropriate, will reuse this object instead of constructing a new one |
readerSchema | The schema the reader is using |
|
inlineprotectedvirtual |
Returns the element at the given index.
array | Array object whose size is required. This is guaranteed to be somthing returned by a previous call to CreateArray(). |
index | The index to look into. |
|
inlineprotectedvirtual |
Returns the size of the given array object.
array | Array object whose size is required. This is guaranteed to be somthing returned by a previous call to CreateArray(). |
|
inlineprotectedvirtual |
Returns a buffer of appropriate size to read data into.
f | The fixed object. It is guaranteed that this is something that has been previously returned by CreateFixed |
|
inlineprotected |
|
inline |
Reads an object off the stream.
T | The type of object to read. A single schema typically returns an object of a single .NET class. The only exception is UnionSchema, which can return a object of different types based on the branch selected. |
reuse | If not null, the implemenation will try to use to return the object |
decoder | The decoder for deserialization |
|
inlineprotectedvirtual |
Deserializes an array and returns an array object. It uses CreateArray() and works on it before returning it. It also uses GetArraySize(), ResizeArray(), SetArrayElement() and GetArrayElement() methods. Derived classes can override these methods to customize their behavior.
reuse | If appropriate, uses this instead of creating a new array object. |
writerSchema | The schema used by the writer. |
readerSchema | The schema that the reader uses. |
d | The decoder for deserialization. |
Reimplemented in Avro.Specific.SpecificDefaultReader.
|
inlineprotectedvirtual |
Deserializes a enum. Uses CreateEnum to construct the new enum object.
reuse | If appropirate, uses this instead of creating a new enum object. |
writerSchema | The schema the writer used while writing the enum |
readerSchema | The schema the reader is using |
d | The decoder for deserialization. |
Reimplemented in Avro.Specific.SpecificDefaultReader.
|
inlineprotectedvirtual |
Deserializes a fixed object and returns the object. The default implementation uses CreateFixed() and GetFixedBuffer() and returns what CreateFixed() returned.
reuse | If appropriate, uses this object instead of creating a new one. |
writerSchema | The FixedSchema the writer used during serialization. |
readerSchema | The schema that the readr uses. Must be a FixedSchema with the same size as the writerSchema. |
d | The decoder for deserialization. |
Reimplemented in Avro.Specific.SpecificDefaultReader.
|
inlineprotectedvirtual |
Deserialized an avro map. The default implemenation creats a new map using CreateMap() and then adds elements to the map using AddMapEntry().
reuse | If appropriate, use this instead of creating a new map object. |
writerSchema | The schema the writer used to write the map. |
readerSchema | The schema the reader is using. |
d | The decoder for serialization. |
Reimplemented in Avro.Specific.SpecificDefaultReader.
|
inlineprotectedvirtual |
Deserializes a null from the stream.
readerSchema | Reader's schema, which should be a NullSchema |
d | The decoder for deserialization |
|
inlineprotectedvirtual |
Deserializes a record from the stream.
reuse | If not null, a record object that could be reused for returning the result |
writerSchema | The writer's RecordSchema |
readerSchema | The reader's schema, must be RecordSchema too. |
dec | The decoder for deserialization |
Reimplemented in Avro.Specific.SpecificDefaultReader.
|
inlineprotectedvirtual |
Deserialized an object based on the writer's uninon schema.
reuse | If appropriate, uses this object instead of creating a new one. |
writerSchema | The UnionSchema that the writer used. |
readerSchema | The schema the reader uses. |
d | The decoder for serialization. |
|
inlineprotectedvirtual |
Resizes the array to the new value.
array | Array object whose size is required. This is guaranteed to be somthing returned by a previous call to CreateArray(). |
n | The new size. |
|
inlineprotectedvirtual |
Assigns a new value to the object at the given index
array | Array object whose size is required. This is guaranteed to be somthing returned by a previous call to CreateArray(). |
index | The index to reassign to. |
value | The value to assign. |
|
inlineprotectedvirtual |
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.
record | The record object to be probed into. This is guaranteed to be one that was returned by a previous call to CreateRecord. |
fieldName | The name of the field to probe. |
value | The value of the field, if found. Null otherwise. |