Class RawMessageEncoder<D>

java.lang.Object
org.apache.avro.message.RawMessageEncoder<D>
All Implemented Interfaces:
MessageEncoder<D>

public class RawMessageEncoder<D> extends Object implements MessageEncoder<D>
A MessageEncoder that encodes only a datum's bytes, without additional information (such as a schema fingerprint).

This class is thread-safe.

  • Constructor Details

    • RawMessageEncoder

      public RawMessageEncoder(GenericData model, Schema schema)
      Creates a new RawMessageEncoder that uses the given data model to deconstruct datum instances described by the schema.

      Buffers returned by encode(D) are copied and will not be modified by future calls to encode.

      Parameters:
      model - the data model for datum instances
      schema - the Schema for datum instances
    • RawMessageEncoder

      public RawMessageEncoder(GenericData model, Schema schema, boolean shouldCopy)
      Creates a new RawMessageEncoder that uses the given data model to deconstruct datum instances described by the schema.

      If shouldCopy is true, then buffers returned by encode(D) are copied and will not be modified by future calls to encode.

      If shouldCopy is false, then buffers returned by encode wrap a thread-local buffer that can be reused by future calls to encode, but may not be. Callers should only set shouldCopy to false if the buffer will be copied before the current thread's next call to encode.

      Parameters:
      model - the data model for datum instances
      schema - the Schema for datum instances
      shouldCopy - whether to copy buffers before returning encoded results
  • Method Details