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

    原文作者:MapReduce
    原文地址: https://www.cnblogs.com/haima1949/archive/2019/09/02/11448100.html
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