*
* @param work
*/
protected void extractFileMapResult(InitialMapWork work) {
LinkedList<Future<Map<String, Integer>>> futureResults = new LinkedList<Future<Map<String, Integer>>>();
LineIterator lineIterator = null;
try {
File fileToCount = work.getFileToCount();
lineIterator = FileUtils.lineIterator(fileToCount);
while (lineIterator.hasNext()) {
// All work including special character handling done at worker
// level
String line = lineIterator.nextLine();
// key is just the file name - initial mapping is easy
// hard part comes with partitioning and reduction
// we assume that we have unique file names in the dir
MapWork newWork = new MapWork(fileToCount.getName(), line);
Future<Map<String, Integer>> future = this.workRouter
.sendRequestReplyFuture(newWork, 30000, getContext());
future.await();
futureResults.add(future);
}
// FinalMapResult result = new FinalMapResult(
// (LinkedList<Future<Map<String, Integer>>>) futureResults);
getContext().channel().sendOneWay(futureResults);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (lineIterator != null) {
lineIterator.close();
}
}
}