elements in this RDD.
*/
def distinct(): RDD[T] = withScope {
distinct(partitions.length)...相同的元素的Value进行binary_function的reduce操作,因此,Key相同的多个元素的值被reduce为一个值,然后与原RDD中的Key组成一个新的KV对。}...,最后再同过map把去重后的元素挑出来。
A4 测试代码
import org.apache.spark....是初设定的partition数
val rdd = sc.parallelize(List(1, 2, 3, 3, 3, 3, 8, 8, 4, 9), 3)
//因为distinct实现用...reduceByKey故其可以重设定partition数,这里设定4
rdd.distinct(4).foreach(println)
//这里执行时,每次结果不同,分区在4以内,每个分区处理的元素也不定