In dem Versuch, Spark zu bewerten, um unsere bestehenden benutzerdefinierten Eingabeformate aus der mapreduce-Ära wieder zu verwenden, bin ich auf ein Java-Generika-Problem gestoßen.Spark benutzerdefinierte Hadoop-Eingabe-Format Java-Generika Fehler
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());
Die oben führt zu folgendem Fehler bei 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>>
nicht sicher, was passiert ist. Es scheint mir, dass ich die Grenzen befriede? Ich kann das Problem nicht erkennen?
This ist der Scala-Code, der aufgerufen wird.