WordCount

Descrição

WordCount
Nilesh Patel
Notas por Nilesh Patel, atualizado more than 1 year ago
Nilesh Patel
Criado por Nilesh Patel mais de 6 anos atrás
4
0

Resumo de Recurso

Página 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)

Semelhante

Filter and Map
Nilesh Patel
Joins
Nilesh Patel
Setup spark scala in windows
Nilesh Patel
Orações Subordinadas Adverbiais
criismoreir
Física - Sobre Ondas
Helen Manzur
Guia de Estudos do ENEM 2014
Alessandra S.
Pré Modernismo e Modernismo
Alyne Mascareli
Teaching with GoConqr Tools
miminoma
Patologia Geral - Hipertensão Arterial (Geral)
BrienneC
Mapa Mental - Exame de Certificação CTFL-AT
Larissa Trindade