zoukankan      html  css  js  c++  java
  • 多输入路径

    目前为止知道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分别进行处理,这种方式更灵活些。
    目前只用到了上述三种方式,欢迎大家补充。
  • 相关阅读:
    【Luogu】P1402 酒店之王 题解
    CSP/S 2019 游记
    【Luogu】P1306 斐波那契公约数 题解
    【Luogu】P1072 Hankson 的趣味题 题解
    字符串函数
    对数换底公式
    round(x,y)和format(x,y)
    约束和索引
    复合主键对外键的影响
    外键
  • 原文地址:https://www.cnblogs.com/baoendemao/p/3804719.html
Copyright © 2011-2022 走看看