본문 바로가기
Hadoop

Reducer

by 언덕너머에 2014. 6. 9.

  Reducer 클래스에서는 맵 태스크의 출력 데이타를 입력 데이터로 전달받아-집계 연산을 수행한다.


 -

  public class Reducer<KEYIN, VALUEIN, KEYOUT, VALUEOUT>

  예)

  public static class MyReduce extends Reducer<Text, LongWritable, Text, LongWritable> {

    private LongWritable sumWritable = new LongWritable();

    public void reduce(Text key, Iterable<LongWritable> values, Context context) 

                                   throws IOException, InterruptedException{

      long sum = 0;

      for(LongWritable val : values) {

        sum += val.get();

      }

      sumWritable.set(sum);

      context.write(key, sumWritable);                    

      //context.getCounter("Words Stats", "Unique Words").increment(1);            

      //context.getCounter("Words Stats", "Total Words").increment(sum);    

    }    

 }  


- Method 요약

  * ssetup


  * reduce


  * cleanup

'Hadoop' 카테고리의 다른 글

Hadoop Chain  (0) 2014.06.16
Hadoop Output Format  (0) 2014.06.13
Partitioner  (0) 2014.06.09
Mapper  (0) 2014.06.09
Inputformat 유형  (0) 2014.06.09