public class RawMessageDecoder<D> extends MessageDecoder.BaseDecoder<D>
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.
MessageDecoder.BaseDecoder<D>| Constructor and Description |
|---|
RawMessageDecoder(GenericData model,
Schema schema)
Creates a new
RawMessageDecoder that uses the given
data model to construct datum instances described by the
schema. |
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. |
| Modifier and Type | Method and Description |
|---|---|
D |
decode(InputStream stream,
D reuse)
Deserialize a single datum from an InputStream.
|
public RawMessageDecoder(GenericData model, Schema schema)
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).
model - the data model for datum instancesschema - the Schema used to construct datum instances and to
decode buffers.public RawMessageDecoder(GenericData model, Schema writeSchema, Schema readSchema)
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.
model - the data model for datum instancesreadSchema - the Schema used to construct datum instanceswriteSchema - the Schema used to decode bufferspublic D decode(InputStream stream, D reuse)
MessageDecoderstream - stream to read fromreuse - a datum instance to reuse, avoiding instantiation if possibleCopyright © 2009–2023 The Apache Software Foundation. All rights reserved.