빅데이터 하둡 프로그래밍 교육과정 ]Map ,Reduce 코드 & 실행결과




빅데이터 하둡 프로그래밍 교육과정 ]Map ,Reduce 코드 & 실행결과

실무개발자를위한 실무교육 전문교육센터학원

www.oraclejava.co.kr에 오시면 보다 다양한 강좌를 보실 수 있습니다.


Map ,Reduce 코드 & 실행결과


■ Map 코드 

 public static class Map extends Mapper<Text, Text, Text, IntWritable> {

    private final static IntWritable one = new IntWritable(1);

    public void map(Text key, Text value, Context context) throws IOException, InterruptedException {

        context.write(value, one);

    }

 }



■ Reduce 코드

public static class Reduce extends Reducer<Text, IntWritable, Text, IntWritable> {

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

      throws IOException, InterruptedException {

        int sum = 0;

        for (IntWritable val : values)

            sum += val.get();

        context.write(key, new IntWritable(sum));

    }

 }



■ 실행결과

앞서 결과에 TopN Job을 실행하여 추출된 top 10 DocID

18951490        9536

38523   10900

5405    12187

9239    12545

3383    13632

5407    15945

15573   21453

14532   23075

14533   24610

9316    34884

+ Recent posts