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. More... | |
JsonEncoder (Schema sc, Stream stream, bool pretty) | |
Initializes a new instance of the JsonEncoder class. More... | |
JsonEncoder (Schema sc, JsonWriter writer) | |
Initializes a new instance of the JsonEncoder class. More... | |
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. More... | |
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. More... | |
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. More... | |
Public Member Functions inherited from Avro.IO.ParsingEncoder | |
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. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from Avro.IO.ParsingEncoder | |
void | Push () |
Push a new collection on to the stack. More... | |
void | Pop () |
Pop a new collection on to the stack. More... | |
int | Depth () |
Returns the position into the stack. More... | |
Protected Attributes inherited from Avro.IO.ParsingEncoder | |
int | Pos = -1 |
Position into the counts stack. More... | |
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 |
Initializes a new instance of the JsonEncoder class.
|
inline |
Initializes a new instance of the JsonEncoder class.
|
inline |
Initializes a new instance of the JsonEncoder class.
|
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.
|
getset |
Whether to include a union label when generating JSON.