思路
这个程序我可是花了3天才写起来的,主要是学习嘛,很多API不知道,一边查一边学喽。
首先读取文件夹里面的所有文件,将每个文件的内容按行拆分,然后再按单词拆分,组成(文件名,单词)对,然后再合并,最后得到我们的结果
输入
id1
hello world
hello hadoop
hadoop love
love cat
cat love rabbit
id2
hello spark
the spark app for you
I love you
you are a cat
id3
hello cat
hello rabbit
cat is doing spark
cat is the world
spark is good
id4
spark is better than hadoop
I love hadoop
you love spark
cat and rabbit love app
id5
hadoop is good in world
spark is very famous in world
I am rabbit
you are cat
代码
import org.apache.spark.{SparkContext, SparkConf}
i