2017-08-30 7 views
1

私はカスタマイズできるコードを書き込もうとしていましたが、インプットはインプリメンテーションを使用して文字の長さに従って減速するパーティションはデフォルトのMapperとReducerがありますが、次のエラーが発生しています。私を助ける人には感謝します。Partitioner型のgetPartitionの名前の衝突は、MapReduce、Hadoopのmainクラスの型の消去と同じです。

int setNumRedTasks)

エラー:

名衝突:タイプ MyPartitionerの方法getPartition(オブジェクト、オブジェクト、INT)は 型パーティション分割のgetPartition(K2、V2、INT)と同様の消去を有するがありません上書きしないこと

コード:

package partition; 

import org.apache.hadoop.io.IntWritable; 
import org.apache.hadoop.io.Text; 
import org.apache.hadoop.mapred.JobConf; 
import org.apache.hadoop.mapred.Partitioner; 

public abstract class MyPartitioner implements Partitioner<Text, IntWritable>{ 

    @Override 
    public void configure(JobConf arg0) { 
     // TODO Auto-generated method stub 

    } 
    // @Override 
    public int getPartition(Object key, Object value, int setNumRedTasks) { 
     String s = key.toString(); 
     if(s.length()==1) 
     { 
      return 0; 
     } 

     if(s.length()==2) 
     { 
      return 1; 
     } 

     if(s.length()==3) 
     { 
      return 2; 
     } 
     else 
      return 3; 


    } 
} 

答えて

0

あなたgetPartitionメソッドのシグネチャが間違っている、それはする必要があります

public int getPartition(Text key, IntWritable value, int setNumRedTasks) { 
    ... Code goes here 
} 

このSO答える消去エラーが何を意味するのかを説明します。効果的Method has the same erasure as another method in type

、あなたの代わりに、一般的な種類のオブジェクトを使用するので、それがうまくできません使用するバージョンは同等です。

関連する問題