private byte[] encodeAvroGenericRecord(Schema schema, GenericRecord record) throws IOException {
    DatumWriter<IndexedRecord> msgDatumWriter = new GenericDatumWriter<>(schema);
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    Encoder encoder = EncoderFactory.get().binaryEncoder(os, null);
    msgDatumWriter.write(record, encoder);
    encoder.flush();
    return os.toByteArray();
  }
Avro SerDe that can be used to serialize or deserialize the avro {@link GenericRecord}.
samza-tools/src/main/java/org/apache/samza/tools/avro/AvroSerDeFactory.java