我對於在Java中使用Hadoop框架非常新穎。我正在嘗試設置JobConf
用於只有映射器的特定映射縮減作業(Reducer沒有真正的中間值)。我的映射類是在這裏:Hadoop:類JobConf中的setMapperClass方法不能應用於給定的類型
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
因此我
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文件,此行的主要方法將引發錯誤問題是,我需要在我的映射器類的實現中修復以便Java編譯並且不會出現此錯誤?這個問題可能措辭不明確,可能是因爲我對這個問題不熟悉。我會很感激任何意見,以幫助提高這個問題的質量。
JobConf是舊的API,並且您顯示的代碼是新的API。您可以使用任何一個前進。不混合兩者。你可以在這裏找到使用新API的wordcount示例:http://www.unmeshasreeveni.blogspot.in/2014/04/hadoop-wordcount-example-in-detail.html – 2014-09-30 03:55:14