gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 16:26:11 25 4
gpt4 key购买 nike

我对在 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);

上面写着:

error: method setMapperClass in class JobConf cannot be applied to given types; conf.setMapperClass(GetArticlesMapper.class); ^ required: Class found: Class reason: actual argument Class cannot be converted to Class by method invocation conversion 1 error

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

最佳答案

您可能正在混合使用“旧 API”和“新 API”。基本上,旧 API(JobConf 是其中的一部分)位于 org.apache.hadoop.mapred 下,而新 API(使用 Job 和 Configuration)位于 org.apache.hadoop 下.mapreduce。您的映射可能正在实现 org.apache.hadoop.mapreduce.Mapper

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

关于java - Hadoop:类 JobConf 中的方法 setMapperClass 不能应用于给定类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26111225/

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