spark【例子】倒排索引(InvertedIndex)
来源:互联网 发布:中国gis软件 编辑:程序博客网 时间:2024/06/06 10:47
例子描述:
【倒排索引(InvertedIndex)】
这个例子是在一本讲Spark书中看到的,但是样例代码写的太Java化,没有函数式编程风格,于是问了些高手,教我写了份函数式的倒排索引。
这段代码,我在刚开始学的时候很难想到二次拆分数据,所以这个难点挺不错的。
原始数据
cx1|a,b,c,d,e,f
cx2|c,d,e,f
cx3|a,b,c,f
cx4|a,b,c,d,e,f
cx5|a,b,e,f
cx6|a,b,c,d
cx7|a,b,c,f
cx8|d,e,f
cx9|b,c,d,e,f
结果数据
d|cx1,cx2,cx4,cx6,cx8,cx9
e|cx1,cx2,cx4,cx5,cx8,cx9
a|cx1,cx3,cx4,cx5,cx6,cx7
b|cx1,cx3,cx4,cx5,cx6,cx7,cx9
f|cx1,cx2,cx3,cx4,cx5,cx7,cx8,cx9
c|cx1,cx2,cx3,cx4,cx6,cx7,cx9
代码片段:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 顶
- 0
0 0
- spark【例子】倒排索引(InvertedIndex)
- spark【例子】倒排索引(InvertedIndex)
- spark 倒排索引
- [spark]倒排索引
- spark:倒排索引
- Spark入门--倒排索引
- 倒排索引原理
- 倒排索引
- 倒排索引
- 倒排索引
- 索引 倒排
- 倒排索引
- 倒排索引
- hadoop 倒排索引
- 倒排索引技术
- 什么是倒排索引?
- 倒排索引求子串
- 倒排索引
- Discuz!开发之判断蜘蛛(机器人)访问函数checkrobot()介绍
- keepalive
- Kettle初步学习
- Kettle注意事项
- Kettle 参数、变量和全局变量(kettle.properties)使用
- spark【例子】倒排索引(InvertedIndex)
- 登高望远,今朝欲望决定未来高度
- Kettle 调用存储过程
- FreeMind:简单粗暴完成一份思维导图
- corosync + pacemaker+drbd 实现mysql高可用
- 大神
- Kettle 流查询,数据库查询和Merge Join的区别
- Spring 整合HibernateDaoSupport(业务Dao继承CommonDaoImpl)
- 求模运算符的应用(植树问题)