January 2019
Beginner to intermediate
154 pages
4h 31m
English
The countByValue() action can be used to find out the occurrence of each element in the RDD. The following is the Scala code that returns a Map of key-value pair. In the output, Map, the key is the RDD element, and the value is the number of occurrences of that element in the RDD:
//Scalaspark.sparkContext.parallelize(Array("A","A","B","C")).countByValue()res0: scala.collection.Map[String,Long] = Map(A -> 2, B -> 1, C -> 1)
Read now
Unlock full access