草庐IT

shift-reduce

全部标签

java - hadoop java : how to know that end of reducer input is reached?

我的reducer是这样的publicstaticclassReduceextendsMapReduceBaseimplementsReducer{ListallRecords=newArrayList();publicvoidreduce(IntWritablekey,Iteratorvalues,OutputCollectoroutput,Reporterreporter)throwsIOException{allRecords.add(values.next());Text[]outputValues=newText[7];for(inti=1;i>=7;i++){outputV

hadoop - 转换序列文件并通过 map 和 hadoop 中的 reduce 任务获取键值对

我想通过hadoopmapreduce应用程序从顺序文件中获取所有键值对。我关注了以下帖子http://lintool.github.com/Cloud9/docs/content/staging-records.html用于读取主类中的顺序文件,但该功能有效。我想将所有键值对打印到hdfs系统中的普通文本文件,我该如何实现?我的代码如下所示。importjava.io.File;importjava.io.IOException;importjava.util.*;importjava.util.logging.Level;importjava.util.logging.Logger

java - Hadoop MR 在 reduce 方法中保持数组引用

我想要一个arrayList来保存对reduce函数中对象的引用。@Overridepublicvoidreduce(finalTextpKey,finalIterablepValues,finalContextpContext)throwsIOException,InterruptedException{finalArrayListbsonObjects=newArrayList();for(finalBSONWritablevalue:pValues){bsonObjects.add(value);//dosomecalculations.}for(finalBSONWritabl

java - 相当于 mongo 的输出 :reduce option in hadoop

我正在重写MongoDBmapreduce作业以改用Hadoop(使用mongo-hadoop连接器),但是当我将两个数据集映射到同一个集合时,它会覆盖值而不是使用它们{reduce:"collectionName"}-Ifdocumentsexistsforagivenkeyintheresultsetandintheoldcollection,thenareduceoperation(usingthespecifiedreducefunction)willbeperformedonthetwovaluesandtheresultwillbewrittentotheoutputcol

java - 即使在命令行上告诉为 -D mapred.reduce.tasks=0 后,hadoop reduce 任务仍在运行

我有一个MapReduce编程为publicstaticclassMapClassextendsMapReduceBaseimplementsMapper{privatefinalstaticIntWritableuno=newIntWritable(1);privateIntWritablecitationCount=newIntWritable();publicvoidmap(Textkey,Textvalue,OutputCollectoroutput,Reporterreporter)throwsIOException{citationCount.set(Integer.par

java - 在 hadoop 中实现多个映射器和单个 reducer

我是hadoop的新手。我有多个包含文件的文件夹来处理hadoop中的数据。我怀疑在map-reducer算法中实现映射器。我可以指定多个映射器来处理多个文件,并使用单个reducer将所有输入文件作为一个输出吗?如果可能,请提供实现上述步骤的指南。 最佳答案 如果您有多个文件,请使用MultipleInputsaddInputPath()方法可用于:添加多个路径和一个通用映射器实现使用自定义映射器和输入格式实现添加多个路径。对于单个reducer,让每个映射的输出键都相同...比如1或“abc”。这样,框架将只创建一个reduce

hadoop - Hadoop 的标准 Mapper 和 Reducer 类?

是否有适用于Hadoop的标准Mappers和Reducers的包或集合?例如,OpenMP带有一组用于循环并行化的预定义缩减器,这很方便,但不可扩展。一组类似的基本reducer对于Hadoop来说会很方便。当您使用Spring-DataHadoop构建SpringBatch应用程序时,这样的集合将非常有用。如果没有这样的东西,我们可以开始收集。Kr,R 最佳答案 Hadoop附带了大量的Mappers和Reducers。它们存储在org.apache.hadoop.mapred.lib中,涵盖了广泛的用例。如果您想查看快速列表,

hadoop - Hadoop Reduce child 中的 OOM 异常

我收到关于reducechild的OOM异常(Java堆空间)。在reducer中,我将所有值附加到StringBuilder,这将是reducer进程的输出。值的数量不是那么多。我试图将mapred.reduce.child.java.opts的值增加到512M和1024M,但这没有帮助。Reducer代码如下。StringBuilderadjVertexStr=newStringBuilder();longitcount=0;while(values.hasNext()){adjVertexStr.append(values.next().toString()).append(""

java - Hadoop map-reduce 输出包含奇怪的字符

我正在运行map缩减作业。当我在我的单节点集群机器上运行它时,输出如下所示hduser@nikhil-VirtualBox:/usr/local/hadoop/hadoop-1.0.4$bin/hadoopdfs-text/user/hduser/output16/part-r-000000RequiredGenotypecolumn(s),MustnotcontainNULLSforrequiredfields,failed,5,1:GENE_NAME;2:GENE_NAME;4:GENE_NAME;5:GENE_NAME;9:GENE_NAME但是,当我在AmazonEMR上对更大

hadoop - 如何在Hadoop主程序中访问reducer输出的值(或键)?

假设每个Reducer输出一个整数作为它的值(或键)。有什么方法可以在Hadoop的主程序中访问这些值(或键)(例如,将它们相加)? 最佳答案 你的输出格式是什么?如果您使用的是SequenceFileOutput,则可以在作业完成后使用SequenceFile.Reader类在主程序中打开part-r-xxxxx文件。例如输出的作业,您可以按如下方式对值求和:FileSystemfs=FileSystem.get(getConf());Textkey=newText();IntWritablevalue=newIntWritabl