빅데이터 하둡 프로그래밍 교육과정 ]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
'빅데이터 > 빅데이터Hadoop' 카테고리의 다른 글
빅데이터 하둡 프로그래밍 교육과정 ]MultipleInputs의 사용 (0) | 2017.02.07 |
---|---|
빅데이터 하둡 프로그래밍 교육과정 ]Join ID & Title 개요 (0) | 2017.02.07 |
빅데이터 하둡 프로그래밍 교육과정 ]개요 (0) | 2017.02.07 |
빅데이터 하둡 프로그래밍 교육과정 ]실행결과 (0) | 2017.02.06 |
빅데이터 하둡 프로그래밍 교육과정 ]Job Chaining 코드 (0) | 2017.02.06 |