Enter CombineFileInputFormat, it packs many files into each split so that each mapper has more to process. CombineFileInputFormat takes node and rack locality into account when deciding which blocks to place in the same split so it doesn't suffer from the same problem of simply having a big split size.
public class MyCombineFileInputFormat extends CombineFileInputFormat { public static class MyKeyValueLineRecordReader implements RecordReader { private final KeyValueLineRecordReader delegate; public MyKeyValueLineRecordReader( CombineFileSplit split, Configuration conf, Reporter reporter, Integer idx) throws IOException { FileSplit fileSplit = new FileSplit( split.getPath(idx), split.getOffset(idx), split.getLength(idx), split.getLocations()); delegate = new KeyValueLineRecordReader(conf, fileSplit); } @Override public boolean next(Text key, Text value) throws IOException { return delegate.next(key, value); } @Override public Text createKey() { return delegate.createKey(); } @Override public Text createValue() { return delegate.createValue(); } @Override public long getPos() throws IOException { return delegate.getPos(); } @Override public void close() throws IOException { delegate.close(); } @Override public float getProgress() throws IOException { return delegate.getProgress(); } } @Override public RecordReader getRecordReader( InputSplit split, JobConf job, Reporter reporter) throws IOException { return new CombineFileRecordReader( job, (CombineFileSplit) split, reporter, (Class) MyKeyValueLineRecordReader.class); } }
CombineFileInputFormat is an abstract class that you need to extend and override getRecordReader method. CombineFileRecordReader manages multiple input splits in CombineFileSplit simply by constructing new RecordReader for each input split within. MyKeyValueLineRecordReader creates a KeyValueLineRecordReader to delegate operations to.
Remember to set mapred.max.split.size to a small multiple of block size in bytes as otherwise there will be no split at all.
相关推荐
window下eclipse中运行mapreduce程序所需要的Hadoop全部jar包
对于两个输入文件,即文件 A 和文件 B,请编写 MapReduce 程序,对两个文件进行合并, 并剔除其中重复的内容,得到一个新的输出文件 C。下面是输入文件和输出文件的一个样例 供参考。 输入文件 A 的样例如下:
MapReduce Shuffle 过程图解 Xmind文件
使用命令行编译打包运行自己的MapReduce程序 Hadoop2.6.0
本人亲手操作搭建Hadoop集群成功,并通过Eclipse进行MapReduce程序的开发,步骤详细完整,在相关过程中配有完整代码和解释,全程无误,只需复制粘贴即可,小白新手按步骤一步一步来也能搭建Hadoop集群成功并进行...
4 分别在自编 MapReduce 程序 WordCount 运行过程中和运行结束后查看 MapReduce Web 界面。 5. 分别在自编 MapReduce 程序 WordCount 运行过程中和运行结束后练习 MapReduce Shell 常用命令。 。。
MapReduce2.0程序设计,包括编程模型介绍,编程接口介绍,Java编程与多语言编程的理论与实践
该文档的目录如下: 1.1实验目的 1.2实验环境 V 1.3实验步骤 1.3.1安装eclipse 1.3.2安装Hadoop- Eclipse Plugin ...1.3.5在Eclipse 中创建MapReduce项目 附:查看HDFS文件系统数据的三种方法
在hadoop平台关于mapreduce的一些应用程序,实现对大数据的分析处理
搭建了一个完全分布式Hadoop集群,并通过Java写了mapreduce程序处理数据,需要下载的可以找我要具体数据。
大数据分析课程设计后端大数据分析MapReduce程序和sql脚本.zip 95分以上必过项目,下载即用无需修改。 大数据分析课程设计后端大数据分析MapReduce程序和sql脚本.zip 95分以上必过项目,下载即用无需修改。大数据...
22、MapReduce使用Gzip压缩、Snappy压缩和Lzo压缩算法写文件和读取相应的文件 网址:https://blog.csdn.net/chenwewi520feng/article/details/130456088 本文的前提是hadoop环境正常。 本文最好和MapReduce操作常见...
Hadoop平台搭建(单节点,伪分布,分布式文件系统及其上MapReduce程序测试) 原创,保证质量,辛苦了很多天,故3分!
用mapreduce进行文本处理,发表在SIGIR2009
Windows下Eclispe远程开发Mapreduce程序
一个简单的MapReduce程序 WordCount单词统计 1 代码实现 2 目 录 一个非常经典的MapReduce案例——WordCount单词统计。 什么是MapReduce 一、WordCount单词统计 二、代码实现 对于map函数的方法。 Mapper的实现 ...
使用hadoop-streaming运行Python编写的MapReduce程序.rar
MapReduce简单程序示例
一个简单的MapReduce程序。Hadoop2.2.0上实测可用。
但是有一些时候,我们需要在MapReduce程序中使用C语言、C++以及其他的语言,比如项目的开发人员更熟悉Java之外的语言,或者项目已经有部分功能用其他语言实现等。针对这些情况,我们需要研究如何在基于Java的...