Search code examples
hadoopmapreducereducersmultipleoutputs

How to change the reducer output file names in a hadoop mr job?


I have a reducer script that need generate a bunch of xml files. I want to set the file name programatically using reducer key. I'm using MultipleOutputs to accomplish that as follows.

MultipleOutputs mos = new MultipleOutputs(context);
mos.write(new Text(key), new Text(output), key + ".xml");

But the output filenames are like key.xml-r-00000. How to remove -r-* part from the filename so that it will be simply key.xml?


Solution

  • Here -r-0000 shows that it is generated from reducer.We can not change it, If you want your customize file name, write a code after generation of these file to change the file name.