gpt4 book ai didi

java - Hadoop MultipleOutputs抛出 “cannot find symbol”

转载 作者:行者123 更新时间:2023-12-02 21:54:54 25 4
gpt4 key购买 nike

我正在使用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.*;
在代码的开头。

谁能告诉我为什么会出现这些错误?
我怎么解决这个问题?

最佳答案

Cannot find symbol错误通常与您在类路径中具有多个类相关联,当您知道已导入类库时,这些类会使编译器在编译时感到困惑。

以下是其他遇到类似问题的人:
cannot find symbol

关于java - Hadoop MultipleOutputs抛出 “cannot find symbol”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15854415/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com