zoukankan      html  css  js  c++  java
  • MapReduce的输入文件是两个

    [学习笔记]

    1.对于MapReduce程序,如何输入文件是两个文件? 
    这一小节,我们将继续第一章大数据入门的HelloWorld例子做进一步的研究。这里,我们研究如何输入文件是两个文件。
    package com;
    import java.io.IOException;
    import java.util.StringTokenizer;
    import org.apache.hadoop.conf.Configuration;
    import org.apache.hadoop.fs.Path;
    import org.apache.hadoop.io.IntWritable;
    import org.apache.hadoop.io.Text;
    import org.apache.hadoop.mapreduce.Job;
    import org.apache.hadoop.mapreduce.Mapper;
    import org.apache.hadoop.mapreduce.Reducer;
    import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
    import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
    import org.apache.hadoop.util.GenericOptionsParser;
    public class WordCountMark_to_win {
        public static class TokenizerMapper extends Mapper<Object, Text, Text, IntWritable> {
            private final static IntWritable one = new IntWritable(1);
            private Text word = new Text();
            public void map(Object key, Text value, Context context) throws IOException, InterruptedException {
                System.out.println("key is 马克-to-win @ 马克java社区:防盗版实名手机尾号:73203"+key.toString()+" value is "+value.toString());
                StringTokenizer itr = new StringTokenizer(value.toString());
                while (itr.hasMoreTokens()) {
                    word.set(itr.nextToken());
                    context.write(word, one);
                }
            }
        }

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

  • 相关阅读:
    IndexOf、IndexOfAny 、Remove
    静态类、静态方法的使用
    面向对象 字段、方法、属性
    break、continue、return
    冒泡排序
    方法练习
    Oracle-查看oracle是否有表被锁
    教程-键盘扫描码
    网卡远程唤醒-远程开机再配合远程控制
    远程控制篇:在DELPHI程序中拨号上网
  • 原文地址:https://www.cnblogs.com/haima1949/p/11448100.html
Copyright © 2011-2022 走看看