Avro C#
|
An Encoder for Avro's JSON data encoding. More...
Public Member Functions | |||||||
JsonEncoder (Schema sc, Stream stream) | |||||||
Initializes a new instance of the JsonEncoder class. | |||||||
JsonEncoder (Schema sc, Stream stream, bool pretty) | |||||||
Initializes a new instance of the JsonEncoder class. | |||||||
JsonEncoder (Schema sc, JsonWriter writer) | |||||||
Initializes a new instance of the JsonEncoder class. | |||||||
override void | Flush () | ||||||
Flushes the encoder. | |||||||
void | Configure (Stream stream) | ||||||
Reconfigures this JsonEncoder to use the output stream provided. Otherwise, this JsonEncoder will flush its current output and then reconfigure its output to use a default UTF8 JsonWriter that writes to the provided Stream. | |||||||
void | Configure (JsonWriter jsonWriter) | ||||||
Reconfigures this JsonEncoder to output to the JsonWriter provided. Otherwise, this JsonEncoder will flush its current output and then reconfigure its output to use the provided JsonWriter. | |||||||
override void | WriteNull () | ||||||
Writes a null value. | |||||||
override void | WriteBoolean (bool b) | ||||||
Writes a boolean value.
| |||||||
override void | WriteInt (int n) | ||||||
Writes an int value.
| |||||||
override void | WriteLong (long n) | ||||||
Writes a long value.
| |||||||
override void | WriteFloat (float f) | ||||||
Writes a float value.
| |||||||
override void | WriteDouble (double d) | ||||||
Writes a double value.
| |||||||
override void | WriteString (string str) | ||||||
Writes an Unicode string.
| |||||||
override void | WriteBytes (byte[] bytes) | ||||||
Writes a byte string.
| |||||||
override void | WriteBytes (byte[] bytes, int start, int len) | ||||||
Writes a byte string.
| |||||||
override void | WriteFixed (byte[] bytes) | ||||||
Writes a fixed value.
| |||||||
override void | WriteFixed (byte[] bytes, int start, int len) | ||||||
Writes a fixed value.
| |||||||
override void | WriteEnum (int e) | ||||||
Writes an enumeration.
| |||||||
override 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();
| |||||||
override void | WriteArrayEnd () | ||||||
Call this method to finish writing an array. See WriteArrayStart for usage information. | |||||||
override 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();
| |||||||
override void | WriteMapEnd () | ||||||
Call this method to terminate the inner-most, currently-opened map. See WriteArrayStart for more details. | |||||||
override void | StartItem () | ||||||
Start a new item of an array or map. See WriteArrayStart for usage information. | |||||||
override void | WriteUnionIndex (int unionIndex) | ||||||
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);
| |||||||
virtual Symbol | DoAction (Symbol input, Symbol top) | ||||||
Perform an action based on the given input. | |||||||
![]() | |||||||
void | WriteNull () | ||||||
Writes a null value. | |||||||
void | WriteBoolean (bool value) | ||||||
Writes a boolean value.
| |||||||
void | WriteInt (int value) | ||||||
Writes an int value.
| |||||||
void | WriteLong (long value) | ||||||
Writes a long value.
| |||||||
void | WriteFloat (float value) | ||||||
Writes a float value.
| |||||||
void | WriteDouble (double value) | ||||||
Writes a double value.
| |||||||
void | WriteBytes (byte[] value) | ||||||
Writes a byte string.
| |||||||
void | WriteBytes (byte[] value, int offset, int length) | ||||||
Writes a byte string.
| |||||||
void | WriteString (string value) | ||||||
Writes an Unicode string.
| |||||||
void | WriteEnum (int value) | ||||||
Writes an enumeration.
| |||||||
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 encoder. | |||||||
virtual void | SetItemCount (long value) | ||||||
Call this method before writing a batch of items in an array or a map.
| |||||||
Properties | |
virtual bool | IncludeNamespace [get, set] |
Whether to include a union label when generating JSON. | |
Additional Inherited Members | |
![]() | |
void | Push () |
Push a new collection on to the stack. | |
void | Pop () |
Pop a new collection on to the stack. | |
int | Depth () |
Returns the position into the stack. | |
![]() | |
int | Pos = -1 |
Position into the counts stack. | |
An Encoder for Avro's JSON data encoding.
JsonEncoder buffers output, and data may not appear on the output until Encoder.Flush() is called.
JsonEncoder is not thread-safe.
|
inline |
Reconfigures this JsonEncoder to output to the JsonWriter provided. Otherwise, this JsonEncoder will flush its current output and then reconfigure its output to use the provided JsonWriter.
jsonWriter | The JsonWriter to direct output to. Cannot be null. |
|
inline |
Reconfigures this JsonEncoder to use the output stream provided. Otherwise, this JsonEncoder will flush its current output and then reconfigure its output to use a default UTF8 JsonWriter that writes to the provided Stream.
stream | The Stream to direct output to. Cannot be null. |
Perform an action based on the given input.
Implements Avro.IO.Parsing.Parser.IActionHandler.
|
inline |
Flushes the encoder.
Implements Avro.IO.Encoder.
|
inlinevirtual |
Start a new item of an array or map. See WriteArrayStart for usage information.
Reimplemented from Avro.IO.ParsingEncoder.
|
inline |
Call this method to finish writing an array. See WriteArrayStart for usage information.
Implements Avro.IO.Encoder.
|
inline |
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:
Implements Avro.IO.Encoder.
|
inline |
|
inline |
|
inline |
Writes a byte string.
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 |
|
inline |
|
inline |
|
inline |
Writes a fixed value.
data | Contents to write. |
start | Position within data where the contents start. |
len | Number of bytes to write. |
Implements Avro.IO.Encoder.
|
inline |
|
inline |
|
inline |
|
inline |
Call this method to terminate the inner-most, currently-opened map. See WriteArrayStart for more details.
Implements Avro.IO.Encoder.
|
inline |
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:
Implements Avro.IO.Encoder.
|
inline |
Writes a null value.
Implements Avro.IO.Encoder.
|
inline |
|
inline |
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:
Implements Avro.IO.Encoder.