2016-07-30 8 views
0

mapreduce時代から私たちの既存のカスタム入力フォーマットを再利用するためにSparkを評価しようとすると、私はJavaジェネリックの問題に遭遇しました。Sparkカスタムハープ入力フォーマットjava genericsエラー

import com.google.protobuf.Message; 
import com.twitter.elephantbird.mapreduce.io.ProtobufWritable; 
public abstract class AbstractInputFormat<K extends Message, V> extends FileInputFormat<ProtobufWritable<K>, V> 

... 

import com.example.MyProto; // this extends Message 
public class MyInputFormat extends AbstractInputFormat<MyProto, Text> 

... 

SparkConf conf = new SparkConf().setAppName("Test"); 
SparkContext sc = new SparkContext(conf); 
JavaSparkContext jsc = JavaSparkContext.fromSparkContext(sc); 
JavaPairRDD myRdd = jsc.newAPIHadoopFile(logFile, MyInputFormat.class, ProtobufWritable.class, Text.class, 
        Job.getInstance().getConfiguration()); 

myRdd

Bound mismatch: The generic method newAPIHadoopFile(String, Class<F>, Class<K>, Class<V>, Configuration) of type JavaSparkContext is not applicable for the arguments (String, Class<MyInputFormat>, Class<ProtobufWritable>, Class<Text>, Configuration). The inferred type MyInputFormat is not a valid substitute for the bounded parameter <F extends InputFormat<K,V>> 

何が起こっているのかわからないで、次のようなエラーに上記リード。私は境界を満足させているように見えますか?私は問題を見つけることができませんか?

Thisは、呼び出されているスカラコードです。

答えて

0

次の変更は私

public class MyInputFormat<K extends Message> extends AbstractInputFormat<MyProto, Text> 

public abstract class AbstractInputFormat<K extends Message, V> extends FileInputFormat<ProtobufWritable<K>, V> 
のために働いていました
関連する問題