Hadoop源码详解之FileOutputFormat 类

本文深入剖析Hadoop中FileOutputFormat类的功能与实现细节,重点介绍了如何为MapReduce作业设置输出目录,以及该类与FileSystems交互的方式,对比了其与文件输入路径的处理差异。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Hadoop 源码详解之FileOutputFormat

1. 类释义

A base class for OutputFormats that read from FileSystems.
一个类从FileSystems读取 用于OutputFormats 【实在翻译不好 _

2. 类源码
3. 方法详解
3.1 setOutputPath()

Set the Path of the output directory for the map-reduce job.
map-reducejob设置输出目录。

  public static void setOutputPath(Job job, Path outputDir) {
    try {
      outputDir = outputDir.getFileSystem(job.getConfiguration()).makeQualified(
          outputDir);
    } catch (IOException e) {
        // Throw the IOException as a RuntimeException to be compatible with MR1
        throw new RuntimeException(e);
    }
    job.getConfiguration().set(FileOutputFormat.OUTDIR, outputDir.toString());
  }

可以看到的是,这里的 setOutputPath()并没有使用一个文件列表组为输出目录。而文件输入路径则可以是一个文件列表。详见 FileInputFormat类

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

说文科技

看书人不妨赏个酒钱?

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值