You could pimp the RDD
class to attach a .flatten
method (in order to follow the List
api):
object SparkHelper {
implicit class SeqRDDExtensions[T: ClassTag](val rdd: RDD[Seq[T]]) {
def flatten: RDD[T] = rdd.flatMap(identity)
}
}
which can then simply be used as such:
rdd.flatten