SequenceFileInputFormat区别TextInputFormat

本文详细介绍了Hadoop中InputFormat的作用及其配置参数,包括如何通过InputFormat检查输入数据的正确性、切分输入数据以及读取输入数据。此外还介绍了几种常用的InputFormat实现,如TextInputFormat和SequenceFileInputFormat。

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


 

通过InputFormat,Hadoop可以:

l           检查MapReduce输入数据的正确性;

l           将输入数据切分为逻辑块InputSplit,这些块会分配给Mapper;

l           提供一个RecordReader实现,Mapper用该实现从InputSplit中读取输入的<K,V>对。


 

通过FileInputFormat。下面几个参数可以用于配置FileInputFormat:

l           mapred.input.pathFilter.class:输入文件过滤器,通过过滤器的文件才会加入InputFormat;

l           mapred.min.split.size:最小的划分大小;

l           mapred.max.split.size:最大的划分大小;

l           mapred.input.dir:输入路径,用逗号做分割。

 
 
java.lang.Object
  org.apache.hadoop.mapreduce.InputFormat<K,V>
      org.apache.hadoop.mapreduce.lib.input.FileInputFormat<K,V>
          org.apache.hadoop.mapreduce.lib.input.SequenceFileInputFormat<K,V>



java.lang.Object
  org.apache.hadoop.mapreduce.InputFormat<K,V>
      org.apache.hadoop.mapreduce.lib.input.FileInputFormat<LongWritable,Text>
          org.apache.hadoop.mapreduce.lib.input.TextInputFormat


TextInputFormat: 默认的输入格式,行号为Key,文件中该行的内容为value

SequenceFileInputFormat: key-value 对的二进制文件
	通过如下方式进行设置使用:
 	job.setInputFormatClass(SequenceFileInputFormat.class);
   	job.setOutputFormatClass(SequenceFileOutputFormat.class);

转载于:https://www.cnblogs.com/baoendemao/p/3804713.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值