如何限制Hadoop序列文件的大小? [英] how to limit size of Hadoop Sequence file?

查看:130
本文介绍了如何限制Hadoop序列文件的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用txt作为输入来编写Hadoop seq文件。
我知道如何从文本文件写入序列文件。



但我想限制输出序列文件的大小,比如256MB。



有没有内建的方法可以做到这一点?

解决方案

AFIAK you'll需要编写自己的自定义输出格式来限制输出文件的大小 - 默认情况下,FileOutputFormats为每个Reducer创建一个输出文件。

另外一个选项是按常规创建序列文件,然后再用第二份工作(仅限地图)和身份映射器,然后修改最小/最大输入拆分大小,以确保每个映射器仅处理每个256MB的数据。这将意味着输入文件1GB将由4个映射器处理并创建256MB的输出文件。你会得到较小的文件,其中输入文件是300MB(256MB映射器和44MB映射器将运行)。



您正在查找的属性是:




  • mapred.min.split.size

  • mapred.max.split.size



它们都配置为字节大小,因此将它们都设置为 268435456


I am writing Hadoop seq file using txt as input. I know how to write Sequence file from text file.

But i want to limit the output sequence file to some specific size say, 256MB.

Is there any inbuilt method to do this?

解决方案

AFIAK you'll need to write your own custom output format to limit output file sizes - by default FileOutputFormats create a single output file per reducer.

Another option is to create your sequence files as normal, then then a second job (map only), with identity mappers and then amend the minimum / maximum input split size to ensure that each mapper only processes ¬256MB each. This will mean a input file og 1GB would be processed by 4 mappers and create output files of ¬256MB. You will get smaller files where an input file is say 300MB (256MB mapper and a 44MB mapper will run).

The properties you are looking for are:

  • mapred.min.split.size
  • mapred.max.split.size

They are both configured as byte sizes, so set them both to 268435456

这篇关于如何限制Hadoop序列文件的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