Package org.apache.avro.io
Class ByteBufferOptimizedBinaryDecoder
java.lang.Object
org.apache.avro.io.Decoder
org.apache.avro.io.BinaryDecoder
org.apache.avro.io.ByteBufferOptimizedBinaryDecoder
public class ByteBufferOptimizedBinaryDecoder
extends org.apache.avro.io.BinaryDecoder
This class is a wrapper of
BinaryDecoder
with the following optimization:
When deserializing byte array field, instead of copying the bytes into a new ByteBuffer
,
this class will create a ByteBuffer, which is wrapping the original array.
This optimization is useful when we know that the original array won't change during the lifecycle.
This optimization should work with both 1.4 and 1.7.-
Constructor Summary
ConstructorDescriptionByteBufferOptimizedBinaryDecoder
(byte[] data) ByteBufferOptimizedBinaryDecoder
(byte[] data, int offset, int length) -
Method Summary
Modifier and TypeMethodDescriptionlong
boolean
isEnd()
long
mapNext()
long
boolean
readBytes
(ByteBuffer old) double
int
readEnum()
void
readFixed
(byte[] bytes, int start, int length) float
int
int
readInt()
long
readLong()
long
void
readNull()
org.apache.avro.util.Utf8
readString
(org.apache.avro.util.Utf8 old) long
void
void
skipFixed
(int length) long
skipMap()
void
Methods inherited from class org.apache.avro.io.BinaryDecoder
doReadBytes, doReadItemCount, doSkipBytes
Methods inherited from class org.apache.avro.io.Decoder
readFixed
-
Constructor Details
-
ByteBufferOptimizedBinaryDecoder
public ByteBufferOptimizedBinaryDecoder(byte[] data) -
ByteBufferOptimizedBinaryDecoder
public ByteBufferOptimizedBinaryDecoder(byte[] data, int offset, int length)
-
-
Method Details
-
readString
- Overrides:
readString
in classorg.apache.avro.io.BinaryDecoder
- Throws:
IOException
-
readNull
- Overrides:
readNull
in classorg.apache.avro.io.BinaryDecoder
- Throws:
IOException
-
readBoolean
- Overrides:
readBoolean
in classorg.apache.avro.io.BinaryDecoder
- Throws:
IOException
-
readInt
- Overrides:
readInt
in classorg.apache.avro.io.BinaryDecoder
- Throws:
IOException
-
readLong
- Overrides:
readLong
in classorg.apache.avro.io.BinaryDecoder
- Throws:
IOException
-
readFloat
- Overrides:
readFloat
in classorg.apache.avro.io.BinaryDecoder
- Throws:
IOException
-
readDouble
- Overrides:
readDouble
in classorg.apache.avro.io.BinaryDecoder
- Throws:
IOException
-
readString
- Overrides:
readString
in classorg.apache.avro.io.BinaryDecoder
- Throws:
IOException
-
skipString
- Overrides:
skipString
in classorg.apache.avro.io.BinaryDecoder
- Throws:
IOException
-
readBytes
- Overrides:
readBytes
in classorg.apache.avro.io.BinaryDecoder
- Throws:
IOException
-
skipBytes
- Overrides:
skipBytes
in classorg.apache.avro.io.BinaryDecoder
- Throws:
IOException
-
readFixed
- Overrides:
readFixed
in classorg.apache.avro.io.BinaryDecoder
- Throws:
IOException
-
skipFixed
- Overrides:
skipFixed
in classorg.apache.avro.io.BinaryDecoder
- Throws:
IOException
-
readEnum
- Overrides:
readEnum
in classorg.apache.avro.io.BinaryDecoder
- Throws:
IOException
-
readArrayStart
- Overrides:
readArrayStart
in classorg.apache.avro.io.BinaryDecoder
- Throws:
IOException
-
arrayNext
- Overrides:
arrayNext
in classorg.apache.avro.io.BinaryDecoder
- Throws:
IOException
-
skipArray
- Overrides:
skipArray
in classorg.apache.avro.io.BinaryDecoder
- Throws:
IOException
-
readMapStart
- Overrides:
readMapStart
in classorg.apache.avro.io.BinaryDecoder
- Throws:
IOException
-
mapNext
- Overrides:
mapNext
in classorg.apache.avro.io.BinaryDecoder
- Throws:
IOException
-
skipMap
- Overrides:
skipMap
in classorg.apache.avro.io.BinaryDecoder
- Throws:
IOException
-
readIndex
- Overrides:
readIndex
in classorg.apache.avro.io.BinaryDecoder
- Throws:
IOException
-
isEnd
- Overrides:
isEnd
in classorg.apache.avro.io.BinaryDecoder
- Throws:
IOException
-
inputStream
- Overrides:
inputStream
in classorg.apache.avro.io.BinaryDecoder
-