我非常擅长在Java中使用Hadoop框架。我正在尝试为仅具有映射器的特定地图缩减作业设置JobConf
(对于缩减器没有真正的中间值)。我的映射器类在这里:
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错误
,无法将类转换为Class
因此我的问题是,我需要在mapper类的实现中修复什么,以便Java编译并且我不会收到此错误?这个问题可能措辞不够,含糊不清,也许是因为我对这个问题不熟悉。我将不胜感激任何评论,以帮助提高这个问题的质量。
答案 0 :(得分:3)
您可能正在混合使用“旧API”和“新API”。基本上,旧的API(JobConf是其中的一部分)位于org.apache.hadoop.mapred
下,而新的API(使用作业和配置)则位于org.apache.hadoop.mapreduce
下。您的映射可能正在实施org.apache.hadoop.mapreduce.Mapper
。
有关所有差异的更多详细信息,请访问:http://hadoopbeforestarting.blogspot.de/2012/12/difference-between-hadoop-old-api-and.html。