Hadoop:JobConf 类中的方法 setMapperClass 不能应用于给定类型

use*_*238 0 java hadoop

我对在 Java 中使用 Hadoop 框架很陌生。我正在尝试为JobConf只有一个映射器的特定 map reduce 作业设置 。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
    }
}
Run Code Online (Sandbox Code Playgroud)

但是,当我编译 java 文件时,main 方法中的这一行会引发错误:

conf.setMapperClass(GetArticlesMapper.class);
Run Code Online (Sandbox Code Playgroud)

其中说:

错误:JobConf 类中的 setMapperClass 方法无法应用于给定类型;conf.setMapperClass(GetArticlesMapper.class); ^ 必需:找到类:类原因:实参类无法通过方法调用转换1错误转换为类

因此我的问题是,我需要在映射器类的实现中修复什么,以便 Java 编译并且我没有收到此错误?这个问题可能措辞不当且含糊不清,也许是因为我自己不熟悉这个主题。我将不胜感激任何意见,以帮助提高这个问题的质量。

xpa*_*492 5

您可能正在混合“旧 API”和“新 API”。基本上旧的 API(JobConf 是其中的一部分org.apache.hadoop.mapred)存在于org.apache.hadoop.mapreduce. 您的映射可能正在实施org.apache.hadoop.mapreduce.Mapper.

有关所有差异的更多详细信息,请访问:http : //hadoopbeforestarting.blogspot.de/2012/12/difference-between-hadoop-old-api-and.html