January 2019
Beginner to intermediate
154 pages
4h 31m
English
You can use subtract() transformation to remove the content of one RDD using another RDD. Let's create two RDDs: The first one has numbers from 1 to 10 and the second one has elements from 6 to 10. If we use subtract(), we get a new RDD with numbers 1 to 5:
#PythonfirstRDD = spark.sparkContext.parallelize(range(1,11))secordRDD = spark.sparkContext.parallelize(range(6,11))firstRDD.subtract(secordRDD).collect()
The following code performs the same operation in Scala:
//scalaval firstRDD = spark.sparkContext.parallelize(1 to 10)val secordRDD = spark.sparkContext.parallelize(6 to 10)firstRDD.subtract(secordRDD).collect()
In the previous example, we have two RDDs: firstRDD contains elements from 1 to 10 and secondRDD contains elements ...
Read now
Unlock full access