本文共 891 字,大约阅读时间需要 2 分钟。
List(("a",2),("d",1),("b",8),("d",3)
package com.opensource.bigdata.spark.local.rdd.operation.dependency.narrow.n_03_pruneDependency.n_02_filterByRangeimport com.opensource.bigdata.spark.local.rdd.operation.base.BaseScalaSparkContextobject Run extends BaseScalaSparkContext{ def main(args: Array[String]): Unit = { val sc = pre() val rdd1 = sc.parallelize(List(("a",2),("d",1),("b",8),("d",3)),2) //ParallelCollectionRDD val rdd1Sort = rdd1.sortByKey() //ShuffleRDD val rdd2 =rdd1Sort.filterByRange("a","b") //MapParttionsRDD println("rdd \n" + rdd2.collect().mkString("\n")) sc.stop() }}
转载地址:http://sfkul.baihongyu.com/