Avro C#

Public Member Functions | List of all members
Avro.IO.BinaryEncoder Class Reference

Write leaf values. More...

Inheritance diagram for Avro.IO.BinaryEncoder:

## Public Member Functions
| BinaryEncoder ()
| Initializes a new instance of the BinaryEncoder class without a backing stream. More...
| BinaryEncoder (Stream stream)
| Initializes a new instance of the BinaryEncoder class that writes to the provided stream. More...
void | WriteNull ()
| null is written as zero bytes More...
void | WriteBoolean (bool b)
| true is written as 1 and false 0. More...
void | WriteInt (int value)
| int and long values are written using variable-length, zig-zag coding. More...
void | WriteLong (long value)
| int and long values are written using variable-length, zig-zag coding. More...
void | WriteFloat (float value)
| A float is written as 4 bytes. The float is converted into a 32-bit integer using a method equivalent to Java's floatToIntBits and then encoded in little-endian format. More...
void | WriteDouble (double value)
| A double is written as 8 bytes. The double is converted into a 64-bit integer using a method equivalent to Java's doubleToLongBits and then encoded in little-endian format. More...
void | WriteBytes (byte[] value)
| Bytes are encoded as a long followed by that many bytes of data. More...
void | WriteBytes (byte[] value, int offset, int length)
| Bytes are encoded as a long followed by that many bytes of data. More...
void | WriteString (string value)
| A string is encoded as a long followed by that many bytes of UTF-8 encoded character data. More...
void | WriteEnum (int value)
| Writes an enumeration.
void | StartItem ()
| Start a new item of an array or map. See WriteArrayStart for usage information.
void | SetItemCount (long value)
| Call this method before writing a batch of items in an array or a map.
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: out.WriteArrayStart(); out.SetItemCount(list.Count); foreach (var r in list) { out.StartItem(); out.WriteLong(r.LongField); out.WriteBoolean(r.BoolField); } out.WriteArrayEnd();
void | WriteArrayEnd ()
| Call this method to finish writing an array. See WriteArrayStart for usage information.
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: 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();
void | WriteMapEnd ()
| Call this method to terminate the inner-most, currently-opened map. See WriteArrayStart for more details.
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: out.WriteIndex(1); out.WriteLong(record.LongField); out.WriteBoolean(record.BoolField);
void | WriteFixed (byte[] data)
| Writes a fixed value.
void | WriteFixed (byte[] data, int start, int len)
| Writes a fixed value.
void | Flush ()
| Flushes the underlying stream. More...

## Detailed Description

Write leaf values.

## Constructor & Destructor Documentation

## ◆ BinaryEncoder() [1/2]

Avro.IO.BinaryEncoder.BinaryEncoder | ( |  | ) |
| inline

Initializes a new instance of the BinaryEncoder class without a backing stream.

## ◆ BinaryEncoder() [2/2]

Avro.IO.BinaryEncoder.BinaryEncoder | ( | Stream | stream | ) |
| inline

Initializes a new instance of the BinaryEncoder class that writes to the provided stream.

Parameters

  stream | Stream to write to.

## Member Function Documentation

## ◆ Flush()

void Avro.IO.BinaryEncoder.Flush | ( |  | ) |
| inline

Flushes the underlying stream.

Implements Avro.IO.Encoder.

## ◆ WriteBoolean()

void Avro.IO.BinaryEncoder.WriteBoolean | ( | bool | b | ) |
| inline

true is written as 1 and false 0.

Parameters

  b | Boolean value to write

Implements Avro.IO.Encoder.

## ◆ WriteBytes() [1/2]

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

Bytes are encoded as a long followed by that many bytes of data.

Parameters

  value |

Implements Avro.IO.Encoder.

## ◆ WriteBytes() [2/2]

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

Bytes are encoded as a long followed by that many bytes of data.

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[].

Implements Avro.IO.Encoder.

## ◆ WriteDouble()

void Avro.IO.BinaryEncoder.WriteDouble | ( | double | value | ) |
| inline

A double is written as 8 bytes. The double is converted into a 64-bit integer using a method equivalent to Java's doubleToLongBits and then encoded in little-endian format.

Parameters

  value |

Implements Avro.IO.Encoder.

## ◆ WriteFloat()

void Avro.IO.BinaryEncoder.WriteFloat | ( | float | value | ) |
| inline

A float is written as 4 bytes. The float is converted into a 32-bit integer using a method equivalent to Java's floatToIntBits and then encoded in little-endian format.

Parameters

  value |

Implements Avro.IO.Encoder.

## ◆ WriteInt()

void Avro.IO.BinaryEncoder.WriteInt | ( | int | value | ) |
| inline

int and long values are written using variable-length, zig-zag coding.

Parameters

  value | Value to write

Implements Avro.IO.Encoder.

## ◆ WriteLong()

void Avro.IO.BinaryEncoder.WriteLong | ( | long | value | ) |
| inline

int and long values are written using variable-length, zig-zag coding.

Parameters

  value | Value to write

Implements Avro.IO.Encoder.

## ◆ WriteNull()

void Avro.IO.BinaryEncoder.WriteNull | ( |  | ) |
| inline

null is written as zero bytes

Implements Avro.IO.Encoder.

## ◆ WriteString()

void Avro.IO.BinaryEncoder.WriteString | ( | string | value | ) |
| inline

A string is encoded as a long followed by that many bytes of UTF-8 encoded character data.

Parameters

  value |

Implements Avro.IO.Encoder.

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

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