package com.esri.hadoop.examples;
import java.io.IOException;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;


public class ReducerClass extends Reducer<Text, EarthquakeDataWritable, Text, EarthquakeDataWritable> {
	
	public void reduce(Text key, Iterable<EarthquakeDataWritable> values, Context ctx) throws IOException, InterruptedException{
		
		int agg_cnt = 0;
		float agg_avgMag = 0;
		float agg_minMag = 999;
		float agg_maxMag = 0;
		
		for (EarthquakeDataWritable data : values)
		{
			int cnt = data.getCnt();
			float avgMag = data.getAvg();
			float minMag = data.getMin();
			float maxMag = data.getMax();
			
			agg_cnt += cnt;
			agg_avgMag = (agg_avgMag == 0) ? avgMag : (agg_avgMag + avgMag) / 2;
			
			agg_minMag = Math.min(agg_minMag, minMag);
			agg_maxMag = Math.max(agg_maxMag, maxMag);
		}
		

		EarthquakeDataWritable array = new EarthquakeDataWritable(agg_cnt, agg_avgMag, agg_minMag, agg_maxMag);
		
		
		ctx.write(key, array);
	}
	
}

@@ -483,16 +483,242 @@
 0;%0D%0A%09%09%0D%0A
+%09%09/* What we've got here is a key (county name such as 'Riverside') and a%0D%0A%09%09 * list of every earthquake that occurred inside that county's boundary.%0D%0A%09%09 * All we need to do is loop and aggregate the data in the list.%0D%0A%09%09 */%0D%0A
 %09%09for (E

Update ReducerClass.java