public class BufferedBinaryEncoder extends BinaryEncoder
Encoder for Avro's binary encoding.
This implementation buffers output to enhance performance. Output may not
appear on the underlying output until flush() is called.
DirectBinaryEncoder can be used in place of this implementation if
the buffering semantics are not desired, and the performance difference is
acceptable.
To construct or reconfigure, use
EncoderFactory.binaryEncoder(OutputStream, BinaryEncoder).
To change the buffer size, configure the factory instance used to create
instances with EncoderFactory.configureBufferSize(int)Encoder,
EncoderFactory,
BlockingBinaryEncoder,
DirectBinaryEncoder| Modifier and Type | Method and Description |
|---|---|
int |
bytesBuffered()
Returns the number of bytes currently buffered by this encoder.
|
void |
flush() |
void |
writeBoolean(boolean b)
Write a boolean value.
|
void |
writeDouble(double d)
Write a double.
|
void |
writeFixed(byte[] bytes,
int start,
int len)
Writes a fixed size binary object.
|
void |
writeFixed(ByteBuffer bytes)
Writes a fixed from a ByteBuffer.
|
void |
writeFloat(float f)
Write a float.
|
void |
writeInt(int n)
Writes a 32-bit integer.
|
void |
writeLong(long n)
Write a 64-bit integer.
|
protected void |
writeZero()
Write a zero byte to the underlying output.
|
setItemCount, startItem, writeArrayEnd, writeArrayStart, writeBytes, writeBytes, writeEnum, writeIndex, writeMapEnd, writeMapStart, writeNull, writeString, writeStringwriteBytes, writeFixed, writeStringpublic void flush()
throws IOException
IOExceptionpublic void writeBoolean(boolean b)
throws IOException
EncoderwriteBoolean in class EncoderIOExceptionpublic void writeInt(int n)
throws IOException
EncoderwriteInt in class EncoderIOExceptionpublic void writeLong(long n)
throws IOException
EncoderwriteLong in class EncoderIOExceptionpublic void writeFloat(float f)
throws IOException
EncoderwriteFloat in class EncoderIOExceptionpublic void writeDouble(double d)
throws IOException
EncoderwriteDouble in class EncoderIOExceptionpublic void writeFixed(byte[] bytes,
int start,
int len)
throws IOException
EncoderwriteFixed in class Encoderbytes - The contents to writestart - The position within bytes where the contents start.len - The number of bytes to write.IOExceptionpublic void writeFixed(ByteBuffer bytes) throws IOException
EncoderwriteFixed in class EncoderIOExceptionprotected void writeZero()
throws IOException
BinaryEncoderwriteZero in class BinaryEncoderIOExceptionpublic int bytesBuffered()
BinaryEncoderFlushable.flush() to empty the buffer to the underlying output.bytesBuffered in class BinaryEncoderCopyright © 2009–2023 The Apache Software Foundation. All rights reserved.