2015-10-06 41 views

回答

1

可以使用Mapper類中的下面的代碼片段來檢索文件名。

FileSplit fileSplit = (FileSplit)context.getInputSplit(); 
String filename = fileSplit.getPath().getName(); 
+0

嗨,Madhu,你知道如何發送文件名作爲使用context.write時的值。在WordCount的例子中,我想使用context.write(new Text(stringWord),fileName);而不是context.write(new Text(stringWord),one);我在減少部分做了一些改動,但仍然無法工作。 – VD007

+1

你可以發佈你的完整代碼嗎?...如果你沒有通過一個,那麼我們將如何能夠找到字數...你能讓我知道清楚 – madhu

+0

http://stackoverflow.com/questions/32969870/ wordcount-example-with-count-per-file/32970219#32970219 – VD007

相關問題