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:

## 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...
void | Flush ()
| Flushes the encoder. More...

## Detailed Description

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

## Member Function Documentation

## ◆ Flush()

void Avro.IO.Encoder.Flush | ( |  | ) |

Flushes the encoder.

Implemented in Avro.IO.BinaryEncoder, Avro.IO.ParsingEncoder, and Avro.IO.JsonEncoder.

## ◆ SetItemCount()

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

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

Parameters

  value | Number of StartItem calls to follow.

Implemented in Avro.IO.BinaryEncoder, and Avro.IO.ParsingEncoder.

## ◆ StartItem()

void Avro.IO.Encoder.StartItem | ( |  | ) |

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

Implemented in Avro.IO.JsonEncoder, Avro.IO.BinaryEncoder, and Avro.IO.ParsingEncoder.

## ◆ WriteArrayEnd()

void Avro.IO.Encoder.WriteArrayEnd | ( |  | ) |

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

Implemented in Avro.IO.JsonEncoder, Avro.IO.BinaryEncoder, and Avro.IO.ParsingEncoder.

## ◆ 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.JsonEncoder, Avro.IO.BinaryEncoder, and Avro.IO.ParsingEncoder.

## ◆ WriteBoolean()

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

Writes a boolean value.

Parameters

  value | Value to write.

Implemented in Avro.IO.ParsingEncoder, Avro.IO.JsonEncoder, and Avro.IO.BinaryEncoder.

## ◆ WriteBytes() [1/2]

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

Writes a byte string.

Parameters

  value | Value to write.

Implemented in Avro.IO.BinaryEncoder, Avro.IO.ParsingEncoder, and Avro.IO.JsonEncoder.

## ◆ WriteBytes() [2/2]

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

Writes a byte string.

Parameters

  value | The byte[] to be read (fully or partially)
  offset | The offset from the beginning of the byte[] to start writing
  length | The length of the data to be read from the byte[].

Implemented in Avro.IO.BinaryEncoder, Avro.IO.ParsingEncoder, and Avro.IO.JsonEncoder.

## ◆ WriteDouble()

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

Writes a double value.

Parameters

  value | Value to write.

Implemented in Avro.IO.BinaryEncoder, Avro.IO.ParsingEncoder, and Avro.IO.JsonEncoder.

## ◆ WriteEnum()

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

Writes an enumeration.

Parameters

  value | Value to write.

Implemented in Avro.IO.BinaryEncoder, Avro.IO.ParsingEncoder, and Avro.IO.JsonEncoder.

## ◆ WriteFixed() [1/2]

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

Writes a fixed value.

Parameters

  data | The contents to write.

Implemented in Avro.IO.BinaryEncoder, Avro.IO.ParsingEncoder, and Avro.IO.JsonEncoder.

## ◆ WriteFixed() [2/2]

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

Writes a fixed value.

Parameters

  data | Contents to write.
  start | Position within data where the contents start.
  len | Number of bytes to write.

Implemented in Avro.IO.BinaryEncoder, Avro.IO.ParsingEncoder, and Avro.IO.JsonEncoder.

## ◆ WriteFloat()

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

Writes a float value.

Parameters

  value | Value to write.

Implemented in Avro.IO.BinaryEncoder, Avro.IO.ParsingEncoder, and Avro.IO.JsonEncoder.

## ◆ WriteInt()

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

Writes an int value.

Parameters

  value | Value to write.

Implemented in Avro.IO.BinaryEncoder, Avro.IO.ParsingEncoder, and Avro.IO.JsonEncoder.

## ◆ WriteLong()

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

Writes a long value.

Parameters

  value | Value to write.

Implemented in Avro.IO.BinaryEncoder, Avro.IO.ParsingEncoder, and Avro.IO.JsonEncoder.

## ◆ 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.JsonEncoder, Avro.IO.BinaryEncoder, and Avro.IO.ParsingEncoder.

## ◆ 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.JsonEncoder, Avro.IO.BinaryEncoder, and Avro.IO.ParsingEncoder.

## ◆ WriteNull()

void Avro.IO.Encoder.WriteNull | ( |  | ) |

Writes a null value.

Implemented in Avro.IO.JsonEncoder, Avro.IO.BinaryEncoder, and Avro.IO.ParsingEncoder.

## ◆ WriteString()

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

Writes an Unicode string.

Parameters

  value | Value to write.

Implemented in Avro.IO.BinaryEncoder, Avro.IO.ParsingEncoder, and Avro.IO.JsonEncoder.

## ◆ 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, Avro.IO.ParsingEncoder, and Avro.IO.JsonEncoder.

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

- src/apache/main/IO/Encoder.cs