WordCount

Beschreibung

WordCount
Nilesh Patel
Notiz von Nilesh Patel, aktualisiert more than 1 year ago
Nilesh Patel
Erstellt von Nilesh Patel vor mehr als 6 Jahre
4
0

Zusammenfassung der Ressource

Seite 1

Word Count:   Example 1 (RDD) val txtfile=sc.textFile("C:/Users/Redirection/pateln7/Downloads/SPARK/wordcount.txt") val txtflatmap= txtfile.flatMap(x=>x.split(" ")) txtflatmap.first val txtmap=txtflatmap.map(x=>(x,1)) txtmap.first val output=txtmap.reduceByKey(_+_) output.foreach(println)   Single line : val output = txtfile.flatMap(x=>x.split(" ")).map(x=>(x,1)).reduceByKey(_+_) output.foreach(println)     Example 2  (RDD) val txtfile=sc.textFile("C:/Users/Redirection/pateln7/Downloads/SPARK/wordcount.txt") val txtflatmap= txtfile.flatMap(x=>x.split(" ")) txtflatmap.first val txtmap=txtflatmap.map(x=>(x,1)) txtmap.first val output = txtmap.reduceByKey((x,txtmap)=>(x+txtmap)).foreach(println)   Example 3 (for Array[(string ,Int) ] type data  val str = "Hell saying hello is good, keep say hello"  val x =str.split(" ").map(x=> (x, 1))  val q = sc.parallelize(x)  q.reduceByKey(_+_).foreach(println)

Zusammenfassung anzeigen Zusammenfassung ausblenden

ähnlicher Inhalt

Filter and Map
Nilesh Patel
Joins
Nilesh Patel
Setup spark scala in windows
Nilesh Patel
Altenpflege Prüfungsfragen II
anna.grillborzer0656
Unsere Erde - Sonnensystem, Klima, Erdschichten etc.
Laura Overhoff
M1, Kurs 2: Einführung in die Forschungsmethoden - Unit 1 - Psychologie als eine empirische Wissenschaft: Warum brauchen wir Forschungsmethoden?
Chris Tho
WERB Univie (mögliche Fragen)
frau planlos
Lf. 2 Büroprozesse gestalten und Arbeitsvorgänge organisieren
Sarah Schneider
Vetie Viro 2012
Alena Gesing
Vetie Quiz Milch 2020
Katharina Enning