Top Description Fields Constructors Methods
com.fasterxml.jackson.dataformat.avro.apacheimpl

public Class DecoderOverAvroParser

extends Decoder
Class Inheritance
Imports
java.io.IOException, java.nio.ByteBuffer, java.util.Arrays, org.apache.avro.io.Decoder, org.apache.avro.util.Utf8, com.fasterxml.jackson.core.JsonToken, com.fasterxml.jackson.dataformat.avro.deser.AvroParserImpl

Wraps an AvroParser instance and allows it to be advanced by reading from it like an avro Decoder

Field Summary

Modifier and TypeField and Description
protected final AvroParserImpl

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public long
arrayNext()

Implements abstract org.apache.avro.io.Decoder.arrayNext.

Processes the next block of an array and returns the number of items in the block and let's the caller read those items.

protected JsonToken

Returns:

The token that was consumed from the parser
consumeToken
(JsonToken...
List of token types that is expected
expectedTokens
)

Reads in the next value token from the parser and validates that it's one of the expected tokens

public long
mapNext()

Implements abstract org.apache.avro.io.Decoder.mapNext.

Processes the next block of map entries and returns the count of them.

protected JsonToken

Returns:

The next union branch token
nextUnionValue
()

Advance to the next token that might contain union branching information; This effectively discards the virtual JSON tokens inserted by the parser for END_OBJECT, START_ARRAY, etc. that are not actually present in the underlying data stream and stops after reading the first token that represents actual data.

protected JsonToken

Returns:

The next data token
nextValue
()

Advance to the next actual value token; This effectively discards the virtual JSON tokens inserted by the parser for START_OBJECT, END_OBJECT, START_ARRAY, etc. that are not actually present in the underlying data stream and stops after reading the first token that represents actual data

public long
readArrayStart()

Implements abstract org.apache.avro.io.Decoder.readArrayStart.

Reads and returns the size of the first block of an array.

public boolean
readBoolean()

Implements abstract org.apache.avro.io.Decoder.readBoolean.

Reads a boolean value written by Encoder#writeBoolean.

public ByteBuffer
readBytes(ByteBuffer old)

Implements abstract org.apache.avro.io.Decoder.readBytes.

Reads a byte-string written by Encoder#writeBytes.

public double
readDouble()

Implements abstract org.apache.avro.io.Decoder.readDouble.

Reads a double written by Encoder#writeDouble.

public int
readEnum()

Implements abstract org.apache.avro.io.Decoder.readEnum.

Reads an enumeration.

public void
readFixed(byte[]
The buffer to store the contents being read.
bytes
,
int
The position where the data needs to be written.
start
,
int
The size of the binary object.
length
)

Implements abstract org.apache.avro.io.Decoder.readFixed.

Reads fixed sized binary object.

public float
readFloat()

Implements abstract org.apache.avro.io.Decoder.readFloat.

Reads a float written by Encoder#writeFloat.

public int
readIndex()

Implements abstract org.apache.avro.io.Decoder.readIndex.

Reads the tag of a union written by Encoder#writeIndex.

public int
readInt()

Implements abstract org.apache.avro.io.Decoder.readInt.

Reads an integer written by Encoder#writeInt.

public long
readLong()

Implements abstract org.apache.avro.io.Decoder.readLong.

Reads a long written by Encoder#writeLong.

public long
readMapStart()

Implements abstract org.apache.avro.io.Decoder.readMapStart.

Reads and returns the size of the next block of map-entries.

public void
readNull()

Implements abstract org.apache.avro.io.Decoder.readNull.

"Reads" a null value.

public Utf8
readString(Utf8 old)

Implements abstract org.apache.avro.io.Decoder.readString.

Reads a char-string written by Encoder#writeString.

public String
readString()

Implements abstract org.apache.avro.io.Decoder.readString.

Reads a char-string written by Encoder#writeString.

public long
skipArray()

Implements abstract org.apache.avro.io.Decoder.skipArray.

Used for quickly skipping through an array.

public void
skipBytes()

Implements abstract org.apache.avro.io.Decoder.skipBytes.

Discards a byte-string written by Encoder#writeBytes.

public void
skipFixed(int
The size of the binary object to be skipped.
length
)

Implements abstract org.apache.avro.io.Decoder.skipFixed.

Discards fixed sized binary object.

public long
skipMap()

Implements abstract org.apache.avro.io.Decoder.skipMap.

Support for quickly skipping through a map similar to skipArray.

public void
skipString()

Implements abstract org.apache.avro.io.Decoder.skipString.

Discards a char-string written by Encoder#writeString.

Inherited from org.apache.avro.io.Decoder:
readFixed

