Class Encoder

Low-level support for serializing Avro values.

class Encoder ;

This class has two types of methods. One type of methods support the writing of leaf values (for example, [Encoder.writeLong] and [Encoder.writeString]). These methods have analogs in [Decoder].

The other type of methods support the writing of maps and arrays. These methods are [Encoder.writeArrayStart], [Encoder.startItem], and [Encoder.writeArrayEnd] (and similar methods for maps). Some implementations of [Encoder] handle the buffering required to break large maps and arrays into blocks, which is necessary for applications that want to do streaming. (See [Encoder.writeArrayStart] for details on these methods.)

Methods

NameDescription
flush () Empty any internal buffers to the underlying output.
setItemCount (itemCount) Call this method before writing a batch of items in an array or a map. Then for each item, call [startItem()] followed by any of the other write methods of [Encoder]. The number of calls to [startItem()] must be equal to the count specified in [setItemCount()]. Once a batch is completed you can start another batch with [setItemCount()].
startItem () Start a new item of an array or map. See {@link #writeArrayStart} for usage information.
writeArrayEnd () Call this method to finish writing an array. See {@link #writeArrayStart} for usage information.
writeArrayStart () Call this method to start writing an array.
writeBoolean (b) Write a boolean value.
writeBytes (bytes, start, len) Write a byte string.
writeBytes (bytes) Writes a byte string. Equivalent to writeBytes(bytes, 0, bytes.length)
writeDouble (d) Write a double.
writeEnum (e, sym) Writes an enumeration.
writeFixed (bytes, start, len) Writes a fixed size binary object.
writeFixed (bytes) A shorthand for writeFixed(bytes, 0, bytes.length).
writeFloat (f) Write a float.
writeInt (n) Writes a 32-bit integer.
writeLong (n) Write a 64-bit integer.
writeMapEnd () Call this method to terminate the inner-most, currently-opened map. See [writeArrayStart] for more details.
writeMapStart () Call this to start a new map. See [writeArrayStart] for details on usage.
writeNull () "Writes" a null value. (Doesn't actually write anything, but advances the state of the parser if this class is stateful.)
writeRecordEnd ()
writeRecordStart ()
writeString (str) Write a Unicode character string.
writeUnionType (unionTypeIndex, unionTypeName) Call this method to write the tag of a union.