区别于scala的zip。
- spark的zip can only zip RDDs with same number of elements in eache partition
- Can't zip RDDs with unequal numbers of partitions
即:可迭代集合数量一致,分区数一致。
val rdd1: RDD[Int] = sc.makeRDD(List(1,2,3,4,5),2)
val rdd2: RDD[Int] = sc.makeRDD(List(5,6,7,8,9),2)
rdd1.zip(rdd2).collect().foreach(println)
(1,5)
(2,6)
(3,7)
(4,8)
(5,9)