-2
在hadoop中的WordCount任務中,如何獲取令牌字的文件名並在context.write(new Test(filename),one)中使用它?如何獲得hadoop WordCount應用程序中所有令牌字的文件名?
在hadoop中的WordCount任務中,如何獲取令牌字的文件名並在context.write(new Test(filename),one)中使用它?如何獲得hadoop WordCount應用程序中所有令牌字的文件名?
可以使用Mapper類中的下面的代碼片段來檢索文件名。
FileSplit fileSplit = (FileSplit)context.getInputSplit();
String filename = fileSplit.getPath().getName();
嗨,Madhu,你知道如何發送文件名作爲使用context.write時的值。在WordCount的例子中,我想使用context.write(new Text(stringWord),fileName);而不是context.write(new Text(stringWord),one);我在減少部分做了一些改動,但仍然無法工作。 – VD007
你可以發佈你的完整代碼嗎?...如果你沒有通過一個,那麼我們將如何能夠找到字數...你能讓我知道清楚 – madhu
http://stackoverflow.com/questions/32969870/ wordcount-example-with-count-per-file/32970219#32970219 – VD007