MR hadoop streaming job的学习 combiner
代码已经拷贝到了公司电脑的:
/Users/baidu/Documents/Data/Work/Code/Self/hadoop_mr_streaming_jobs
首先是主控脚本 main.sh
调用的是 extract.py
然后发现写的不太好。其中有一个combiner,可以看这里:
https://blog.csdn.net/u010700335/article/details/72649186
streaming 脚本的时候,是以管道为基础的:
(5) Python脚本
1
2
3
|
import sys for line in sys.stdin: .......
|
#!/usr/bin/env python import sys # maps words to their counts
word2count = {} # input comes from STDIN (standard input)
for line in sys.stdin:
# remove leading and trailing whitespace
line = line.strip()
# split the line into words while removing any empty strings
words = filter(lambda word: word, line.split())
# increase counters
for word in words:
# write the results to STDOUT (standard output);
# what we output here will be the input for the
# Reduce step, i.e. the input for reducer.py
#
# tab-delimited; the trivial word count is
print '%s\t%s' % (word, )
#---------------------------------------------------------------------------------------------------------
#!/usr/bin/env python from operator import itemgetter
import sys # maps words to their counts
word2count = {} # input comes from STDIN
for line in sys.stdin:
# remove leading and trailing whitespace
line = line.strip() # parse the input we got from mapper.py
word, count = line.split()
# convert count (currently a string) to int
try:
count = int(count)
word2count[word] = word2count.get(word, ) + count
except ValueError:
# count was not a number, so silently
# ignore/discard this line
pass # sort the words lexigraphically;
#
# this step is NOT required, we just do it so that our
# final output will look more like the official Hadoop
# word count examples
sorted_word2count = sorted(word2count.items(), key=itemgetter()) # write the results to STDOUT (standard output)
for word, count in sorted_word2count:
print '%s\t%s'% (word, count)
MR hadoop streaming job的学习 combiner的更多相关文章
- hadoop学习;Streaming,aggregate;combiner
hadoop streaming同意我们使用不论什么可运行脚本来处理按行组织的数据流,数据取自UNIX的标准输入STDIN,并输出到STDOUT 我们能够用 linux命令管道查看文本有多少行,cat ...
- Hadoop Streaming框架学习(一)
Hadoop Streaming框架学习(一) Hadoop Streaming框架学习(一) 2013-08-19 12:32 by ATP_, 473 阅读, 3 评论, 收藏, 编辑 1.Had ...
- Hadoop Streaming框架学习2
Hadoop Streaming框架学习(二) 1.常用Streaming命令介绍 使用下面的命令运行Streaming MapReduce程序: 1: $HADOOP_HOME/bin/hadoop ...
- Hadoop Streaming框架学习(二)
1.常用Streaming命令介绍 使用下面的命令运行Streaming MapReduce程序: 1: $HADOOP_HOME/bin/hadoop/hadoop streaming args 其 ...
- Hadoop Streaming框架使用(一)
Streaming简介 link:http://www.cnblogs.com/luchen927/archive/2012/01/16/2323448.html Streaming框架允许任何程 ...
- hadoop streaming 编程
概况 Hadoop Streaming 是一个工具, 代替编写Java的实现类,而利用可执行程序来完成map-reduce过程.一个最简单的程序 $HADOOP_HOME/bin/hadoop jar ...
- Hadoop Streaming Command Details and Q&A
Hadoop Streaming Hadoopstreaming is a utility that comes with the Hadoop distribution. The utilityal ...
- hadoop streaming编程小demo(python版)
大数据团队搞数据质量评测.自动化质检和监控平台是用django,MR也是通过python实现的.(后来发现有orc压缩问题,python不知道怎么解决,正在改成java版本) 这里展示一个python ...
- Hadoop Streaming详解
一: Hadoop Streaming详解 1.Streaming的作用 Hadoop Streaming框架,最大的好处是,让任何语言编写的map, reduce程序能够在hadoop集群上运行:m ...
随机推荐
- urlparse获取url后面的参数
copyfrom: http://www.cnpythoner.com/post/263.html 如果给定你一个URL,比如: http://url/api?param=2¶m2=4 ...
- JMeter 定时器(Synchronizing Timer)之集合点应用
性能测试中我们经常提到一个概念就是“并发”,其实在实际真实的性能测试中是不存在真正的并发的.为了更真实的模拟对一个请求的并发测试场景,我们通常设置一个集合点,JMeter中提供了这样的一个功能设置. ...
- Spark优化之一:分布式下的map操作是闭包
例如对一个JavaPairRDD<String, String>做遍历操作,常见的,我们可以通过先通过collect()操作将它转化为Map对象再进行遍历,也可以使用Spark提供的map ...
- [ Linux 命令 ] awk
一.AWK简介 awk:报告生成器,是以行为单位进行处理,并格式化后显示 awk是一个强大的文本分析工具,相对于grep的查找,sed的编辑,awk在其对数据分析并生成报告时,显得尤为强大.简单来说a ...
- jquery请求格式和返回类型 汇总
常规请求基本格式 1 [WebMethod] 2 public string SayHello(string name) 3 { 4 return "Hello " + name; ...
- GUI界面------tkinter
import tkinter as tk class APP: def __init__(self,master): frame = tk.Frame(master) frame.pack(side ...
- ubuntu 16.04 qtcreator 闪退
当用QtCreator 进行代码自动补全时,比如编写ros代码,ROS_INFO时候就会出现闪退,后面按照 http://doc.qt.io/qtcreator/creator-clang-codem ...
- <context-param>与<init-param>的区别与作用(转自青春乐园)(
<context-param>的作用:web.xml的配置中<context-param>配置作用1. 启动一个WEB项目的时候,容器(如:Tomcat)会去读它的配置文件we ...
- rhel 6.5 yum源的配置
https://blog.csdn.net/error_0_0_/article/details/54962199
- AC日记——中山市选[2009]小明的游戏 bzoj 2464
2464 思路: 最短路: 代码: #include <cstdio> #include <cstring> #include <iostream> #includ ...