Top Description Fields Constructors Methods
org.apache.avro.message

public Class RawMessageDecoder<D>

extends MessageDecoder.BaseDecoder<D>
Class Inheritance
Imports
org.apache.avro.AvroRuntimeException, .Schema, org.apache.avro.generic.GenericData, org.apache.avro.io.BinaryDecoder, .DatumReader, .DecoderFactory, java.io.IOException, .InputStream

A MessageDecoder that deserializes from raw datum bytes.

This class uses the schema passed to its constructor when decoding buffers. To decode buffers that have different schemas, use BinaryMessageEncoder and BinaryMessageDecoder.

This will not throw BadHeaderException because it expects no header, and will not throw MissingSchemaException because it always uses the read schema from its constructor.

This class is thread-safe.

Field Summary

Modifier and TypeField and Description
private static final ThreadLocal<BinaryDecoder>
private final DatumReader<D>

Constructor Summary

AccessConstructor and Description
public
RawMessageDecoder(GenericData
the data model for datum instances
model
,
Schema
the Schema used to construct datum instances and to decode buffers.
schema
)

Creates a new RawMessageDecoder that uses the given data model to construct datum instances described by the schema.

public
RawMessageDecoder(GenericData
the data model for datum instances
model
,
Schema
the Schema used to decode buffers
writeSchema
,
Schema
the Schema used to construct datum instances
readSchema
)

Creates a new RawMessageDecoder that uses the given data model to construct datum instances described by the readSchema.

Method Summary

Modifier and TypeMethod and Description
public D
decode(InputStream
stream to read from
stream
,
D
a datum instance to reuse, avoiding instantiation if possible
reuse
)

Implements org.apache.avro.message.MessageDecoder.decode.

Deserialize a single datum from an InputStream.
Inherited from org.apache.avro.message.MessageDecoder.BaseDecoder:
decodedecodedecodedecodedecode

Field Detail

DECODERback to summary
private static final ThreadLocal<BinaryDecoder> DECODER
readerback to summary
private final DatumReader<D> reader

Constructor Detail

RawMessageDecoderback to summary
public RawMessageDecoder(GenericData model, Schema schema)

Creates a new RawMessageDecoder that uses the given data model to construct datum instances described by the schema.

The schema is used as both the expected schema (read schema) and for the schema of payloads that are decoded (written schema).

Parameters
model:GenericData

the data model for datum instances

schema:Schema

the Schema used to construct datum instances and to decode buffers.

RawMessageDecoderback to summary
public RawMessageDecoder(GenericData model, Schema writeSchema, Schema readSchema)

Creates a new RawMessageDecoder that uses the given data model to construct datum instances described by the readSchema.

The readSchema is used for the expected schema and the writeSchema is the schema used to decode buffers. The writeSchema must be the schema that was used to encode all buffers decoded by this class.

Parameters
model:GenericData

the data model for datum instances

writeSchema:Schema

the Schema used to decode buffers

readSchema:Schema

the Schema used to construct datum instances

Method Detail

decodeback to summary
public D decode(InputStream stream, D reuse)

Implements org.apache.avro.message.MessageDecoder.decode.

Doc from org.apache.avro.message.MessageDecoder.decode.

Deserialize a single datum from an InputStream.

Parameters
stream:InputStream

stream to read from

reuse:D

a datum instance to reuse, avoiding instantiation if possible

Returns:D

a datum read from the stream

Annotations
@Override