Interface DatumWriter<D>

All Known Implementing Classes:
GenericDatumWriter, Json.ObjectWriter, ProtobufDatumWriter, ReflectDatumWriter, SpecificDatumWriter, ThriftDatumWriter

public interface DatumWriter<D>
Write data of a schema.

Implemented for different in-memory data representations.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    setSchema(Schema schema)
    Set the schema.
    default byte[]
    toByteArray(D datum)
    Convenience method to Write a datum to a byte array.
    void
    write(D datum, Encoder out)
    Write a datum.
  • Method Details

    • setSchema

      void setSchema(Schema schema)
      Set the schema.
    • write

      void write(D datum, Encoder out) throws IOException
      Write a datum. Traverse the schema, depth first, writing each leaf value in the schema from the datum to the output.
      Throws:
      IOException
    • toByteArray

      default byte[] toByteArray(D datum) throws IOException
      Convenience method to Write a datum to a byte array. Traverse the schema, depth first, writing each leaf value in the schema from the datum to the byte array.
      Parameters:
      datum - The datum to serialize
      Returns:
      The serialized datum stored in an array of bytes
      Throws:
      IOException