[學習筆記] 下載hadoop-2.7.4-src.tar.gz,拷貝hadoop-2.7.4-src.tar.gz中hadoop-mapreduce-project\hadoop-mapreduce-examples\src\main\java\org\apache\hadoop\examples ...
[學習筆記]
下載hadoop-2.7.4-src.tar.gz,拷貝hadoop-2.7.4-src.tar.gz中hadoop-mapreduce-project\hadoop-mapreduce-examples\src\main\java\org\apache\hadoop\examples下的WordCount.java文件中的內容到新創建的WordCount空類中。此處附上:
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 WordCount {
/*下麵的話是我講靜態內部類時的話:馬克-to-win:這裡的內部類的static,意思是它可以不用實例化外部類,就自己單獨被實例化,單獨存在(有點像生活中的辦公室和辦公桌(獨立於辦公室,辦公桌也可以存在)),靜態方法不就不用實例化類,直接用嗎?就實例化而言,靜態內部類和外層類之間完全沒有任何關係,相互獨立。誰愛怎麼樣,就怎麼樣!誰想實例化誰就實例化, 不管對方的感受。當然要想讓它們有關係,也可以,見下麵例子中的tc.core=nc;*/
public static class TokenizerMapper extends Mapper<Object, Text, Text, IntWritable> {
private final static IntWritable one = new IntWritable(1);
private Text word = new Text();
org.apache.hadoop.mapreduce.Mapper.Context,java.lang.InterruptedException,想看map的源代碼,按control,點擊,出現Attach Source Code,點擊External Location/External File,找到源代碼,就在Source目錄下,,D:\hadoop-2.7.4\src
其中key為此行的開頭相對於文件的起始位置,value就是此行的字元文本
文章轉載自原文:https://blog.csdn.net/qq_44594249/article/details/95863084