Java Spark数据集映射行';无法解析方法映射(<;lambda expression>;)';
通过尝试映射到数据集中的每一行,尝试从数据集中创建RDD。获取Java Spark数据集映射行';无法解析方法映射(<;lambda expression>;)';,java,apache-spark,apache-spark-sql,parquet,apache-spark-dataset,Java,Apache Spark,Apache Spark Sql,Parquet,Apache Spark Dataset,通过尝试映射到数据集中的每一行,尝试从数据集中创建RDD。获取无法解决df1.map(r->)中映射上的错误: Dataset<Object> df1 = session.read().parquet(tableName).as(Encoders.bean(Object.class)); JavaRDD<List<Tuple3<Long, Integer, Double>>> tempDatas1 = df1.map(r -> new Ma
无法解决df1.map(r->
)中映射上的错误:
Dataset<Object> df1 = session.read().parquet(tableName).as(Encoders.bean(Object.class));
JavaRDD<List<Tuple3<Long, Integer, Double>>> tempDatas1 = df1.map(r -> new MapFunction<Object, List<Tuple3<Long, Integer, Double>>>(){
//@Override
public List<Tuple3<Long, Integer, Double>> call(Object row) throws Exception
{
// Get the sample property, remove leading and ending spaces and split it by comma
// to get each sample individually
List<Tuple2<String, Integer>> samples = zipWithIndex((row.getSamples().trim().split(",")));
// Gets the unique identifier for that s.
Long snp = row.getPos();
// Calculates the hamming distance.
return samples.stream().map(t -> {
String alleles = t._1();
Integer patient = t._2();
List<String> values = Arrays.asList(alleles.split("\\|"));
Double firstAllele = Double.parseDouble(values.get(0));
Double secondAllele = Double.parseDouble(values.get(1));
// Returns the initial s id, p id and the distance in form of Tuple.
return new Tuple3<>(snp, patient, firstAllele + secondAllele);
}).collect(Collectors.toList());
}
});
Dataset df1=session.read().parquet(tableName).as(Encoders.bean(Object.class));
JavaRDD tempDatas1=df1.map(r->newMapFunction(){
//@凌驾
公共列表调用(对象行)引发异常
{
//获取sample属性,删除前导空格和结尾空格,并用逗号将其拆分
//单独获取每个样本
List samples=zipWithIndex((row.getSamples().trim().split(“,”));
//获取该s的唯一标识符。
Long snp=row.getPos();
//计算汉明距离。
返回samples.stream().map(t->{
字符串等位基因=t._1();
整数患者=t._2();
列表值=array.asList(allegenes.split(“\\\\”);
双第一等位基因=Double.parseDouble(value.get(0));
Double SecondAllege=Double.parseDouble(values.get(1));
//以元组的形式返回初始s id、p id和距离。
返回新的Tuple3(snp,患者,第一等位基因+第二等位基因);
}).collect(Collectors.toList());
}
});
任何帮助都将不胜感激。map
使用了一个编码器。您没有提供编码器。@user9613318您有任何关于如何操作的提示吗?请查看字数示例-