Avro C#
|
Write leaf values. More...
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... | |
Write leaf values.
|
inline |
Initializes a new instance of the BinaryEncoder class without a backing stream.
|
inline |
Initializes a new instance of the BinaryEncoder class that writes to the provided stream.
stream | Stream to write to. |
|
inline |
Flushes the underlying stream.
Implements Avro.IO.Encoder.
|
inline |
|
inline |
Bytes are encoded as a long followed by that many bytes of data.
value |
Implements Avro.IO.Encoder.
|
inline |
Bytes are encoded as a long followed by that many bytes of data.
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.
|
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.
value |
Implements Avro.IO.Encoder.
|
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.
value |
Implements Avro.IO.Encoder.
|
inline |
int and long values are written using variable-length, zig-zag coding.
value | Value to write |
Implements Avro.IO.Encoder.
|
inline |
int and long values are written using variable-length, zig-zag coding.
value | Value to write |
Implements Avro.IO.Encoder.
|
inline |
null is written as zero bytes
Implements Avro.IO.Encoder.
|
inline |
A string is encoded as a long followed by that many bytes of UTF-8 encoded character data.
value |
Implements Avro.IO.Encoder.