MapReduce三种路径输入

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

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

这种方式可以接收多个路径下的文件输入,但是这些文件都是通过一个Map进行处理
2、第二种是通过以下方式输入(第二个路径参数是通过,分割的多个路径):

FileInputFormat.addInputPaths(job, args[0] + "," + args[1] + "," + args[2]);

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

MultipleInputs.addInputPath(job, new Path(args[0]), TextInputFormat.class,Mapper1.class);
MultipleInputs.addInputPath(job, new Path(args[1]), TextInputFormat.class,Mapper2.class);
MultipleInputs.addInputPath(job, new Path(args[2]), TextInputFormat.class,Mapper3.class);

这种方式是针对不同的输入文件,他们的格式可能不同,然后针对他们的格式编写相应的Map分别进行处理,这种方式更灵活些。

来自:http://f.dataguru.cn/thread-235219-1-1.html

原文地址:https://www.cnblogs.com/sunxucool/p/3899037.html