Class BinaryMessageEncoder<D>

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

public class BinaryMessageEncoder<D> extends Object implements MessageEncoder<D>
A MessageEncoder that adds a header and 8-byte schema fingerprint to each datum encoded as binary.

This class is thread-safe.

  • Constructor Details

    • BinaryMessageEncoder

      public BinaryMessageEncoder(GenericData model, Schema schema)
      Creates a new BinaryMessageEncoder 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
    • BinaryMessageEncoder

      public BinaryMessageEncoder(GenericData model, Schema schema, boolean shouldCopy)
      Creates a new BinaryMessageEncoder 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