
MapReduce
文章平均质量分 55
Lesley dude
信仰
展开
-
[MapReducer]求平均数
这是Udacity的课程 intro to hadoop and mapReduce里面Lesson4的练习 只说一点,求平均不能在combiner中进行 算法依然是计数,记录总和,最后输出 平均值 #Mapper #!/usr/bin/python import sys from datetime import datetime for line in sys.stdin: data原创 2015-07-27 19:03:41 · 697 阅读 · 0 评论 -
[MapReduce]Top N 任务的mapper
这是Udacity的课程 intro to hadoop and mapReduce里面Lesson4的练习 求总体的Top N。 首先在Mapper中求出局部的Top N,求Top N不能像word count那样来一句print一句,要把所有的line都读完,计数,排序,输入topN 然后再Reducer中求出全局的 Top N。 以下是Mapper 代码 #!/usr/bin/py原创 2015-07-27 18:55:27 · 1302 阅读 · 0 评论 -
[MapReduce]Filter Pattern
这是Udacity的课程 intro to hadoop and mapReduce里面Lesson4的练习 该练习完成了从大量的论坛post中,过滤出只有一句话的post。以下是题目具体描述以及python代码#!/usr/bin/python import sys import csv # To run this code on the actual data, please do原创 2015-07-27 18:49:49 · 894 阅读 · 0 评论 -
[MapReduce]倒排索引任务
这是Udacity的课程 intro to hadoop and mapReduce里面Lesson4的练习 其实这个任务与 word count类似,只不过这里Reducer输出索引,而word count的输出是 计数 #mapper import sys import csv import string def mapper(): reader = csv.reader原创 2015-07-27 18:59:34 · 1005 阅读 · 0 评论 -
[MapReduce]students on forums that communicate a lot between themselves
源自Udacity,Intro to hadoop这门课Final Project We might want to help students form study groups. But first we want to see if there are already students on forums that communicate a lot between原创 2015-07-28 18:01:16 · 420 阅读 · 0 评论 -
[MapReduce]Top 10 标签
源自Udacity,Intro to hadoop这门课Final Project 题目要求,从给定的论坛帖子数据中,找出被使用最多的10个tag。tag存在于question中(因为comment和answer也存在于数据表中,所有需要在mapper中过滤) 思路: mapper 从是question的记录中,提取tags,并输出 reducer 给每个tags计数,保存原创 2015-07-28 17:47:50 · 934 阅读 · 0 评论 -
[MapReduce] correlation between the length of a post and the length of answers
源自Udacity,Intro to hadoop这门课Final Project 题目说想知道 帖子的长度跟回答的长度有没有相关性 思路: Mapper 过滤出question和answer,输出id,type(question, answer), length Reducer 统计每一个id对应的 question的len 以及 answer的average len原创 2015-07-28 17:55:21 · 508 阅读 · 0 评论 -
[MapReduce]找出每个用户最喜欢po贴的时间(以小时为单位)
源自Udacity,Intro to hadoop这门课Final Project 题目要求,从论坛帖子的结构化数据中,找出每个用户po贴最多的时间。 比如,用户A在每天的8点,po最多的帖子,数量标记为x 那么reducer的输出就是 A x 思路: Mapper需要输出 author_id; Reducer则对每个用户做一个{hour : count}的统计原创 2015-07-28 17:44:51 · 635 阅读 · 0 评论 -
[日志分析]在nginx日志中,提取有效的request uri
最近在做公司的nginx log分析,其中一个需求是提取这个月每天被访问Top10的页面,及其访问量。 做这个需求,首先要清洗出有效的页面访问。我采用排除法,去掉 .js .css之类的访问。但最初,我并不能全面的了解要去掉带有哪些后缀的request。 经过清洗 -> 抽样 -> 清洗 -> 抽样 -> 清洗,最终需要过滤掉含有下列后缀的uri .js .css . gif原创 2015-08-01 10:24:54 · 2853 阅读 · 0 评论