一、OutputFormat

OutputFormat描述的是MapReduce的输出格式,它主要的任务是:

1.验证job输出格式的有效性,如:检查输出的目录是否存在。

2.通过实现RecordWriter,将输出的结果写到文件系统的文件中。

OutputFormat的主要是由三个抽象方法组成,下面根据源代码介绍每个方法的功能,源代码详解如下:

 public abstract class OutputFormat<K, V> {

   /**
* Get the {@link RecordWriter} for the given task.
* 得到给定任务的K-V对,即RecordWriter。
* @param context the information about the current task.
* @return a {@link RecordWriter} to write the output for the job.
* @throws IOException
*/
public abstract RecordWriter<K, V> getRecordWriter(TaskAttemptContext context)
throws IOException, InterruptedException; /**
* Check for validity of the output-specification for the job.
* 为job检查输出格式的有效性。
* <p>This is to validate the output specification for the job when it is
* a job is submitted. Typically checks that it does not already exist,
* throwing an exception when it already exists, so that output is not
* overwritten.</p>
* 这里,当job被提交时验证输出格式。实际上检查输出目录是否已经存在,当存在时抛出exception。
* 以至于原来的输出不会被覆盖。
* @param context information about the job
* @throws IOException when output should not be attempted
*/
public abstract void checkOutputSpecs(JobContext context) throws IOException, InterruptedException; /**
* Get the output committer for this output format. This is responsible
* for ensuring the output is committed correctly.
* 获得一个OutPutCommitter对象。这是用来确保输出被正确的提交。
* @param context the task context
* @return an output committer
* @throws IOException
* @throws InterruptedException
*/
public abstract OutputCommitter getOutputCommitter(TaskAttemptContext context)
throws IOException, InterruptedException;
}

Hadoop中OutputFormat解析的更多相关文章

  1. Hadoop 中疑问解析

    Hadoop 中疑问解析 FAQ问题剖析 一.HDFS 文件备份与数据安全性分析1 HDFS 原理分析1.1 Hdfs master/slave模型 hdfs采用的是master/slave模型,一个 ...

  2. hadoop中OutputFormat 接口的设计与实现

    OutputFormat 主要用于描述输出数据的格式,它能够将用户提供的 key/value 对写入特定格式的文件中. 本文将介绍 Hadoop 如何设计 OutputFormat 接口 , 以及一些 ...

  3. Hadoop中Partition解析

    1.解析Partition Map的结果,会通过partition分发到Reducer上,Reducer做完Reduce操作后,通过OutputFormat,进行输出,下面我们就来分析参与这个过程的类 ...

  4. Hadoop中常用的InputFormat、OutputFormat(转)

    Hadoop中的Map Reduce框架依赖InputFormat提供数据,依赖OutputFormat输出数据,每一个Map Reduce程序都离不开它们.Hadoop提供了一系列InputForm ...

  5. Hadoop中Yarnrunner里面submit Job以及AM生成 至Job处理过程源码解析

    参考 http://blog.csdn.net/caodaoxi/article/details/12970993 Hadoop中Yarnrunner里面submit Job以及AM生成 至Job处理 ...

  6. OutputFormat中OutputCommitter解析

    在hadoop中,由于一个Task可能由多个节点同时运行,当每个节点完成Task时,一个Task可能会出现多个结果,为了避免这种情况的出现,使用了OutPutCommitter.所以OutPutCom ...

  7. 用shell获得hadoop中mapreduce任务运行结果的状态

    在近期的工作中,我需要用脚本来运行mapreduce,并且要判断运行的结果,根据结果来做下一步的动作. 开始我想到shell中获得上一条命令运行结果的方法,即判断"$?"的值 if ...

  8. hadoop中实现java网络爬虫

    这一篇网络爬虫的实现就要联系上大数据了.在前两篇java实现网络爬虫和heritrix实现网络爬虫的基础上,这一次是要完整的做一次数据的收集.数据上传.数据分析.数据结果读取.数据可视化. 需要用到 ...

  9. hadoop中InputFormat 接口的设计与实现

    InputFormat 主要用于描述输入数据的格式, 它提供以下两个功能.❑数据切分:按照某个策略将输入数据切分成若干个 split, 以便确定 Map Task 个数以及对应的 split.❑为 M ...

随机推荐

  1. POJ3468 A Simple Problem With Integers 树状数组 区间更新区间询问

    今天学了很多关于树状数组的技巧.一个是利用树状数组可以简单的实现段更新,点询问(二维的段更新点询问也可以),每次修改只需要修改2个角或者4个角就可以了,另外一个技巧就是这题,原本用线段树做,现在可以用 ...

  2. POJ 1745

    #include <iostream> #define MAXN 10005 using namespace std; int _m[MAXN]; ]; int main() { //fr ...

  3. [STL]算法的泛化过程

    “选择了错误的算法,便注定了失败的命运”.最近对这句话感触颇深,经常因为一开始思路错误,修改半天,到头来却都是无用功,所以学好算法势在必行. 算法的泛化过程 如何设计一个算法,使他适用于任何(大多数) ...

  4. Android ListView点击失效

    item中存在 ImageButton 等可以点击的组件,这会抢先获得ListView的焦点. 从而导致item点击失效

  5. cojs 简单的最近公共祖先 解题报告

    我曾经自己想过每考试一次就从考试题中找找idea来出题 这次又找到了一个,先不管原来的考试题是什么 考试题中其中的一部分就是今天的这道题目啦 当时考场上自己比较傻,没有注意到有用的性质,套用了之前黑白 ...

  6. GDB笔记

    GDB是在Linux命令行下对C/C++的程序进行调试常用的一个命令,现将平时记录在本子上的笔记整理如下: 一.断点 断点类型有breakpoints, watchpoints, catchpoint ...

  7. 转ATL对象类型

    http://hi.baidu.com/rural_child/item/d91ce5d8fba9c8e73cc2cbf9 1.Objects a.Simple Object:用于实现业务逻辑,无用户 ...

  8. 排序 归并排序&逆序对

    void MergeArray(int cry[],int temp[],int begin,int middle,int end) { int i=begin; int j=middle+1; in ...

  9. Linux批量杀进程

    ps -ef |grep 进程名|grep -v grep |awk '{print $2}' |xargs kill -9

  10. mysql 查看警告

    显示警告(打开): warnings 查看警告(查看内容): show warnings; 记录运行日志: tee  _logsfile source sql_filenotee