Avro C#
Public Member Functions | List of all members
Avro.IO.Encoder Interface Reference

Defines the interface for a class that provides low-level support for serializing Avro values. More...

Inheritance diagram for Avro.IO.Encoder:
Avro.IO.BinaryEncoder

Public Member Functions

void WriteNull ()
 Writes a null value. More...
 
void WriteBoolean (bool value)
 Writes a boolean value. More...
 
void WriteInt (int value)
 Writes an int value. More...
 
void WriteLong (long value)
 Writes a long value. More...
 
void WriteFloat (float value)
 Writes a float value. More...
 
void WriteDouble (double value)
 Writes a double value. More...
 
void WriteBytes (byte[] value)
 Writes a byte string. More...
 
void WriteBytes (byte[] value, int offset, int length)
 Writes a byte string. More...
 
void WriteString (string value)
 Writes an Unicode string. More...
 
void WriteEnum (int value)
 Writes an enumeration. More...
 
void SetItemCount (long value)
 Call this method before writing a batch of items in an array or a map. More...
 
void StartItem ()
 Start a new item of an array or map. See WriteArrayStart for usage information. More...
 
void WriteArrayStart ()
 Call this method to start writing an array. When starting to serialize an array, call WriteArrayStart. Then, before writing any data for any item call SetItemCount(long) followed by a sequence of StartItem and the item itself. The number of StartItem should match the number specified in SetItemCount(long). When actually writing the data of the item, you can call any Encoder method (e.g., WriteLong(long)). When all items of the array have been written, call WriteArrayEnd. As an example, let's say you want to write an array of records, the record consisting of an Long field and a Boolean field. Your code would look something like this: More...
 
void WriteArrayEnd ()
 Call this method to finish writing an array. See WriteArrayStart for usage information. More...
 
void WriteMapStart ()
 Call this to start a new map. See WriteArrayStart for details on usage. As an example of usage, let's say you want to write a map of records, the record consisting of an Long field and a Boolean field. Your code would look something like this: More...
 
void WriteMapEnd ()
 Call this method to terminate the inner-most, currently-opened map. See WriteArrayStart for more details. More...
 
void WriteUnionIndex (int value)
 Call this method to write the tag of a union. As an example of usage, let's say you want to write a union, whose second branch is a record consisting of an Long field and a Boolean field. Your code would look something like this: More...
 
void WriteFixed (byte[] data)
 Writes a fixed value. More...
 
void WriteFixed (byte[] data, int start, int len)
 Writes a fixed value. More...
 

Detailed Description

Defines the interface for a class that provides low-level support for serializing Avro values.

Member Function Documentation

◆ SetItemCount()

void Avro.IO.Encoder.SetItemCount ( long  value)

Call this method before writing a batch of items in an array or a map.

Parameters
valueNumber of StartItem calls to follow.

Implemented in Avro.IO.BinaryEncoder.

◆ StartItem()

void Avro.IO.Encoder.StartItem ( )

Start a new item of an array or map. See WriteArrayStart for usage information.

Implemented in Avro.IO.BinaryEncoder.

◆ WriteArrayEnd()

void Avro.IO.Encoder.WriteArrayEnd ( )

Call this method to finish writing an array. See WriteArrayStart for usage information.

Implemented in Avro.IO.BinaryEncoder.

◆ WriteArrayStart()

void Avro.IO.Encoder.WriteArrayStart ( )

Call this method to start writing an array. When starting to serialize an array, call WriteArrayStart. Then, before writing any data for any item call SetItemCount(long) followed by a sequence of StartItem and the item itself. The number of StartItem should match the number specified in SetItemCount(long). When actually writing the data of the item, you can call any Encoder method (e.g., WriteLong(long)). When all items of the array have been written, call WriteArrayEnd. As an example, let's say you want to write an array of records, the record consisting of an Long field and a Boolean field. Your code would look something like this:

out.WriteArrayStart(); out.SetItemCount(list.Count); foreach (var r in list) { out.StartItem(); out.WriteLong(r.LongField); out.WriteBoolean(r.BoolField); } out.WriteArrayEnd();

