Skip to content

Commit

Permalink
add sparkBatchBasics/countByKey1.scala
Browse files Browse the repository at this point in the history
  • Loading branch information
yennan.liu committed Jul 22, 2021
1 parent 08172fd commit d5efe22
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions spark/src/main/scala/com/yen/sparkBatchBasics/countByKey1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.yen.sparkBatchBasics

import org.apache.spark.SparkContext

// https://www.youtube.com/watch?v=eaKHArSYwcA&list=PLmOn9nNkQxJF-qlCCDx9WsdAe6x5hhH77&index=50

object countByKey1 extends App {

val sc = new SparkContext("local[*]", "countByKey1")

val rdd1 = sc.parallelize(List((1,3),(3,2),(1,5),(6,7)))

println(rdd1.countByKey()) // Map(1 -> 2, 3 -> 1, 6 -> 1)
}

0 comments on commit d5efe22

Please sign in to comment.