Chinaunix首页 | 论坛 | 博客
  • 博客访问: 532404
  • 博文数量: 129
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1888
  • 用 户 组: 普通用户
  • 注册时间: 2013-06-20 11:09
文章分类

全部博文(129)

文章存档

2016年(1)

2015年(5)

2014年(64)

2013年(59)

我的朋友

分类: HADOOP

2014-07-16 16:14:12

目前为止知道MapReduce有三种路径输入方式。
1、第一种是通过一下方式输入:

  1. FileInputFormat.addInputPath(job, new Path(args[0]));
  2. FileInputFormat.addInputPath(job, new Path(args[1]));
  3. FileInputFormat.addInputPath(job, new Path(args[2]));
  4. FileInputFormat.addInputPath(job, new Path(args[3]));

这种方式可以接收多个路径下的文件输入,但是这些文件都是通过一个Map进行处理

2、第二种是通过以下方式输入(第二个路径参数是通过,分割的多个路径):
  1. FileInputFormat.addInputPaths(job, args[0] + "," + args[1] + "," + args[2]);

这种方式跟第一种相似,看源码会发现,该方式是先将路径通过,分割成String[] paths数组形式,然后再循环调用第一种方式,而且他也是通过一个Map进行处理

3、第三种是通过以下方式输入:
  1. MultipleInputs.addInputPath(job, new Path(args[0]), TextInputFormat.class,EmpMapper.class);
  2. MultipleInputs.addInputPath(job, new Path(args[1]), TextInputFormat.class,EmpMapper.class);
  3. MultipleInputs.addInputPath(job, new Path(args[2]), TextInputFormat.class,TestMapper.class);

这种方式是针对不同的输入文件,他们的格式可能不同,然后针对他们的格式编写相应的Map分别进行处理,这种方式更灵活些。
这三种方式中提到的路径既可以是目录也可以使文件。

参考:
  
   http://blog.csdn.net/july_2/article/details/8211577



阅读(2693) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~