diff --git a/mapreduce/CHANGES.txt b/mapreduce/CHANGES.txt index 63707a324c0..aee8b0a8ced 100644 --- a/mapreduce/CHANGES.txt +++ b/mapreduce/CHANGES.txt @@ -212,6 +212,9 @@ Trunk (unreleased changes) JobInProgress.getCounters() aquire locks in a shorter time period. (Joydeep Sen Sarma via schen) + MAPREDUCE-2740. MultipleOutputs in new API creates needless + TaskAttemptContexts. (todd) + BUG FIXES MAPREDUCE-2603. Disable High-Ram emulation in system tests. diff --git a/mapreduce/src/java/org/apache/hadoop/mapreduce/lib/output/MultipleOutputs.java b/mapreduce/src/java/org/apache/hadoop/mapreduce/lib/output/MultipleOutputs.java index 31dd2818c05..0db94e0475d 100644 --- a/mapreduce/src/java/org/apache/hadoop/mapreduce/lib/output/MultipleOutputs.java +++ b/mapreduce/src/java/org/apache/hadoop/mapreduce/lib/output/MultipleOutputs.java @@ -132,6 +132,10 @@ public class MultipleOutputs { * Cache for the taskContexts */ private Map taskContexts = new HashMap(); + /** + * Cached TaskAttemptContext which uses the job's configured settings + */ + private TaskAttemptContext jobOutputFormatContext; /** * Checks if a named output name is valid token. @@ -382,11 +386,13 @@ public class MultipleOutputs { public void write(KEYOUT key, VALUEOUT value, String baseOutputPath) throws IOException, InterruptedException { checkBaseOutputPath(baseOutputPath); - TaskAttemptContext taskContext = - new TaskAttemptContextImpl(context.getConfiguration(), - context.getTaskAttemptID(), - new WrappedStatusReporter(context)); - getRecordWriter(taskContext, baseOutputPath).write(key, value); + if (jobOutputFormatContext == null) { + jobOutputFormatContext = + new TaskAttemptContextImpl(context.getConfiguration(), + context.getTaskAttemptID(), + new WrappedStatusReporter(context)); + } + getRecordWriter(jobOutputFormatContext, baseOutputPath).write(key, value); } // by being synchronized MultipleOutputTask can be use with a