如何以递归方式在新的Hadoop API中使用目录结构?

rab*_*ens 4 recursion hadoop hdfs

我的文件结构如下:

/indir/somedir1/somefile
/indir/somedir1/someotherfile...
/indir/somedir2/somefile
/indir/somedir2/someotherfile...
Run Code Online (Sandbox Code Playgroud)

我现在想要递归地将所有内容传递给MR作业,我正在使用新的API.所以我做了:

FileInputFormat.setInputPaths(job, new Path("/indir"));
Run Code Online (Sandbox Code Playgroud)

但是这项工作失败了:

Error: java.io.FileNotFoundException: Path is not a file: /indir/somedir1
Run Code Online (Sandbox Code Playgroud)

我正在使用Hadoop 2.4,在这篇文章中声明Hadoop 2的新API不支持递归文件.但我想知道这是怎么回事,因为我认为在Hadoop工作中抛出一个大的嵌套目录结构是世界上最普通的事情......

那么,这是故意的,还是这个错误?在这两种方式中,除了使用旧API之外还有其他解决方法吗?

rab*_*ens 15

我自己找到了答案.在上述论坛帖子中链接的JIRA中,有两条关于如何正确完成的评论:

  1. 设置mapreduce.input.fileinputformat.input.dir.recursivetrue(注释状态mapred.input.dir.recursive但不推荐使用)
  2. 使用FileInputFormat.addInputPath指定输入目录

通过这些更改,它可以工作.