RDD编程

一、词频统计

1.读文本文件生成RDD lines

 

2.将一行一行的文本分割成单词 words flatmap()

 

3.全部转换为小写 lower()

 

4.去掉长度小于3的单词 filter()

 

5.去掉停用词

 

6.转换成键值对 map()

7.统计词频 reduceByKey()

 

8.按字母顺序排序 sortBy(f)

 

9.按词频排序 sortByKey()

 

 

 

 

二、学生课程案例分析

1.总共有多少学生?map(), distinct(), count()

 

2.开设了多少门课程?

 

3.每个学生选修了多少门课?map(), countByKey()

 

4.每门课程有多少个学生选?map(), countByValue()

 

5.Tom选修了几门课?每门课多少分?filter(), map() RDD

 

6.Tom选修了几门课?每门课多少分?map(),lookup()  list

 

7.Tom的成绩按分数大小排序。filter(), map(), sortBy()

 

8.Tom的平均分。map(),lookup(),mean()

 

posted @ 2021-04-18 19:41  赖泽梵  阅读(45)  评论(0编辑  收藏  举报