@Override
  public void write(AvroKey<T> record, NullWritable ignore) throws IOException {
    mAvroFileWriter.append(record.datum());
  }
@Test
  void write() throws IOException {
    Schema writerSchema = Schema.create(Schema.Type.INT);
    GenericData dataModel = new ReflectData();
    CodecFactory compressionCodec = CodecFactory.nullCodec();
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    TaskAttemptContext context = mock(TaskAttemptContext.class);

    // Write an avro container file with two records: 1 and 2.
    AvroKeyRecordWriter<Integer> recordWriter = new AvroKeyRecordWriter<>(writerSchema, dataModel, compressionCodec,
        outputStream);
    recordWriter.write(new AvroKey<>(1), NullWritable.get());
    recordWriter.write(new AvroKey<>(2), NullWritable.get());
    recordWriter.close(context);

    // Verify that the file was written as expected.
    InputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
    Schema readerSchema = Schema.create(Schema.Type.INT);
    DatumReader<Integer> datumReader = new SpecificDatumReader<>(readerSchema);
    DataFileStream<Integer> dataFileReader = new DataFileStream<>(inputStream, datumReader);

    assertTrue(dataFileReader.hasNext()); // Record 1.
    assertEquals(1, dataFileReader.next().intValue());
    assertTrue(dataFileReader.hasNext()); // Record 2.
    assertEquals(2, dataFileReader.next().intValue());
    assertFalse(dataFileReader.hasNext()); // No more records.

    dataFileReader.close();

    verify(context, never()).getConfiguration();
  }