MyReducer.reduce
public void reduce(Text key, lterable<Text>
valuelter, final Context context) throws
IOException, InterruptedException
{
String title=null;
String frequency=null;
int count=0;
for(Text t: valuelter)
{
String str=t.toString();
String[]tokens=str.split("\\t");
if(tokens[1].equals("1"))
title=tokens[0];
else
frequency=tokens[0];
count++;
}
if (count == 2 && title !=null && frequency !=null)
context.write(key,new Text(title+"\\t"+frequency));
}
실행결과
(top 10 most referred wikipedia pages)
14532 ltaly 23075
15573 Japan 21453
3383 Vrazil 13632
38523 Departments of France 10900
9239 Europe 12545
9316 England 34884
14533 India 24610
5405 China 12187
18951490 American football 9536
5407 California 15945
'빅데이터 > 빅데이터Hadoop' 카테고리의 다른 글
빅데이터공부하기 58_ JOIN ID AND TITLE V2 (0) | 2014.11.26 |
---|---|
빅데이터공부하기57_SORT STRING (0) | 2014.11.26 |
빅데이터공부하기 56_1 MyMapper.map (0) | 2014.11.21 |
빅데이터공부하기 56_ JOIN ID & TITLE (0) | 2014.11.20 |
빅데이터공부하기 55_ COUNT CITATION (0) | 2014.11.19 |