Top Description Fields Constructors Methods
org.apache.avro.io

public Class DirectBinaryEncoder

extends BinaryEncoder
Class Inheritance
Imports
java.io.IOException, .OutputStream, java.util.Objects

An Encoder for Avro's binary encoding that does not buffer output.

This encoder does not buffer writes, and as a result is slower than BufferedBinaryEncoder. However, it is lighter-weight and useful when the buffering in BufferedBinaryEncoder is not desired and/or the Encoder is very short lived.

To construct, use EncoderFactory#directBinaryEncoder(OutputStream, BinaryEncoder)

DirectBinaryEncoder is not thread-safe

See Also
BinaryEncoder, EncoderFactory, Encoder, Decoder

Field Summary

Modifier and TypeField and Description
private final byte[]
private OutputStream

Constructor Summary

AccessConstructor and Description
pack-priv
DirectBinaryEncoder(OutputStream out)

Create a writer that sends its output to the underlying stream out.

Method Summary

Modifier and TypeMethod and Description
public int
bytesBuffered()

Implements abstract org.apache.avro.io.BinaryEncoder.bytesBuffered.

Returns the number of bytes currently buffered by this encoder.
pack-priv DirectBinaryEncoder
public void
flush()

Implements java.io.Flushable.flush.

Flushes this stream by writing any buffered output to the underlying stream.
public void
writeBoolean(boolean b)

Implements abstract org.apache.avro.io.Encoder.writeBoolean.

Write a boolean value.
public void
writeDouble(double d)

Implements abstract org.apache.avro.io.Encoder.writeDouble.

Write a double.
public void
writeFixed(byte[]
The contents to write
bytes
,
int
The position within bytes where the contents start.
start
,
int
The number of bytes to write.
len
)

Implements abstract org.apache.avro.io.Encoder.writeFixed.

Writes a fixed size binary object.
public void
writeFloat(float f)

Implements abstract org.apache.avro.io.Encoder.writeFloat.

Write a float.
public void
writeInt(int n)

Implements abstract org.apache.avro.io.Encoder.writeInt.

Writes a 32-bit integer.
public void
writeLong(long n)

Implements abstract org.apache.avro.io.Encoder.writeLong.

Write a 64-bit integer.
protected void
writeZero()

Implements abstract org.apache.avro.io.BinaryEncoder.writeZero.

Write a zero byte to the underlying output.
Inherited from org.apache.avro.io.BinaryEncoder:
setItemCountstartItemwriteArrayEndwriteArrayStartwriteByteswriteByteswriteEnumwriteIndexwriteMapEndwriteMapStartwriteNullwriteStringwriteString

Field Detail

bufback to summary
private final byte[] buf
outback to summary
private OutputStream out

Constructor Detail

DirectBinaryEncoderback to summary
pack-priv DirectBinaryEncoder(OutputStream out)

Create a writer that sends its output to the underlying stream out.

Method Detail

bytesBufferedback to summary
public int bytesBuffered()

Implements abstract org.apache.avro.io.BinaryEncoder.bytesBuffered.

Doc from org.apache.avro.io.BinaryEncoder.bytesBuffered.

Returns the number of bytes currently buffered by this encoder. If this Encoder does not buffer, this will always return zero.

Call flush() to empty the buffer to the underlying output.

Annotations
@Override
configureback to summary
pack-priv DirectBinaryEncoder configure(OutputStream out)
flushback to summary
public void flush() throws IOException

Implements java.io.Flushable.flush.

Doc from java.io.Flushable.flush.

Flushes this stream by writing any buffered output to the underlying stream.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
writeBooleanback to summary
public void writeBoolean(boolean b) throws IOException

Implements abstract org.apache.avro.io.Encoder.writeBoolean.

Doc from org.apache.avro.io.Encoder.writeBoolean.

Write a boolean value.

Annotations
@Override
writeDoubleback to summary
public void writeDouble(double d) throws IOException

Implements abstract org.apache.avro.io.Encoder.writeDouble.

Doc from org.apache.avro.io.Encoder.writeDouble.

Write a double.

Annotations
@Override
writeFixedback to summary
public void writeFixed(byte[] bytes, int start, int len) throws IOException

Implements abstract org.apache.avro.io.Encoder.writeFixed.

Doc from org.apache.avro.io.Encoder.writeFixed.

Writes a fixed size binary object.

Parameters
bytes:byte[]

The contents to write

start:int

The position within bytes where the contents start.

len:int

The number of bytes to write.

Annotations
@Override
writeFloatback to summary
public void writeFloat(float f) throws IOException

Implements abstract org.apache.avro.io.Encoder.writeFloat.

Doc from org.apache.avro.io.Encoder.writeFloat.

Write a float.

Annotations
@Override
writeIntback to summary
public void writeInt(int n) throws IOException

Implements abstract org.apache.avro.io.Encoder.writeInt.

Doc from org.apache.avro.io.Encoder.writeInt.

Writes a 32-bit integer.

Annotations
@Override
writeLongback to summary
public void writeLong(long n) throws IOException

Implements abstract org.apache.avro.io.Encoder.writeLong.

Doc from org.apache.avro.io.Encoder.writeLong.

Write a 64-bit integer.

Annotations
@Override
writeZeroback to summary
protected void writeZero() throws IOException

Implements abstract org.apache.avro.io.BinaryEncoder.writeZero.

Doc from org.apache.avro.io.BinaryEncoder.writeZero.

Write a zero byte to the underlying output.

Annotations
@Override