January 2019
Beginner to intermediate
154 pages
4h 31m
English
Any operation that shuffles the data accepts an additional parameter, that is, degrees of parallelism. This allows users to provide the number of partitions for the produced RDD. The following example shows how you can change the number of partitions of the new RDD by passing an additional parameter:
//Scalaval baseRDD = spark.sparkContext.parallelize(Array(("US",20),("IND", 30),("UK",10)), 3)println(baseRDD.getNumPartitions)Output:3
The following code changes the number of partitions of the new RDD:
//Scalaval groupedRDD = baseRDD.groupByKey(2)println(groupedRDD.getNumPartitions)Output:2
The baseRDD has 3 partitions. We have passed an additional parameter to groupByKey which will tell Spark to produce groupedRDD with 2 partitions. ...
Read now
Unlock full access