实验-MapReduce编程初级实践————————————————————————————————作者:————————————————————————————————日期: ;,包括数据去重、数据排序和数据挖掘等。实验平台已经配置完成的Hadoop伪分布式环境。,即文件A和文件B,请编写MapReduce程序,对两个文件进行合并,并剔除其中重复的内容,得到一个新的输出文件C。下面是输入文件和输出文件的一个样例供参考。实验最终结果(合并的文件):代码如下:.Merge;;.;.;.;.;.;.;.;.;lassMerge{lassMapextendsMapper<Object,Text,Text,Text>{privatestaticTexttext=newText();publicvoidmap(Objectkey,Textvalue,Contextcontext)throwsIOException,InterruptedException{text=value;(text,newText(""));}}lassReduceextendsReducer<Text,Text,Text,Text>{publicvoidreduce(Textkey,Iterable<Text>values,Contextcontext)throwsIOException,InterruptedException{(key,newText(""));}}publicstaticvoidmain(String[]args)throwsException{Configurationconf=newConfiguration();("","hdfs://localhost:9000");String[]otherArgs=newString[]{"input","output"};if(!=2){("Usage:Mergeandduplicateremoval<in><out>");(2);}Jobjob=(conf,"Mergeandduplicateremoval");
实验MapReduce编程初级实践 来自淘豆网www.taodocs.com转载请标明出处.