Search code examples
accumulo

How to get the input file name in the mapper in a Accumulo program?


I am trying to the wordcount example and I wanted to print the name of the files where the word was found. But I dont know as how to get the name of the input split in map function of accumulo


Solution

  • Use the following command in the map function of your code:

    context is the variable of the class Context defined in the arguments of your map function:

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

    For more info: More info