Class IntSumClassicReducer

java.lang.Object
mapreduce.apps.intsum.studio.IntSumClassicReducer
All Implemented Interfaces:
Collector<Integer,​List<Integer>,​Integer>, ClassicReducer<Integer,​Integer>

public class IntSumClassicReducer extends Object implements ClassicReducer<Integer,​Integer>
A reducer that sums all of the Integers passed to it. This is used in the word count example to sum all of the ones passed to it. Note that this class implements ClassicReducer. This means that it is a Collector, and the other Collector methods are defined in the ClassicReducer interface.
Author:
__STUDENT_NAME__, Finn Voichick, Dennis Cosgrove (http://www.cse.wustl.edu/~cosgroved/)
  • Constructor Details

    • IntSumClassicReducer

      public IntSumClassicReducer()
  • Method Details

    • finisher

      public Function<List<Integer>,​Integer> finisher()
      Returns a Function used to convert from a List of Integers to a single Integer. This function should, given a list of integers, return their sum. Note the interesting structure of this method. It is returning an anonymous class that implements the Function interface. The Function interface has a Function.apply(Object) method, which our anonymous inner class must implement. We're giving you this structure, and you just have to implement the apply method.
      Specified by:
      finisher in interface Collector<Integer,​List<Integer>,​Integer>