如何从Map-Reduce中的多个目录中读取多个文件

Bha*_*hah 1 java hadoop

我想在Map-Reduce程序中读取多个目录中的多个文件.我试图在main方法中给出文件名:

FileInputFormat.setInputPaths(conf,new Path("hdfs://localhost:54310/user/test/"));
FileInputFormat.setInputPaths(conf,new Path("hdfs://localhost:54310/Test/test1/"));
Run Code Online (Sandbox Code Playgroud)

但它只是从一个文件中读取.

我该怎么做才能读取多个文件?

请提出解决方案.

谢谢.

Pra*_*ati 5

FileInputFormat#setInputPaths将覆盖先前设置的输入路径后设置输入路径.使用FileInputFormat#addInputPathFileInputFormat#addInputPaths添加到现有路径.