2016-12-09 68 views

回答

2

採取JavaPairRDD<K, V>

JavaPairRDD<K, V> rdd = ...; 

定義分區:

Partitioner partitioner = ...; 

如果需要的話可以選擇定義Comparator<K>

Comparator<K> comparator = ...; 

Apply方法:

JavaPairRDD<K, V> repartitioned = 
    rdd.repartitionAndSortWithinPartitions(partitioner); 

JavaPairRDD<K, V> repartitioned = 
    rdd.repartitionAndSortWithinPartitions(partitioner, comparator);