Field Detail

_parserback to summary
protected final AvroParserImpl _parser

Constructor Detail

DecoderOverAvroParserback to summary
public DecoderOverAvroParser(AvroParserImpl parser)

Method Detail

arrayNextback to summary
public long arrayNext() throws IOException

Implements abstract org.apache.avro.io.Decoder.arrayNext.

Doc from org.apache.avro.io.Decoder.arrayNext.

Processes the next block of an array and returns the number of items in the block and let's the caller read those items.

Annotations
@Override
consumeTokenback to summary
protected JsonToken consumeToken(JsonToken... expectedTokens) throws IOException

Reads in the next value token from the parser and validates that it's one of the expected tokens

Parameters
expectedTokens:JsonToken[]

List of token types that is expected

Returns:JsonToken

The token that was consumed from the parser

Exceptions
IOException:
If there is an error while reading the next token
IllegalArgumentException:
If the next token is not one of the expectedTokens
mapNextback to summary
public long mapNext() throws IOException

Implements abstract org.apache.avro.io.Decoder.mapNext.

Doc from org.apache.avro.io.Decoder.mapNext.

Processes the next block of map entries and returns the count of them. Similar to arrayNext. See readMapStart for details.

Annotations
@Override
nextUnionValueback to summary
protected JsonToken nextUnionValue() throws IOException

Advance to the next token that might contain union branching information; This effectively discards the virtual JSON tokens inserted by the parser for END_OBJECT, START_ARRAY, etc. that are not actually present in the underlying data stream and stops after reading the first token that represents actual data. START_OBJECT is not skipped because union information is only available at the start of an object, and has been discarded by the parser by the time we reach the next actual value.

Returns:JsonToken

The next union branch token

Exceptions
IOException:
If there is an error while reading the next token
nextValueback to summary
protected JsonToken nextValue() throws IOException

Advance to the next actual value token; This effectively discards the virtual JSON tokens inserted by the parser for START_OBJECT, END_OBJECT, START_ARRAY, etc. that are not actually present in the underlying data stream and stops after reading the first token that represents actual data

Returns:JsonToken

The next data token

Exceptions
IOException:
If there is an error while reading the next token
readArrayStartback to summary
public long readArrayStart() throws IOException

Implements abstract org.apache.avro.io.Decoder.readArrayStart.

Doc from org.apache.avro.io.Decoder.readArrayStart.

Reads and returns the size of the first block of an array. If this method returns non-zero, then the caller should read the indicated number of items, and then call arrayNext to find out the number of items in the next block. The typical pattern for consuming an array looks like:

  for(long i = in.readArrayStart(); i != 0; i = in.arrayNext()) {
    for (long j = 0; j < i; j++) {
      read next element of the array;
    }
  }
Annotations
@Override
readBooleanback to summary
public boolean readBoolean() throws IOException

Implements abstract org.apache.avro.io.Decoder.readBoolean.

Doc from org.apache.avro.io.Decoder.readBoolean.

Reads a boolean value written by Encoder#writeBoolean.

Annotations
@Override
readBytesback to summary
public ByteBuffer readBytes(ByteBuffer old) throws IOException

Implements abstract org.apache.avro.io.Decoder.readBytes.

Doc from org.apache.avro.io.Decoder.readBytes.

Reads a byte-string written by Encoder#writeBytes. if old is not null and has sufficient capacity to take in the bytes being read, the bytes are returned in old.

Annotations
@Override
readDoubleback to summary
public double readDouble() throws IOException

Implements abstract org.apache.avro.io.Decoder.readDouble.

Doc from org.apache.avro.io.Decoder.readDouble.

Reads a double written by Encoder#writeDouble.

Annotations
@Override
readEnumback to summary
public int readEnum() throws IOException

Implements abstract org.apache.avro.io.Decoder.readEnum.

Doc from org.apache.avro.io.Decoder.readEnum.

Reads an enumeration.

Returns:int

The enumeration's value.

Annotations
@Override
readFixedback to summary
public void readFixed(byte[] bytes, int start, int length) throws IOException

Implements abstract org.apache.avro.io.Decoder.readFixed.

Doc from org.apache.avro.io.Decoder.readFixed.

Reads fixed sized binary object.

Parameters
bytes:byte[]

The buffer to store the contents being read.

start:int

The position where the data needs to be written.

length:int

The size of the binary object.

Annotations
@Override
readFloatback to summary
public float readFloat() throws IOException

Implements abstract org.apache.avro.io.Decoder.readFloat.

Doc from org.apache.avro.io.Decoder.readFloat.

Reads a float written by Encoder#writeFloat.