Implemented in Avro.IO.BinaryEncoder.

◆ WriteBoolean()

void Avro.IO.Encoder.WriteBoolean ( bool  value)

Writes a boolean value.

Parameters
valueValue to write.

Implemented in Avro.IO.BinaryEncoder.

◆ WriteBytes() [1/2]

void Avro.IO.Encoder.WriteBytes ( byte[]  value)

Writes a byte string.

Parameters
valueValue to write.

Implemented in Avro.IO.BinaryEncoder.

◆ WriteBytes() [2/2]

void Avro.IO.Encoder.WriteBytes ( byte[]  value,
int  offset,
int  length 
)

Writes a byte string.

Parameters
valueThe byte[] to be read (fully or partially)
offsetThe offset from the beginning of the byte[] to start writing
lengthThe length of the data to be read from the byte[].

Implemented in Avro.IO.BinaryEncoder.

◆ WriteDouble()

void Avro.IO.Encoder.WriteDouble ( double  value)

Writes a double value.

Parameters
valueValue to write.

Implemented in Avro.IO.BinaryEncoder.

◆ WriteEnum()

void Avro.IO.Encoder.WriteEnum ( int  value)

Writes an enumeration.

Parameters
valueValue to write.

Implemented in Avro.IO.BinaryEncoder.

◆ WriteFixed() [1/2]

void Avro.IO.Encoder.WriteFixed ( byte[]  data)

Writes a fixed value.

Parameters
dataThe contents to write.

Implemented in Avro.IO.BinaryEncoder.

◆ WriteFixed() [2/2]

void Avro.IO.Encoder.WriteFixed ( byte[]  data,
int  start,
int  len 
)

Writes a fixed value.

Parameters
dataContents to write.
startPosition within data where the contents start.
lenNumber of bytes to write.

Implemented in Avro.IO.BinaryEncoder.

◆ WriteFloat()

void Avro.IO.Encoder.WriteFloat ( float  value)

Writes a float value.

Parameters
valueValue to write.

Implemented in Avro.IO.BinaryEncoder.

◆ WriteInt()

void Avro.IO.Encoder.WriteInt ( int  value)

Writes an int value.

Parameters
valueValue to write.

Implemented in Avro.IO.BinaryEncoder.

◆ WriteLong()

void Avro.IO.Encoder.WriteLong ( long  value)

Writes a long value.

Parameters
valueValue to write.

Implemented in Avro.IO.BinaryEncoder.

◆ WriteMapEnd()

void Avro.IO.Encoder.WriteMapEnd ( )

Call this method to terminate the inner-most, currently-opened map. See WriteArrayStart for more details.

Implemented in Avro.IO.BinaryEncoder.

◆ WriteMapStart()

void Avro.IO.Encoder.WriteMapStart ( )

Call this to start a new map. See WriteArrayStart for details on usage. As an example of usage, let's say you want to write a map of records, the record consisting of an Long field and a Boolean field. Your code would look something like this:

out.WriteMapStart(); out.SetItemCount(dictionary.Count); foreach (var entry in dictionary) { out.StartItem(); out.WriteString(entry.Key); out.writeLong(entry.Value.LongField); out.writeBoolean(entry.Value.BoolField); } out.WriteMapEnd();

Implemented in Avro.IO.BinaryEncoder.

◆ WriteNull()

void Avro.IO.Encoder.WriteNull ( )

Writes a null value.

Implemented in Avro.IO.BinaryEncoder.

◆ WriteString()

void Avro.IO.Encoder.WriteString ( string  value)

Writes an Unicode string.

Parameters
valueValue to write.

Implemented in Avro.IO.BinaryEncoder.

◆ WriteUnionIndex()

void Avro.IO.Encoder.WriteUnionIndex ( int  value)

Call this method to write the tag of a union. As an example of usage, let's say you want to write a union, whose second branch is a record consisting of an Long field and a Boolean field. Your code would look something like this:

out.WriteIndex(1); out.WriteLong(record.LongField); out.WriteBoolean(record.BoolField);

Parameters
value

Implemented in Avro.IO.BinaryEncoder.


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