code: public RecordWriter<K,SAMRecordWritable> getRecordWriter(
  			TaskAttemptContext ctx, Path out)
  		throws IOException
  	{
  		if (this.header == null)
  			throw new IOException(
  				"Can't create a RecordWriter without the SAM header");
  
  		final boolean writeHeader = ctx.getConfiguration().getBoolean(
  			WRITE_HEADER_PROPERTY, true);
  
  		switch (format) {
  			case BAM:
  				return new KeyIgnoringBAMRecordWriter<K>(
  					out, header, writeHeader, ctx);
  
  			case SAM:
  				return new KeyIgnoringSAMRecordWriter<K>(
  						out, header, writeHeader, ctx);
  
  			case CRAM:
  				return new KeyIgnoringCRAMRecordWriter<K>(
  						out, header, writeHeader, ctx);
  
  			default: assert false; return null;
  		}
  	}
docs: Allows wrappers to provide their own work file.