public void map(Object key, Text value, Context context) throws IOException, InterruptedException { String[] line = value.toString().split(","); month.set(line[2]); int delay = Integer.parseInt(line[20]); outTuple.setCount(1); outTuple.setMax(delay); outTuple.setMin(delay); context.write(month, outTuple); }
public void reduce(Text key, Iterable<MinMaxCountsTuple> values, Context context) throws IOException, InterruptedException { result.setMin(Integer.MAX_VALUE); result.setMax(Integer.MIN_VALUE); result.setCount(0); int sum = 0; for (MinMaxCountsTuple val : values) { if (val.getMin() < result.getMin()) { result.setMin(val.getMin()); } if (val.getMax() > result.getMax()) { result.setMax(val.getMax()); } sum += val.getCount(); } result.setCount(sum); context.write(key, result); }