Annotations
@Override
readIndexback to summary
public int readIndex() throws IOException

Implements abstract org.apache.avro.io.Decoder.readIndex.

Doc from org.apache.avro.io.Decoder.readIndex.

Reads the tag of a union written by Encoder#writeIndex.

Annotations
@Override
readIntback to summary
public int readInt() throws IOException

Implements abstract org.apache.avro.io.Decoder.readInt.

Doc from org.apache.avro.io.Decoder.readInt.

Reads an integer written by Encoder#writeInt.

Annotations
@Override
readLongback to summary
public long readLong() throws IOException

Implements abstract org.apache.avro.io.Decoder.readLong.

Doc from org.apache.avro.io.Decoder.readLong.

Reads a long written by Encoder#writeLong.

Annotations
@Override
readMapStartback to summary
public long readMapStart() throws IOException

Implements abstract org.apache.avro.io.Decoder.readMapStart.

Doc from org.apache.avro.io.Decoder.readMapStart.

Reads and returns the size of the next block of map-entries. Similar to readArrayStart. As an example, let's say you want to read a map of records, the record consisting of an Long field and a Boolean field. Your code would look something like this:

Map m = new HashMap();
Record reuse = new Record();
for (long i = in.readMapStart(); i != 0; i = in.readMapNext()) {
  for (long j = 0; j < i; j++) {
    String key = in.readString();
    reuse.intField = in.readInt();
    reuse.boolField = in.readBoolean();
    m.put(key, reuse);
  }
}
Annotations
@Override
readNullback to summary
public void readNull() throws IOException

Implements abstract org.apache.avro.io.Decoder.readNull.

Doc from org.apache.avro.io.Decoder.readNull.

"Reads" a null value. (Doesn't actually read anything, but advances the state of the parser if the implementation is stateful.)

Annotations
@Override
readStringback to summary
public Utf8 readString(Utf8 old) throws IOException

Implements abstract org.apache.avro.io.Decoder.readString.

Doc from org.apache.avro.io.Decoder.readString.

Reads a char-string written by Encoder#writeString.

Annotations
@Override
readStringback to summary
public String readString() throws IOException

Implements abstract org.apache.avro.io.Decoder.readString.

Doc from org.apache.avro.io.Decoder.readString.

Reads a char-string written by Encoder#writeString.

Annotations
@Override
skipArrayback to summary
public long skipArray() throws IOException

Implements abstract org.apache.avro.io.Decoder.skipArray.

Doc from org.apache.avro.io.Decoder.skipArray.

Used for quickly skipping through an array. Note you can either skip the entire array, or read the entire array (with readArrayStart), but you can't mix the two on the same array. This method will skip through as many items as it can, all of them if possible. It will return zero if there are no more items to skip through, or an item count if it needs the client's help in skipping. The typical usage pattern is:

  for(long i = in.skipArray(); i != 0; i = i.skipArray()) {
    for (long j = 0; j < i; j++) {
      read and discard the next element of the array;
    }
  }
Note that this method can automatically skip through items if a byte-count is found in the underlying data, or if a schema has been provided to the implementation, but otherwise the client will have to skip through items itself.
Annotations
@Override
skipBytesback to summary
public void skipBytes() throws IOException

Implements abstract org.apache.avro.io.Decoder.skipBytes.

Doc from org.apache.avro.io.Decoder.skipBytes.

Discards a byte-string written by Encoder#writeBytes.

Annotations
@Override
skipFixedback to summary
public void skipFixed(int length) throws IOException

Implements abstract org.apache.avro.io.Decoder.skipFixed.

Doc from org.apache.avro.io.Decoder.skipFixed.

Discards fixed sized binary object.

Parameters
length:int

The size of the binary object to be skipped.

Annotations
@Override
skipMapback to summary
public long skipMap() throws IOException

Implements abstract org.apache.avro.io.Decoder.skipMap.

Doc from org.apache.avro.io.Decoder.skipMap.

Support for quickly skipping through a map similar to skipArray. As an example, let's say you want to skip a map of records, the record consisting of an Long field and a Boolean field. Your code would look something like this:

for (long i = in.skipMap(); i != 0; i = in.skipMap()) {
  for (long j = 0; j < i; j++) {
    in.skipString(); // Discard key
    in.readInt(); // Discard int-field of value
    in.readBoolean(); // Discard boolean-field of value
  }
}
Annotations
@Override
skipStringback to summary
public void skipString() throws IOException

Implements abstract org.apache.avro.io.Decoder.skipString.

Doc from org.apache.avro.io.Decoder.skipString.

Discards a char-string written by Encoder#writeString.

Annotations
@Override