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 ofBinaryDecoder
with the following optimization: When deserializing byte array field, instead of copying the bytes into a newByteBuffer
, 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
Constructors Constructor Description ByteBufferOptimizedBinaryDecoder(byte[] data)
ByteBufferOptimizedBinaryDecoder(byte[] data, int offset, int length)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
arrayNext()
java.io.InputStream
inputStream()
boolean
isEnd()
long
mapNext()
long
readArrayStart()
boolean
readBoolean()
java.nio.ByteBuffer
readBytes(java.nio.ByteBuffer old)
double
readDouble()
int
readEnum()
void
readFixed(byte[] bytes, int start, int length)
float
readFloat()
int
readIndex()
int
readInt()
long
readLong()
long
readMapStart()
void
readNull()
java.lang.String
readString()
org.apache.avro.util.Utf8
readString(org.apache.avro.util.Utf8 old)
long
skipArray()
void
skipBytes()
void
skipFixed(int length)
long
skipMap()
void
skipString()
-
-
-
Method Detail
-
readString
public java.lang.String readString() throws java.io.IOException
- Overrides:
readString
in classorg.apache.avro.io.BinaryDecoder
- Throws:
java.io.IOException
-
readNull
public void readNull() throws java.io.IOException
- Overrides:
readNull
in classorg.apache.avro.io.BinaryDecoder
- Throws:
java.io.IOException
-
readBoolean
public boolean readBoolean() throws java.io.IOException
- Overrides:
readBoolean
in classorg.apache.avro.io.BinaryDecoder
- Throws:
java.io.IOException
-
readInt
public int readInt() throws java.io.IOException
- Overrides:
readInt
in classorg.apache.avro.io.BinaryDecoder
- Throws:
java.io.IOException
-
readLong
public long readLong() throws java.io.IOException
- Overrides:
readLong
in classorg.apache.avro.io.BinaryDecoder
- Throws:
java.io.IOException
-
readFloat
public float readFloat() throws java.io.IOException
- Overrides:
readFloat
in classorg.apache.avro.io.BinaryDecoder
- Throws:
java.io.IOException
-
readDouble
public double readDouble() throws java.io.IOException
- Overrides:
readDouble
in classorg.apache.avro.io.BinaryDecoder
- Throws:
java.io.IOException
-
readString
public org.apache.avro.util.Utf8 readString(org.apache.avro.util.Utf8 old) throws java.io.IOException
- Overrides:
readString
in classorg.apache.avro.io.BinaryDecoder
- Throws:
java.io.IOException
-
skipString
public void skipString() throws java.io.IOException
- Overrides:
skipString
in classorg.apache.avro.io.BinaryDecoder
- Throws:
java.io.IOException
-
readBytes
public java.nio.ByteBuffer readBytes(java.nio.ByteBuffer old) throws java.io.IOException
- Overrides:
readBytes
in classorg.apache.avro.io.BinaryDecoder
- Throws:
java.io.IOException
-
skipBytes
public void skipBytes() throws java.io.IOException
- Overrides:
skipBytes
in classorg.apache.avro.io.BinaryDecoder
- Throws:
java.io.IOException
-
readFixed
public void readFixed(byte[] bytes, int start, int length) throws java.io.IOException
- Overrides:
readFixed
in classorg.apache.avro.io.BinaryDecoder
- Throws:
java.io.IOException
-
skipFixed
public void skipFixed(int length) throws java.io.IOException
- Overrides:
skipFixed
in classorg.apache.avro.io.BinaryDecoder
- Throws:
java.io.IOException
-
readEnum
public int readEnum() throws java.io.IOException
- Overrides:
readEnum
in classorg.apache.avro.io.BinaryDecoder
- Throws:
java.io.IOException
-
readArrayStart
public long readArrayStart() throws java.io.IOException
- Overrides:
readArrayStart
in classorg.apache.avro.io.BinaryDecoder
- Throws:
java.io.IOException
-
arrayNext
public long arrayNext() throws java.io.IOException
- Overrides:
arrayNext
in classorg.apache.avro.io.BinaryDecoder
- Throws:
java.io.IOException
-
skipArray
public long skipArray() throws java.io.IOException
- Overrides:
skipArray
in classorg.apache.avro.io.BinaryDecoder
- Throws:
java.io.IOException
-
readMapStart
public long readMapStart() throws java.io.IOException
- Overrides:
readMapStart
in classorg.apache.avro.io.BinaryDecoder
- Throws:
java.io.IOException
-
mapNext
public long mapNext() throws java.io.IOException
- Overrides:
mapNext
in classorg.apache.avro.io.BinaryDecoder
- Throws:
java.io.IOException
-
skipMap
public long skipMap() throws java.io.IOException
- Overrides:
skipMap
in classorg.apache.avro.io.BinaryDecoder
- Throws:
java.io.IOException
-
readIndex
public int readIndex() throws java.io.IOException
- Overrides:
readIndex
in classorg.apache.avro.io.BinaryDecoder
- Throws:
java.io.IOException
-
isEnd
public boolean isEnd() throws java.io.IOException
- Overrides:
isEnd
in classorg.apache.avro.io.BinaryDecoder
- Throws:
java.io.IOException
-
inputStream
public java.io.InputStream inputStream()
- Overrides:
inputStream
in classorg.apache.avro.io.BinaryDecoder
-
-