Class RawMessageDecoder<D>

java.lang.Object
org.apache.avro.message.MessageDecoder.BaseDecoder<D>
org.apache.avro.message.RawMessageDecoder<D>
All Implemented Interfaces:
MessageDecoder<D>

public class RawMessageDecoder<D> extends MessageDecoder.BaseDecoder<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.

  • Constructor Details

    • RawMessageDecoder

      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 - the data model for datum instances
      schema - the Schema used to construct datum instances and to decode buffers.
    • RawMessageDecoder

      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 - the data model for datum instances
      writeSchema - the Schema used to decode buffers
      readSchema - the Schema used to construct datum instances
  • Method Details

    • decode

      public D decode(InputStream stream, D reuse)
      Description copied from interface: MessageDecoder
      Deserialize a single datum from an InputStream.
      Parameters:
      stream - stream to read from
      reuse - a datum instance to reuse, avoiding instantiation if possible
      Returns:
      a datum read from the stream