我使用的是Cassandra 2.2.8,JDK 8,spark-cassandra-connector-java_2.10,spark-cassandra-connector_2.11-2.0.0-M3,cassandra-driver-core-3.1.0和以下的Cassandra Spark Connector Example JavaDemo。这个演示必须修复,才能用新的2.1 Connetcor API编译。我已经修复了一些东西,但下面的这个让我很为难:在此行发生编译错误:
JavaPairRDD<Integer, BigDecimal> allSalesRDD = joinedRDD.flatMap(new PairFlatMapFunction<Tuple2<Integer, Tuple2<Sale, Product>>, Integer, BigDecimal>() {
@Override
public Iterable<Tuple2<Integer, BigDecimal>> call(Tuple2<Integer, Tuple2<Sale, Product>> input) throws Exception {
错误:
The method
flatMap(FlatMapFunction<Tuple2<Integer,Tuple2<SparkJavaDemo.Sale,SparkJavaDemo.Product>>,U>) in the type
AbstractJavaRDDLike<Tuple2<Integer,Tuple2<SparkJavaDemo.Sale,SparkJavaDemo.Product>>,JavaPairRDD<Integer,Tuple2<SparkJavaDemo.
Sale,SparkJavaDemo.Product>>> is not applicable for the arguments (new
PairFlatMapFunction<Tuple2<Integer,Tuple2<SparkJavaDemo.Sale,SparkJavaDemo.Product>>,Integer,BigDecimal>(){})
谢谢
1条答案
按热度按时间uttx8gqw1#
您可以使用
flatMapToPair
代替flatMap
,如下所示。我已经在https://gist.github.com/baghelamit/f2963d9e37acc55474559104f5f16cf1上创建了更新代码的要点