R1 record = new R1();
record.attribute = "test";
AvroValue<R1> avroValue = new AvroValue<R1>(record);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
AvroDatumConverterFactory factory =
new AvroDatumConverterFactory(job.getConfiguration());
AvroDatumConverter<Text, ?> keyConverter = factory.create(Text.class);
@SuppressWarnings("unchecked")
AvroDatumConverter<AvroValue<R1>, R1> valueConverter =
factory.create((Class<AvroValue<R1>>) avroValue.getClass());
AvroKeyValueRecordWriter<Text, AvroValue<R1>> writer =
new AvroKeyValueRecordWriter<Text, AvroValue<R1>>(
keyConverter, valueConverter, new ReflectData(),
CodecFactory.nullCodec(), outputStream);