Package org.apache.avro.io
Class BufferedBinaryEncoder
java.lang.Object
org.apache.avro.io.Encoder
org.apache.avro.io.BinaryEncoder
org.apache.avro.io.BufferedBinaryEncoder
- All Implemented Interfaces:
Flushable
- Direct Known Subclasses:
BlockingBinaryEncoder
An
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)- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionintReturns the number of bytes currently buffered by this encoder.voidflush()voidwriteBoolean(boolean b) Write a boolean value.voidwriteDouble(double d) Write a double.voidwriteFixed(byte[] bytes, int start, int len) Writes a fixed size binary object.voidwriteFixed(ByteBuffer bytes) Writes a fixed from a ByteBuffer.voidwriteFloat(float f) Write a float.voidwriteInt(int n) Writes a 32-bit integer.voidwriteLong(long n) Write a 64-bit integer.protected voidWrite a zero byte to the underlying output.Methods inherited from class org.apache.avro.io.BinaryEncoder
setItemCount, startItem, writeArrayEnd, writeArrayStart, writeBytes, writeBytes, writeEnum, writeIndex, writeMapEnd, writeMapStart, writeNull, writeString, writeStringMethods inherited from class org.apache.avro.io.Encoder
writeBytes, writeFixed, writeString
-
Method Details
-
flush
- Throws:
IOException
-
writeBoolean
Description copied from class:EncoderWrite a boolean value.- Specified by:
writeBooleanin classEncoder- Throws:
IOException
-
writeInt
Description copied from class:EncoderWrites a 32-bit integer.- Specified by:
writeIntin classEncoder- Throws:
IOException
-
writeLong
Description copied from class:EncoderWrite a 64-bit integer.- Specified by:
writeLongin classEncoder- Throws:
IOException
-
writeFloat
Description copied from class:EncoderWrite a float.- Specified by:
writeFloatin classEncoder- Throws:
IOException
-
writeDouble
Description copied from class:EncoderWrite a double.- Specified by:
writeDoublein classEncoder- Throws:
IOException
-
writeFixed
Description copied from class:EncoderWrites a fixed size binary object.- Specified by:
writeFixedin classEncoder- Parameters:
bytes- The contents to writestart- The position within bytes where the contents start.len- The number of bytes to write.- Throws:
IOException
-
writeFixed
Description copied from class:EncoderWrites a fixed from a ByteBuffer.- Overrides:
writeFixedin classEncoder- Throws:
IOException
-
writeZero
Description copied from class:BinaryEncoderWrite a zero byte to the underlying output.- Specified by:
writeZeroin classBinaryEncoder- Throws:
IOException
-
bytesBuffered
public int bytesBuffered()Description copied from class:BinaryEncoderReturns the number of bytes currently buffered by this encoder. If this Encoder does not buffer, this will always return zero. CallFlushable.flush()to empty the buffer to the underlying output.- Specified by:
bytesBufferedin classBinaryEncoder
-