zoukankan      html  css  js  c++  java
  • hadoop在eclipse当中如何添加源码?

    [学习笔记]

    /*org.apache.hadoop.mapreduce.Mapper.Context,java.lang.InterruptedException,想看map的源代码,按control,点击,出现Attach Source Code,点击External Location/External File,找到源代码,就在Source目录下,,D:hadoop-2.7.4src
     其中key为此行的开头相对于文件的起始位置,value就是此行的字符文本
      */  public void map(Object key, Text value, Context context) throws IOException, InterruptedException {
                System.out.println("key is 马克-to-win @ 马克java社区 "+key.toString()+" value is "+value.toString());
                StringTokenizer itr = new StringTokenizer(value.toString());
                while (itr.hasMoreTokens()) {
                    word.set(itr.nextToken());
                    context.write(word, one);
                }
            }
        }

        public static class IntSumReducer extends Reducer<Text, IntWritable, Text, IntWritable> {
            private IntWritable result = new IntWritable();
            public void reduce(Text key, Iterable<IntWritable> values, Context context)
                    throws IOException, InterruptedException {
                System.out.println("reduce key is 马克-to-win @ 马克java社区 "+key.toString());
                int sum = 0;
                for (IntWritable val : values) {
                    int valValue=val.get();
                    System.out.println("valValue is"+valValue);
                    sum += valValue ;
                }
                result.set(sum);
                context.write(key, result);
            }
        }


        public static void main(String[] args) throws Exception {
            Configuration conf = new Configuration();
            String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();
            if (otherArgs.length != 2) {
                System.err.println("Usage: wordcount <in> <out>");
                System.exit(2);
            }
            Job job = new Job(conf, "word count");
            job.setJarByClass(WordCount.class);
            job.setMapperClass(TokenizerMapper.class);

    文章转载自原文:https://blog.csdn.net/qq_44594249/article/details/96110661

  • 相关阅读:
    encodeURIcomponent编码和ASP.NET之间编码转换
    android入门学习一 基本概念
    Acvityity 的生命周期
    Android中ADT插件的安装
    控件必须放在具有 runat=server 的窗体标记内 错误解决解决方法
    AspNetPager 重写UrlRewriting配置示例
    将字符串按指定长度换行的一个C#方法
    [添砖加瓦]:ExtJS+WCF+LINQ打造全功能Grid
    C#中判断字符是否为中文
    Asp.net中防止用户多次登录的方法
  • 原文地址:https://www.cnblogs.com/haima1949/p/11444867.html
Copyright © 2011-2022 走看看