Package org.apache.avro.message
Class RawMessageDecoder<D>
java.lang.Object
org.apache.avro.message.MessageDecoder.BaseDecoder<D>
org.apache.avro.message.RawMessageDecoder<D>
- All Implemented Interfaces:
MessageDecoder<D>
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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.avro.message.MessageDecoder
MessageDecoder.BaseDecoder<D>
-
Constructor Summary
ConstructorDescriptionRawMessageDecoder
(GenericData model, Schema schema) Creates a newRawMessageDecoder
that uses the givendata model
to construct datum instances described by theschema
.RawMessageDecoder
(GenericData model, Schema writeSchema, Schema readSchema) Creates a newRawMessageDecoder
that uses the givendata model
to construct datum instances described by thereadSchema
. -
Method Summary
Modifier and TypeMethodDescriptiondecode
(InputStream stream, D reuse) Deserialize a single datum from an InputStream.
-
Constructor Details
-
RawMessageDecoder
Creates a newRawMessageDecoder
that uses the givendata model
to construct datum instances described by theschema
.The
schema
is used as both the expected schema (read schema) and for the schema of payloads that are decoded (written schema).- Parameters:
model
- thedata model
for datum instancesschema
- theSchema
used to construct datum instances and to decode buffers.
-
RawMessageDecoder
Creates a newRawMessageDecoder
that uses the givendata model
to construct datum instances described by thereadSchema
.The
readSchema
is used for the expected schema and thewriteSchema
is the schema used to decode buffers. ThewriteSchema
must be the schema that was used to encode all buffers decoded by this class.- Parameters:
model
- thedata model
for datum instanceswriteSchema
- theSchema
used to decode buffersreadSchema
- theSchema
used to construct datum instances
-
-
Method Details
-
decode
Description copied from interface:MessageDecoder
Deserialize a single datum from an InputStream.- Parameters:
stream
- stream to read fromreuse
- a datum instance to reuse, avoiding instantiation if possible- Returns:
- a datum read from the stream
-