Hadoop中OutputFormat解析
一、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解析的更多相关文章
- Hadoop 中疑问解析
Hadoop 中疑问解析 FAQ问题剖析 一.HDFS 文件备份与数据安全性分析1 HDFS 原理分析1.1 Hdfs master/slave模型 hdfs采用的是master/slave模型,一个 ...
- hadoop中OutputFormat 接口的设计与实现
OutputFormat 主要用于描述输出数据的格式,它能够将用户提供的 key/value 对写入特定格式的文件中. 本文将介绍 Hadoop 如何设计 OutputFormat 接口 , 以及一些 ...
- Hadoop中Partition解析
1.解析Partition Map的结果,会通过partition分发到Reducer上,Reducer做完Reduce操作后,通过OutputFormat,进行输出,下面我们就来分析参与这个过程的类 ...
- Hadoop中常用的InputFormat、OutputFormat(转)
Hadoop中的Map Reduce框架依赖InputFormat提供数据,依赖OutputFormat输出数据,每一个Map Reduce程序都离不开它们.Hadoop提供了一系列InputForm ...
- Hadoop中Yarnrunner里面submit Job以及AM生成 至Job处理过程源码解析
参考 http://blog.csdn.net/caodaoxi/article/details/12970993 Hadoop中Yarnrunner里面submit Job以及AM生成 至Job处理 ...
- OutputFormat中OutputCommitter解析
在hadoop中,由于一个Task可能由多个节点同时运行,当每个节点完成Task时,一个Task可能会出现多个结果,为了避免这种情况的出现,使用了OutPutCommitter.所以OutPutCom ...
- 用shell获得hadoop中mapreduce任务运行结果的状态
在近期的工作中,我需要用脚本来运行mapreduce,并且要判断运行的结果,根据结果来做下一步的动作. 开始我想到shell中获得上一条命令运行结果的方法,即判断"$?"的值 if ...
- hadoop中实现java网络爬虫
这一篇网络爬虫的实现就要联系上大数据了.在前两篇java实现网络爬虫和heritrix实现网络爬虫的基础上,这一次是要完整的做一次数据的收集.数据上传.数据分析.数据结果读取.数据可视化. 需要用到 ...
- hadoop中InputFormat 接口的设计与实现
InputFormat 主要用于描述输入数据的格式, 它提供以下两个功能.❑数据切分:按照某个策略将输入数据切分成若干个 split, 以便确定 Map Task 个数以及对应的 split.❑为 M ...
随机推荐
- poj 3101 Astronomy
2个星球周期为a,b.则相差半周的长度为a*b/(2*abs(a-b)),对于n个只需求这n个 分数的最小公倍数即可! 公式: 分数的最小公倍数 = 分子的最小公倍数/分母的最大公约数 由于涉及到大数 ...
- Fragment 与 Activity 通信
先说说背景知识: (From:http://blog.csdn.net/t12x3456/article/details/8119607) 尽管fragment的实现是独立于activity的,可以被 ...
- Spring 3.0: Unable to locate Spring NamespaceHandler for XML schema namespace
被这个问题折磨着很久:参考: http://have23.iteye.com/blog/1340777 (cfx 与 spring 整合的时候出现的问题: org.springframework.be ...
- 李洪强iOS开发之OC[017]函数和方法的区别
// // main.m // 15 - 函数和对象的方法的区别 // // Created by vic fan on 16/7/12. // Copyright © 2016年 李洪强. ...
- Project Euler 88:Product-sum numbers 积和数
Product-sum numbers A natural number, N, that can be written as the sum and product of a given set o ...
- lintcode 中等题:Intersection of Two Linked Lists 两个链表的交叉
题目 两个链表的交叉 请写一个程序,找到两个单链表最开始的交叉节点. 样例 下列两个链表: A: a1 → a2 ↘ c1 → c2 → c3 ↗ B: b1 → b2 → b3 在节点 c1 开始交 ...
- Sina App Engine(SAE)入门教程(2)-Mysql使用
如果你还没有SAE的账号,请在http://sae.sina.com.cn 注册新用户.具体的注册流程请参见:Sina App Engine(SAE)入门教程(1)在常规的环境下,我们可以通过http ...
- 解决不安装VC运行库(VC2005,VC2008),程序运行出错的方法
因为VS2005以后程序采用了manifest的生成方式,所以发布的时候要和运行库一起发布.但是我们平时开发和发布的时候如果都要客户安装运行库,那就不太方便了.你可以Microsoft下载:http: ...
- java:访问权限-protected实例
在不同包,子类继承后可以使用父类的protect权限的属性或方法 父类: package com.tinyphp; public class Father { protected String nam ...
- centos下安装JDK8的方法
判断是否安装 首先,我们得判断机子上是不是安装了jdk,好多人推荐使用java -version命令.我的计算机上使用java -version命令,内容如下: java version " ...