-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add sparkBatchBasics/countByKey1.scala
- Loading branch information
yennan.liu
committed
Jul 22, 2021
1 parent
08172fd
commit d5efe22
Showing
1 changed file
with
14 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
spark/src/main/scala/com/yen/sparkBatchBasics/countByKey1.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |