0
votes

To get file path in mapper or reducer we use

  FileSplit fileSplit = (FileSplit)reporter.getInputSplit();
  String filename = fileSplit.getPath().getName();
  System.out.println("File name "+filename);
  System.out.println("Directory and File name"+fileSplit.getPath().toString());

process(key,value);

But In input folder i had five different kind of files so need to get file name such that i can set different mappers for different files . example in args[0] my input folder /cloudera/test contains test.txt,dev.txt,rev.txt

if file name contains dev I should set mapper1 file name contains test I should set mapper 2 ..........

2

2 Answers

1
votes

You have to use MultipleInputs and mappers i think i got a good link for you help that helped me too when i practiced it long back.

MultipleInput Usage

0
votes

You can use something like this: FileInputFormat.addInputPaths(job, String.valueOf(args[0]+","+args[1]));

Where, you can mention the paths of individual files in args[0] and args[1].