2011-11-13 143 views
2

我有一個HDFS結構類似使用FileInputFormat.addInputPaths遞歸添加HDFS路徑

a/b/file1.gz 
a/b/file2.gz 
a/c/file3.gz 
a/c/file4.gz 

我使用的

FileInputFormat.addInputPaths(conf, args[0]); 

經典模式設置爲我輸入路徑java map減少工作。

如果我指定能正常工作ARGS [0]作爲A/B但如果我只指定一個(我的意圖是處理所有4個文件)

錯誤是

失敗
Exception in thread "main" java.io.IOException: Not a file: hdfs://host:9000/user/hadoop/a 

如何遞歸添加下的所有內容a

我必須失去了一些東西簡單...

回答

2

這是在Hadoop中的當前版本中的錯誤。這是JIRA相同。它仍處於開放狀態。在代碼中進行更改並構建二進制文件或等待它在即將發佈的版本中得到修復。遞歸處理文件可以打開/關閉,查看連接到JIRA的補丁以獲取更多細節。

4

Eitan Illuz提到here,Hadoop中2.4.0引入一個mapreduce.input.fileinputformat.input.dir.recursive配置屬性,當設置爲true指示輸入格式遞歸包含文件。

在Java代碼中,它看起來是這樣的:

Configuration conf = new Configuration(); 
conf.setBoolean("mapreduce.input.fileinputformat.input.dir.recursive", true); 
Job job = Job.getInstance(conf); 
// etc. 

我一直在使用這種新的屬性,發現它工作得很好。

編輯:更重要的是,使用這種新方法在FileInputFormat能實現相同的結果:

Job job = Job.getInstance(); 
FileInputFormat.setInputDirRecursive(job, true); 
+0

conf.setBoolean( 「mapreduce.input.fileinputformat.input.dir.recursive」,真正的);也在Hadoop 2.2.0中爲我工作 – Alex