[學習筆記] 1.對於MapReduce程式,如何輸入文件是兩個文件? 這一小節,我們將繼續第一章大數據入門的HelloWorld例子做進一步的研究。這裡,我們研究如何輸入文件是兩個文件。package com;import java.io.IOException;import java.util. ...
[學習筆記]
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