hadoop框架

面试Hadoop工程师有哪些问题?

 

 

 

wordcount mr java代码

 1 public class WordCount {
 2     public static class Map{
 3         static IntWritable one = new IntWritable(1);
 4         Text word = new Text();
 5         public void map(Object key, Text values, Context context) throws IOException, InterruptrdException{
 6             StringTokenzier str = new StringTokenzier(values);
 7             while (str.hasMoreToken()) {
 8                 word.set(str.nextToken());
 9                 context.write(word, one);
10             }
11         }
12     }
13     public static class Reduce{
14         static IntWritable ans = new IntWritable();
15         public void reduce(Text key, Iterator<IntWritable> values, Context context) throws IOException, InterruptedException {
16             int sum = 0;
17             while (values.hasNext()) {
18                 sum += values.getNext();
19             }
20             ans.set(sum);
21             Conetxt.write(key, ans);
22         }
23     }
24 }
View Code

hadoop优化的七个建议 http://langyu.iteye.com/blog/916304

posted @ 2017-03-10 11:47  fisherinbox  阅读(137)  评论(0编辑  收藏  举报