【发布时间】:2014-09-30 01:07:47
【问题描述】:
我对在 Java 中使用 Hadoop 框架非常陌生。我正在尝试为只有一个映射器的特定 map reduce 作业设置 JobConf(对于 reducer 没有真正的中间值)。我的映射器类在这里:
public static class GetArticlesMapper extends Mapper<LongWritable, WikipediaPage, Text, Text>
{
public static Set<String> peopleArticlesTitles = new HashSet<String>();
@Override
protected void setup(Mapper<LongWritable, WikipediaPage, Text, Text>.Context context)
throws IOException, InterruptedException {
// TODO: You should implement people articles load from
// DistributedCache here
super.setup(context);
}
@Override
public void map(LongWritable offset, WikipediaPage inputPage, Context context)
throws IOException, InterruptedException {
// TODO: You should implement getting article mapper here
}
}
但是,当我编译java文件时,main方法中的这一行会引发错误:
conf.setMapperClass(GetArticlesMapper.class);
上面写着:
错误:类 JobConf 中的方法 setMapperClass 不能应用于 给定类型; conf.setMapperClass(GetArticlesMapper.class); ^ 必需:类找到:类原因:实际参数 类不能通过方法调用转换为类1错误
因此我的问题是,我需要在映射器类的实现中修复什么,以便 Java 编译并且我没有收到此错误?这个问题可能措辞不佳且含糊不清,也许是因为我自己对这个主题不熟悉。我也会感谢任何 cmets 来帮助提高这个问题的质量。
【问题讨论】:
-
JobConf 是旧 API,您显示的代码是新 API。您可以使用其中任何一个继续前进。不要混合使用两者。您可以在这里找到使用新 API 的 wordcount 示例:unmeshasreeveni.blogspot.in/2014/04/…