Encoder for Avro's binary encoding.
To construct and configure instances, use EncoderFactory
EncoderFactory, BufferedBinaryEncoder, DirectBinaryEncoder, BlockingBinaryEncoder, Encoder, Decoder
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public abstract int | |
| public void | setItemCount(long
The number of itemCount)startItem() calls to follow.Implements abstract org. |
| public void | startItem()
Implements abstract org. |
| public void | writeArrayEnd()
Implements abstract org. |
| public void | writeArrayStart()
Implements abstract org. |
| public void | writeBytes(ByteBuffer bytes)
Implements abstract org. |
| public void | writeBytes(byte[] bytes, int start, int len)
Implements abstract org. |
| public void | |
| public void | writeIndex(int unionIndex)
Implements abstract org. |
| public void | writeMapEnd()
Implements abstract org. |
| public void | writeMapStart()
Implements abstract org. |
| public void | |
| public void | writeString(Utf8 utf8)
Implements abstract org. |
| public void | writeString(String string)
Overrides org. |
| protected abstract void |
| BinaryEncoder | back to summary |
|---|---|
| public BinaryEncoder() | |
| bytesBuffered | back to summary |
|---|---|
| public abstract int bytesBuffered() Returns the number of bytes currently buffered by this encoder. If this Encoder does not buffer, this will always return zero.
Call | |
| setItemCount | back to summary |
|---|---|
| public void setItemCount(long itemCount) throws IOException Implements abstract org. Doc from org. Call this method before writing a batch of items in an array or a map. Then
for each item, call
| |
| startItem | back to summary |
|---|---|
| public void startItem() throws IOException Implements abstract org. Doc from org. Start a new item of an array or map. See
| |
| writeArrayEnd | back to summary |
|---|---|
| public void writeArrayEnd() throws IOException Implements abstract org. Doc from org. Call this method to finish writing an array. See
| |
| writeArrayStart | back to summary |
|---|---|
| public void writeArrayStart() throws IOException Implements abstract org. Doc from org. Call this method to start writing an array.
When starting to serialize an array, call
out.writeArrayStart();
out.setItemCount(list.size());
for (Record r : list) {
out.startItem();
out.writeLong(r.longField);
out.writeBoolean(r.boolField);
}
out.writeArrayEnd();
| |
| writeBytes | back to summary |
|---|---|
| public void writeBytes(ByteBuffer bytes) throws IOException Implements abstract org. Doc from org. Write a byte string.
| |
| writeBytes | back to summary |
|---|---|
| public void writeBytes(byte[] bytes, int start, int len) throws IOException Implements abstract org. Doc from org. Write a byte string.
| |
| writeEnum | back to summary |
|---|---|
| public void writeEnum(int e) throws IOException Implements abstract org. Doc from org. Writes an enumeration.
| |
| writeIndex | back to summary |
|---|---|
| public void writeIndex(int unionIndex) throws IOException Implements abstract org. Doc from org. 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);
| |
| writeMapEnd | back to summary |
|---|---|
| public void writeMapEnd() throws IOException Implements abstract org. Doc from org. Call this method to terminate the inner-most, currently-opened map. See
| |
| writeMapStart | back to summary |
|---|---|
| public void writeMapStart() throws IOException Implements abstract org. Doc from org. Call this to start a new map. See out.writeMapStart(); out.setItemCount(list.size()); for (Map.Entry
| |
| writeNull | back to summary |
|---|---|
| public void writeNull() throws IOException Implements abstract org. Doc from org. "Writes" a null value. (Doesn't actually write anything, but advances the state of the parser if this class is stateful.)
| |
| writeString | back to summary |
|---|---|
| public void writeString(Utf8 utf8) throws IOException Implements abstract org. Doc from org. Write a Unicode character string.
| |
| writeString | back to summary |
|---|---|
| public void writeString(String string) throws IOException Overrides org. Doc from org. Write a Unicode character string. The default implementation converts the
String to a
| |
| writeZero | back to summary |
|---|---|
| protected abstract void writeZero() throws IOException Write a zero byte to the underlying output. | |