import java.io.IOException; import java.util.*; import org.apache.hadoop.fs.Path; import org.apache.hadoop.conf.*; import org.apache.hadoop.io.*; import org.apache.hadoop.mapreduce.*; import org.apache.hadoop.util.*; // outputkey is going to be the condidate number public class reducecounter extends Reducer { protected void reduce(IntWritable inkey, Iterable vals, Context collector) throws IOException, InterruptedException { Iterator values = vals.iterator(); long ccount = 0; long most = -1; // file with most cats int filenum = 0; // file number with most cats while (values.hasNext()) { catval current = values.next(); ccount += current.count; if (current.count > most) { most=current.count; filenum = current.filenum; } } IntWritable outkey = new IntWritable(0); // common key for reducer Text outval = new Text("Total CATs = "+ccount+", file with most CATs = dna"+filenum); collector.write(outkey,outval); // output result }//reducer }//reducecounter