我正在使用 Hadoop 0.21.0。我想输出到两个不同的文件,所以我试图让 MultipleOutputs 工作。这是我的减少:
public static class Reduce extends MapReduceBase implements Reducer < Text, Text > {
private MultipleOutputs mos;
public void configure(JobConf conf) {
mos = new MultipleOutputs(conf);
}
public void reduce(Text key, Iterator < Text > values, OutputCollector < Text, Text > output, Reporter reporter) throws IOException {
mos.getCollector("A", reporter).collect(key, new Text("Hello"));
mos.getCollector("B", reporter).collect(key, new Text("Bye"));
mos.getCollector("C", reporter).collect(key, new Text("Chau"));
}
public void close() throws IOException {
mos.close();
}
}
但是当我尝试编译它时,我得到了这些错误:
Main.java:41: error: cannot find symbol
private MultipleOutputs mos;
^
symbol: class MultipleOutputs
location: class Reduce
Main.java:45: error: cannot find symbol
mos = new MultipleOutputs(conf);
^
symbol: class MultipleOutputs
location: class Reduce
虽然我已经添加了这个:import org.apache.hadoop.mapred.*
; 在代码的开头。
谁能告诉我为什么我会收到这些错误?我怎么解决这个问题?