我有一个输入bz2文件的文件夹,其中一些可能已损坏,我想在运行MR作业之前删除所有损坏/无效的bz2文件。有什么好方法吗?
最佳答案
使用bzip2 -t测试bzip文件是否已损坏。如果它已损坏,我认为您可以看到类似的内容。
bzip2: test1.txt: bad magic number (file not created by bzip2)
bzip2: 2: bad magic number (file not created by bzip2)
You can use the `bzip2recover' program to attempt to recover
data from undamaged sections of corrupted files.
因此,如果文件位于本地文件系统中,则应使用基于上述要点的一些Shell脚本。如果文件已经在HDFS上,则将Hadoop streaming与mapper一起用作脚本来输出损坏的文件,并且不使用reducer,或者用reducer删除或后期处理这些文件。
关于validation - 加载到Hadoop MR之前的文件验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19551566/