public RecordWriter<KEY, VALUE> getRecordWriter(final TaskAttemptContext context)
throws IOException, InterruptedException {
Configuration conf = context.getConfiguration();
// we don't currently allow datasets as the format between map and reduce stages, otherwise we'll have to
// pass in the stage here instead of hardcoding reducer.
MapReduceContextProvider contextProvider = new MapReduceContextProvider(context, MapReduceMetrics.TaskType.Reducer);
BasicMapReduceContext mrContext = contextProvider.get();
mrContext.getMetricsCollectionService().startAndWait();
@SuppressWarnings("unchecked")
BatchWritable<KEY, VALUE> dataset = (BatchWritable<KEY, VALUE>) mrContext.getDataSet(getOutputDataSet(conf));
// the record writer now owns the context and will close it