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 sysfor 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 ...
随机推荐
- linux中nginx重定向方法总结
linux中nginx 301重定向跳转方法总结 第一种情况:访问aaaaaaa站定向到bbbbbbbbbbb站 复制代码代码如下: server { server_naaaaaaame www.aa ...
- mongodb的数据库操作
1.创建数据库 语法 MongoDB 创建数据库的语法格式如下: use DATABASE_NAME 如果数据库不存在,则创建数据库,否则切换到指定数据库. 1.创建数据库 > show dbs ...
- linux基础——磁盘分区和yum安装
第一部分 1) 开启Linux系统前添加一块大小为15G的SCSI硬盘 2) 开启系统,右击桌面,打开终端 3) 为新加的硬盘分区,一个主分区大小为5G,剩余空间给扩展分区,在扩展分区上划分1 ...
- linux基础——文件的压缩解压缩以及vim编辑
一.将用户信息数据库文件和组信息数据库文件纵向合并为一个文件/1.txt(覆盖) cat /etc/{passwd,group} > /1.txt 查看:cat /1.txt 二. ...
- Linux c括号作用域【原创笔记】
大师指点后,所做的笔记,很感谢一起愿意研究技术的同事,以下不是本人原创,是他分析的成果 #include <stdio.h> #include <time.h> struct ...
- SSH Secure Shell 无法登录:server responded "algorithm negotiation failed”
SSH Secure Shell Client 连接 ubuntu系统报错 修改ssh的配置文件 /etc/ssh/sshd_config在配置文件中添加: Ciphers aes128-cbc,ae ...
- Docker Ubuntu容器安装ping(zz)
更新apt-get的软件包信息,然后再安装 sudo docker run ubuntu apt-get update sudo docker run ubuntu apt-get install i ...
- 云平台资源挂盘办法V1.2
一.优先使用mount 方式进行挂盘,记得使用sync参数,如果对方网络限制了445端口,我们被迫采用第二种办法. mount -t cifs -o sync,username='Administra ...
- 串行写队列的MYSQL大文本参数
public void AsyncWriteDataBase() { var spName = ""; while (true) { try { var jsonText = Re ...
- 只用120行Java代码写一个自己的区块链-4实现真正的p2p网络
在之前的文章中,我们模拟了节点网络通讯,很多朋友反馈说,他们想看真正的节点网络通讯而不是单节点的模拟.本章将满足你们.