倒排索引解题思路

应用背景:对网页,文档进行合理的存储。构建合理的索引


数据源:
"mapreduce is simple , this is test case" (来自1.html)
"hello mapreduce ,hello world, hello mapreduce of inversedIndex,the athor is daidai"(来自2.html)


期望结果:某个单词在某个文档中出现的次数
(mapreduce,1.html:1;2.html:2)
 (is,1.html:2;2.html:1)


map任务:统计某个单词在某个文档中出现的了一次,通过combine任务来统计某个单词在某个文档中出现的总次数
所以我们期望的map结果如下:、
(mapreduce:1.html,1)
(is:1.html,1)
(is:1.html,1)
(mapreduce:2.html,1)
(mapreduce:2.html,1)
(is:2.html,1)


通过combine程序我们完成词频统计部分,得到结果
(mapreduce,1.html:1)
(is,1.html:2)
(mapreduce,2.html:2)
(is,2.html:1)


通过洗牌后,得到结果、
(mapreduce,(1.html:1),(2.html:2))
(is,(1.html:2);(2.html:1))
reduce任务无需特别处理直接统计结果:
(mapreduce,1.html:1;2.html:2)
(is,1.html:2;2.html:1)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值