如何在MapReduce中处理标题和预告片 [英] How to process Header and Trailer in MapReduce

查看:121
本文介绍了如何在MapReduce中处理标题和预告片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何处理文件中的标题和预告片?
处理完这些行后,应该从文件中删除。



标题行可以通过偏移值0和相同的拖尾找到最大偏移量。
但是这里的问题是我们如何在一个映射器中获得这两条线?



欣赏你的帮助..



Regards,Mohammed Niaz

解决方案

当给定的输入文件只有一个映射器时,这是可能的。 / p>

我们可以在以下三个选项中处理标题和预告片记录


  1. 编写自定义InputFormat文件并扩展FileInputFormat。在自定义的InputFormat覆盖isSplitable()方法并返回'false',MR框架不会拆分文件内容并将整个内容传递给一个映射器类。
  2. 使hdfs块的大小大于文件大小(但不推荐)。因此,整个文件内容可供一个映射器类使用。

  3. 如果输入文件是Gzipped(即压缩),则整个文件内容可供一个映射器使用。 b

欢迎您提出任何意见或建议。


How to process the Header and Trailer in the file? After processing these lines, it should be removed from the file.

The Header line can be found by the offset value 0 and the same trailer the max offset. But the issue here is how we can get both these lines in one mapper?

Appreciate your help..

Regards, Mohammed Niaz

解决方案

It is possible when we have only one mapper for the given input file.

We can process Header and Trailer records in below three options

  1. Write a custom InputFormat file and extend FileInputFormat. In custom InputFormat override isSplitable() method and return 'false' thus MR framework wont split the file content and pass whole content to one mapper class.
  2. Make the hdfs block size greater than the file size(but not recommended). So the whole file content would be available to one mapper class.
  3. Whole file content would be available to one mapper if input file is Gzipped(i.e compressed).

Would welcome any comments or suggestions.

这篇关于如何在MapReduce中处理标题和预告片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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