我正在使用工作流运行我的 MR 作业:0.5"。我的用例是为输出创建基于键的目录结构。这是我的配置文件:-
`
<configuration>
<!-- These are important. -->
<property>
<name>mapred.mapper.new-api</name>
<value>true</value>
</property>
<property>
<name>mapred.reducer.new-api</name>
<value>true</value>
</property>
<property>
<name>mapred.job.queue.name</name>
<value>${queue.name}
</value>
</property>
<property>
<name>mapreduce.map.class</name>
<value>com.a.b.c.Amapper</value>
</property>
<property>
<name>mapreduce.reduce.class</name>
<value>com.a.b.c.Areducer</value>
</property>
<property>
<name>mapred.output.key.class</name>
<value>org.apache.hadoop.io.Text</value>
</property>
<property>
<name>mapred.output.value.class</name>
<value>org.apache.hadoop.io.Text</value>
</property>
<property>
<name>mapreduce.outputformat.class</name>
<value>org.apache.hadoop.mapreduce.lib.output.MultipleOutputs
</value>
</property>
<property>
<name>mapred.input.dir</name>
<value>${inputDir}</value>
</property>
<property>
<name>mapred.output.dir</name>
<value>${outputDir}</value>
</property>
</configuration>`
在 reducer 中,我想使用此代码创建格式化的目录结构-
`public class Areducer extends Reducer<Text, Text, Text, Text> {
private Text aggregatorRecord = new Text();
private MultipleOutputs<Text, Text> out;
public void setup(Context context) {
out = new MultipleOutputs<Text, Text>(context);
}
public void reduce(Text aggregatorRecordKey,
Iterable<Text> values, Context context)
throws IOException, InterruptedException {
/**
some business logic to do aggregation to set aggregatorRecord.
*/
String plist = "Surname|Forename";
Text t = new Text(plist);
out.write(aggregatorRecordKey, aggregatorRecord, generateFileName(t));
}
protected void cleanup(Context context) throws IOException,
InterruptedException {
out.close();
}
private String generateFileName(Text k) {
String[] kStr = k.toString().split("\\|");
String sName = kStr[0];
String fName = kStr[1];
// example for k = Smith|John
// output written to /user/hadoop/path/to/output/Smith/John-r-00000
// (etc)
return sName + "/" + fName;
}
`
oozie 工作流程给出了这个例外
java.lang.NoSuchMethodException: org.apache.hadoop.mapreduce.lib.output.MultipleOutputs.<\init>()
有人可以建议使用 MultipleOutputs 使用 oozie 工作流创建目录结构的正确方法吗?