[英]Hadoop - @Override error for mappers and reducers
我一直在研究MapReduce程序,我遇到了障礙,需要一些幫助。 我有一個運行3個作業的程序(作業#2在for循環中運行5次)似乎我的一些mappers和reducer沒有正確定義。 在編譯時,我不斷得到“方法不會覆蓋或實現超類型中的方法”錯誤。
這是我的程序的基本結構:
Job 1:
FirstMapper
沒有減速機
Job 2:
第二個映射器
第一減速機
Job 3:
最終映射器
最終減速機
這是我如何定義我的映射器和縮減器:
public static class FirstMapper extends Mapper<Object, Text, LongWritable, Vertex> {
@Override
public void map(Object key, Text value, Context context) throws IOException, InterruptedException {}
public static class SecondMapper extends Mapper<LongWritable, Vertex, LongWritable, Vertex> {
@Override
public void map(long key, Vertex value, Context context) throws IOException, InterruptedException {}
public static class FirstReducer extends Reducer<LongWritable, Vertex, LongWritable, Vertex> {
@Override
public void reduce(Long key, Iterable<Vertex> values, Context context) throws IOException, InterruptedException {}
public static class FinalMapper extends Mapper<LongWritable, Vertex, LongWritable, LongWritable> {
@Override
public void map(Long key, Vertex value, Context context) throws IOException, InterruptedException {}
public static class FinalReducer extends Reducer<LongWritable, LongWritable, LongWritable, LongWritable> {
@Override
public void reduce(Long key, Iterable<LongWritable> values, Context context) throws IOException, InterruptedException {}
FirstMapper似乎沒問題,因為它不會導致錯誤,但是其他4個做了,我無法弄清楚為什么因為方法簽名看起來正確。 我最初認為可能是因為我的自定義Vertex類,但它實現了Writable,所以我不確定為什么這會導致問題。 任何和所有的幫助將不勝感激。 謝謝
您的密鑰需要實現WritableComparable
接口並匹配您在Mapper
和Reducer
簽名類中指定的類型。 例如,在第二個你有:
Mapper<LongWritable, Vertex, LongWritable, Vertex>
但是在map
方法中你使用了long
。 這需要匹配您在簽名中指定的類型,即LongWritable
。 所以第二張圖的參數需要如下所示:
map(LongWritable key, Vertex value, Context context)
所有最后四個類都有這個問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.