我正在尝试在 spark 作业中读取 lzo
文件。
我的 spark 版本是 1.6.0
(spark-core_2.10-1.6.0-cdh5.7.1)。
这是我的java代码:
JavaSparkContext sc = new JavaSparkContext(new SparkConf().setAppName("ReadLzo"));
JavaPairRDD <NullWritable, Text> lines = sc.newAPIHadoopFile(args[0],LzoTextInputFormat.class,NullWritable.class,Text.class,new Configuration());
但是我得到一个编译时异常:
The method newAPIHadoopFile(String, Class, Class, Class, Configuration) in the type JavaSparkContext is not applicable for the arguments (String, Class, Class, Class, Configuration)
那么在 Java 中使用 JavaSparkContext.newAPIHadoopFile()
的正确方法是什么?
最佳答案
没有保证,但是 LzoTextInputFormat
扩展了 TextInputFormat
,其 Key 是 LongWritable
,value 是 Text
。
确保您的导入语句也是正确的类型。特别是对于 Text
关于java - 如何在 Java 中使用 Spark 的 .newAPIHadoopFile(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39272530/