AvroMultipleOutputs { @SuppressWarnings("rawtypes") public synchronized RecordWriter getRecordWriter( TaskAttemptContext taskContext, String baseFileName) throws IOException, InterruptedException { RecordWriter writer = recordWriters.get(baseFileName); if (writer == null) { taskContext.getConfiguration().set("avro.mo.config.namedOutput",baseFileName); try { writer = ((OutputFormat) ReflectionUtils.newInstance( taskContext.getOutputFormatClass(), taskContext.getConfiguration())) .getRecordWriter(taskContext); } catch (ClassNotFoundException e) { throw new IOException(e); } if (countersEnabled) { context.getCounter(COUNTERS_GROUP, baseFileName).setValue(0); writer = new RecordWriterWithCounter(writer, baseFileName, context); } recordWriters.put(baseFileName, writer); } return writer; } AvroMultipleOutputs(
      TaskInputOutputContext<?, ?, ?, ?> context); @SuppressWarnings("rawtypes") static void addNamedOutput(Job job, String namedOutput,
      Class<? extends OutputFormat> outputFormatClass,
      Schema keySchema); @SuppressWarnings("rawtypes") static void addNamedOutput(Job job, String namedOutput,
      Class<? extends OutputFormat> outputFormatClass,
      Schema keySchema, Schema valueSchema); static void setCountersEnabled(Job job, boolean enabled); static boolean getCountersEnabled(JobContext job); Set<String> getNamedOutputs(); void write(String namedOutput, Object key); void write(String namedOutput, Object key, Object value); @SuppressWarnings("unchecked") void write(String namedOutput, Object key, Object value,
      String baseOutputPath); void write(Object key, Object value, String baseOutputPath); @SuppressWarnings({ "unchecked", "deprecation" }) void write(Object key, Object value, Schema keySchema,
      Schema valSchema, String baseOutputPath); @SuppressWarnings("rawtypes") synchronized RecordWriter getRecordWriter(
      TaskAttemptContext taskContext, String baseFileName); @SuppressWarnings("deprecation") TaskAttemptContext getContext(String nameOutput); void close();  }
@Test public void testGetRecordWriter() throws Exception { String baseFileName = "baseFileName"; Configuration conf = new Configuration(); doReturn(conf).when(context).getConfiguration(); doReturn(MockOutputFormat.class).when(context).getOutputFormatClass(); AvroMultipleOutputs multipleOutputs = new AvroMultipleOutputs(context); RecordWriter<?, ?> recordWriter = multipleOutputs.getRecordWriter(context, baseFileName); assertNotNull(recordWriter); }