    public static class MasteringHadoopAvroReducer extends Reducer<Text, LongWritable, Text, LongWritable>{
 
         private LongWritable total = new LongWritable();
 
 
         @Override
         protected void reduce(Text key, Iterable<LongWritable> values, Context context) throws IOException, InterruptedException {
             long totalPopulation = 0;
 
             for(LongWritable pop : values){
                 totalPopulation += pop.get();
             }
 
             total.set(totalPopulation);
             context.write(key, total);
         }
     }
 
 
 
 
     public static void main(String args[]) throws IOException, InterruptedException, ClassNotFoundException, URISyntaxException{
 
         GenericOptionsParser parser = new GenericOptionsParser(args);
         Configuration config = parser.getConfiguration();
         String[] remainingArgs = parser.getRemainingArgs();
 
         config.set("citySchema", citySchema);
 
         Job job = Job.getInstance(config, "MasteringHadoop-AvroMapReduce");
 
         job.setMapOutputKeyClass(AvroKey.class);
         job.setMapOutputValueClass(Text.class);
         job.setOutputKeyClass(Text.class);
         job.setOutputValueClass(LongWritable.class);
 
         job.addCacheFile(new URI(remainingArgs[2]));
 
         job.setMapperClass(MasteringHadoopAvroMapper.class);
         job.setReducerClass(MasteringHadoopAvroReducer.class);
         job.setNumReduceTasks(1);
 
         Schema schema  = (new Schema.Parser()).parse(new File(remainingArgs[2]));
         AvroJob.setInputKeySchema(job, schema);
 
         job.setInputFormatClass(AvroKeyInputFormat.class);
         job.setOutputFormatClass(TextOutputFormat.class);
 
         AvroKeyInputFormat.addInputPath(job, new Path(remainingArgs[0]));
         TextOutputFormat.setOutputPath(job, new Path(remainingArgs[1]));
 
         job.waitForCompletion(true);
 
     }
 }
 
 
