解读:MR多路径输入
对于在一个MR-Job中使用多路径作为输入文件,一般有三种方法:
1).多次调用,加载不同路径:
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; //输入路径in01 in02
String in01 = "hdfs://RS5-112:9000/cs01/path01";
String in02 = "hdfs://RS5-112:9000/cs02/path02"; //多次调用addInputPath()方法
FileInputFormat.addInputPath(job,new Path(in0));
FileInputFormat.addInputPath(job,new Path(in1));
2).一次调用,同时加载多路径(字符串用逗号隔开):
//这种方式的第二个参数只能是:将路径以逗号拼接的字符串
FileInputFormat.addInputPaths(job,
"hdfs://RS5-112:9000/cs01/path1,hdfs://RS5-112:9000/cs02/path2");
3).使用MultipleInputs类的方法
addInputPath(Job job, Path path,
Class<? extends InputFormat> inputFormatClass);
addInputPath(Job job, Path path,
Class<? extends InputFormat> inputFormatClass,
Class<? extends Mapper> mapperClass);
MultipleInputs类的强大之处在于不仅可以多次调用addInputPath()方法加载路径,而且可以根据路径的不同指定不同的输入格式,更有甚者还可以根据输入格式的不同指定不同的Mapper函数进行处理。详见 MR案例:倒排索引 && MultipleInputs 和 MR案例:CombineFileInputFormat
DEMO1:
MultipleInputs.addInputPath(job,
new Path("hdfs://RS5-112:9000/cs01/path01"),
TextInputFormat.class);
MultipleInputs.addInputPath(job,
new Path("hdfs://RS5-112:9000/cs02/path2"),
KeyValueInputFormat.class);
DEMO2:
MultipleInputs.addInputPath(job,
new Path("hdfs://RS5-112:9000/cs01/path01"),
TextInputFormat.class,
Mapper01.class);
MultipleInputs.addInputPath(job,
new Path("hdfs://RS5-112:9000/cs02/path2"),
KeyValueInputFormat.class,
Mapper02.class);
解读:MR多路径输入的更多相关文章
- MapReduce三种路径输入
目前为止知道MapReduce有三种路径输入方式.1.第一种是通过一下方式输入: FileInputFormat.addInputPath(job, new Path(args[0]));FileIn ...
- ArcGIS Server,rest路径输入要素json 格式描述
以下内容只测试了简单线, 在ArcGIS Server 的rest路径下可以对服务进行操作,如Query等,这些操作可以输入json 格式要素描述或运行得到即输出json格式要素描述. 如博客:htt ...
- ROS源码解读(二)--全局路径规划
博客转载自:https://blog.csdn.net/xmy306538517/article/details/79032324 ROS中,机器人全局路径规划默认使用的是navfn包 ,move_b ...
- ROS源码解读(一)--局部路径规划
博客转载自:https://blog.csdn.net/xmy306538517/article/details/78772066 ROS局部路径导航包括Trajectory Rollout 和 Dy ...
- MR案例:CombineFileInputFormat
CombineFileInputFormat是一个抽象类.Hadoop提供了两个实现类CombineTextInputFormat和CombineSequenceFileInputFormat. 此案 ...
- MR案例:倒排索引 && MultipleInputs
本案例采用 MultipleInputs类 实现多路径输入的倒排索引.解读:MR多路径输入 package test0820; import java.io.IOException; import j ...
- MR案例:定制InputFormat
数据输入格式 InputFormat类用于描述MR作业的输入规范,主要功能:输入规范检查(比如输入文件目录的检查).对数据文件进行输入切分和从输入分块中将数据记录逐一读取出来.并转化为Map的输入键值 ...
- MapReduce框架原理-InputFormat数据输入
InputFormat简介 InputFormat:管控MR程序文件输入到Mapper阶段,主要做两项操作:怎么去切片?怎么将切片数据转换成键值对数据. InputFormat是一个抽象类,没有实现怎 ...
- 【python】文件的输入和输出
1.os模块 2.os.path 模块 3.实例 1. os模块 对文件系统的访问大多通过python的os模块实现,其中os 模块负责大部分的文件系统操作,包括删除/重命名文件,遍历目录树,管理文件 ...
随机推荐
- 160518、java中使用百度地图(超级简单)
第一步:导入如下内容,红色的部分需要申请(个人通过手机号就可以申请) <script type="text/javascript" src="http://api. ...
- flask--简记
Jinjia变量过滤器: safe 渲染值时不转义 capitalize 把值的首字母转换成大写,其他字母转换成小写 lower 把值转换成小写形式 upper 把值转换成大写形式 title 把值中 ...
- myeclipse 代码提示(alt+/)
windows -->preference-->general-->keys找到 alt+/ 解除绑定 windows -->preference-->general-- ...
- python console
print(sys.stdout.encoding, locale.getpreferredencoding ()) windows console : chcp 65001; 在设置了这个环境变量时 ...
- Spring AOP和事务的相关陷阱
1.前言 2.嵌套方法拦截失效 2.1 问题场景 2.2 解决方案 2.3 原因分析 2.3.1 原理 2.3.2 源代码分析 3.Spring事务在多线程环境下失效 3.1 问题场景 3.2 解决方 ...
- Zipline Beginner Tutorial
Zipline Beginner Tutorial Basics Zipline is an open-source algorithmic trading simulator written in ...
- python基础-第五篇-5.4正则表达式
正则基础知识 正则表达式是通过调用re模块实现的 在python里,正则表达式处理对象为字符串,所以正则里方法和字符串的方法有很多相似的地方:re.findall和find,re.split和spli ...
- 最简单的win7、win8免费升级正版win10图文教程
https://www.microsoft.com/zh-cn/software-download/windows10 http://jingyan.baidu.com/article/19192ad ...
- confluence安装、破解+MariaDB驱动、汉化
下载所需文件:http://fansik.edusaas.com/confluence/安装包:atlassian-confluence-5.8.10-x64.bin 汉化包:Confluence-5 ...
- Python数据库连接池实例——PooledDB
不用连接池的MySQL连接方法 import MySQLdb conn= MySQLdb.connect(host='localhost',user='root',passwd='pwd',db='m ...