Index: src/java/org/apache/hcatalog/mapreduce/MultiOutputFormat.java =================================================================== --- src/java/org/apache/hcatalog/mapreduce/MultiOutputFormat.java (revision 1338888) +++ src/java/org/apache/hcatalog/mapreduce/MultiOutputFormat.java (working copy) @@ -156,6 +156,35 @@ } /** + * Get the JobContext with the related OutputFormat configuration populated given the alias + * and the actual JobContext + * @param alias the name given to the OutputFormat configuration + * @param context the JobContext + * @return a copy of the JobContext with the alias configuration populated + */ + public static JobContext getJobContext(String alias, JobContext context) { + String aliasConf = context.getConfiguration().get(getAliasConfName(alias)); + JobContext aliasContext = new JobContext(context.getConfiguration(), context.getJobID()); + addToConfig(aliasConf, aliasContext.getConfiguration()); + return aliasContext; + } + + /** + * Get the TaskAttemptContext with the related OutputFormat configuration populated given the alias + * and the actual TaskAttemptContext + * @param alias the name given to the OutputFormat configuration + * @param context the Mapper or Reducer Context + * @return a copy of the TaskAttemptContext with the alias configuration populated + */ + public static TaskAttemptContext getTaskAttemptContext(String alias, TaskAttemptContext context) { + String aliasConf = context.getConfiguration().get(getAliasConfName(alias)); + TaskAttemptContext aliasContext = new TaskAttemptContext(context.getConfiguration(), + context.getTaskAttemptID()); + addToConfig(aliasConf, aliasContext.getConfiguration()); + return aliasContext; + } + + /** * Write the output key and value using the OutputFormat defined by the * alias. * @@ -265,21 +294,6 @@ return builder.substring(0, builder.length() - COMMA_DELIM.length()); } - private static JobContext getJobContext(String alias, JobContext context) { - String aliasConf = context.getConfiguration().get(getAliasConfName(alias)); - JobContext aliasContext = new JobContext(context.getConfiguration(), context.getJobID()); - addToConfig(aliasConf, aliasContext.getConfiguration()); - return aliasContext; - } - - private static TaskAttemptContext getTaskContext(String alias, TaskAttemptContext context) { - String aliasConf = context.getConfiguration().get(getAliasConfName(alias)); - TaskAttemptContext aliasContext = new TaskAttemptContext(context.getConfiguration(), - context.getTaskAttemptID()); - addToConfig(aliasConf, aliasContext.getConfiguration()); - return aliasContext; - } - private static String getAliasConfName(String alias) { return MO_ALIAS + "." + alias + ".conf"; } @@ -408,7 +422,7 @@ baseRecordWriters = new LinkedHashMap(); String[] aliases = getOutputFormatAliases(context); for (String alias : aliases) { - TaskAttemptContext aliasContext = getTaskContext(alias, context); + TaskAttemptContext aliasContext = getTaskAttemptContext(alias, context); Configuration aliasConf = aliasContext.getConfiguration(); // Create output directory if not already created. String outDir = aliasConf.get("mapred.output.dir"); @@ -476,7 +490,7 @@ outputCommitters = new LinkedHashMap(); String[] aliases = getOutputFormatAliases(context); for (String alias : aliases) { - TaskAttemptContext aliasContext = getTaskContext(alias, context); + TaskAttemptContext aliasContext = getTaskAttemptContext(alias, context); OutputCommitter baseCommitter = getOutputFormatInstance(aliasContext) .getOutputCommitter(aliasContext); outputCommitters.put(alias,