首页  

spark-shell 简单使用     所属分类 spark 浏览量 136
spark-3.1.1-bin-hadoop3.2

./spark-shell 

val file = sc.textFile("/path/info.txt")
file.count()
file.first()

file.filter(line => line.contains("spark")).count()
file.filter(line => line.contains("java")).count()

file.filter(line => line.contains("hello")).count()


val wordcount = file.flatMap(line => line.split(" ")).map(word => (word,1)).reduceByKey(_+_)
wordcount.count()

wordcount.collect()
Array[(String, Int)] = Array((hello,2), (java,1), (spark,1))





info.txt hello spark hello java

上一篇     下一篇
常用存储选型指南

Linux hostname

Mybatis通用Mapper tk.mybatis 使用

drools StatelessKieSession 并发执行 空指针

中概互联 恒生互联网 恒生科技 指数简介及比较

指数估值方法