-
多输入路径
目前为止知道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,EmpMapper.class);
-
MultipleInputs.addInputPath(job, new Path(args[1]), TextInputFormat.class,EmpMapper.class);
-
MultipleInputs.addInputPath(job, new Path(args[2]), TextInputFormat.class,TestMapper.class);
复制代码
这种方式是针对不同的输入文件,他们的格式可能不同,然后针对他们的格式编写相应的Map分别进行处理,这种方式更灵活些。
目前只用到了上述三种方式,欢迎大家补充。
-
相关阅读:
斗鱼扩展--localStorage备份与导出(九)
斗鱼扩展--管理移除房间(八)
斗鱼扩展--让你看到更多内容(七)
Ubuntu18.04 安装水星1300M无线网卡
Course1_Week1_ProgrammingHomeWork
找出3个数中不为-1的最小数
马拉车算法
偏差-方差分解
决策树如何防止过拟合
可视化数据集两个类别变量的关系
-
原文地址:https://www.cnblogs.com/baoendemao/p/3804719.html
Copyright © 2020-2023
润新知