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
ConstructorsConstructorDescriptionRawMessageDecoder(GenericData model, Schema schema) Creates a newRawMessageDecoderthat uses the givendata modelto construct datum instances described by theschema.RawMessageDecoder(GenericData model, Schema writeSchema, Schema readSchema) Creates a newRawMessageDecoderthat uses the givendata modelto 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 newRawMessageDecoderthat uses the givendata modelto construct datum instances described by theschema.The
schemais used as both the expected schema (read schema) and for the schema of payloads that are decoded (written schema).- Parameters:
model- thedata modelfor datum instancesschema- theSchemaused to construct datum instances and to decode buffers.
-
RawMessageDecoder
Creates a newRawMessageDecoderthat uses the givendata modelto construct datum instances described by thereadSchema.The
readSchemais used for the expected schema and thewriteSchemais the schema used to decode buffers. ThewriteSchemamust be the schema that was used to encode all buffers decoded by this class.- Parameters:
model- thedata modelfor datum instanceswriteSchema- theSchemaused to decode buffersreadSchema- theSchemaused to construct datum instances
-
-
Method Details
-
decode
Description copied from interface:MessageDecoderDeserialize 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
-