spark scala练习
spark scala练习准备一个文件上传至hdfshello wordhello javahello pythonhello c++启动spark-shellspark-shell获取到要计算的文件val file = spark.read.textFile("test.txt")统计该文件的行数file.count()获取第一行的内容file.first()获取到特定的内容val lines
·
spark scala练习
准备一个文件上传至hdfs
hello word
hello java
hello python
hello c++
启动spark-shell
spark-shell
获取到要计算的文件
val file = spark.read.textFile("test.txt")
统计该文件的行数
file.count()
获取第一行的内容
file.first()
获取到特定的内容
val lines = file.filter(line => line.contains("hello"))
获取指定词出现的次数
file.filter(line => line.contains("hello")).count()
更多推荐
已为社区贡献1条内容
所有评论(0)