0
我使用工作流运行我的MR工作:0.5" 我的用例创建输出基于密钥的目录结构 这是我的配置文件: - 。如何使用hadoop.mapreduce.lib.output.MultipleOutputs使用oozie工作流创建目录结构? 。
`
<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>`
在减速,我想创建格式的目录结构中使用此代码 -
`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。 < \初始化>()
有人建议可以使用MultipleOutputs使用Oozie的工作流创建目录结构,正确的做法?
非常感谢。 它的工作。 最初,我坚持定义 org.apache.hadoop.mapreduce.lib.output.MultipleOutputs ,但将其更改为org.apache.hadoop.mapreduce.lib.output。 TextOutputFormat,解决了我的问题。但我正在逐渐目录文件结构,这样的输出: - /outputDir /姓 /outputDir /姓氏/录名字-R-00000 /outputDir/_SUCCESS /outputDir /一部分-R-00000, 我想_SUCCESS在Forename-r-00000的'Surname'目录中(因为它需要标志来启动其他相关作业)。所以,如果不写java类,是不是可以得到它? –
user2449613
2014-10-27 06:54:18