Spark:JavaRDD<Tuple2>到 JavaPairRDD<>

2022-01-14 00:00:00 apache-spark mapreduce java

我有一个 JavaRDD<Tuple2<String, String>>,需要将其转换为 JavaPairRDD<String, String>.目前我通过简单地编写只返回输入元组的映射函数来做到这一点.但是不知道有没有更好的办法?

I have a JavaRDD<Tuple2<String, String>> and need to transform it to JavaPairRDD<String, String>. Currently I am doing it by simply writing map function that just returns the input tuple as is. But I wonder if there is a better way?

推荐答案

JavaPairRDD.fromJavaRDD(rdd) 是解决方案之一

JavaPairRDD.fromJavaRDD(rdd) is one of solutions

相关文章