首页  

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

./spark-shell 
Spark context Web UI available at http://192.168.102.255:4040
启动另一个 spark-shell
WARN Utils: Service 'SparkUI' could not bind on port 4040. Attempting port 4041.
Spark context Web UI available at http://192.168.102.255:4041


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 并发执行 空指针

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

指数估值方法