The new API version of MapFileOutputFormat is not availble in the hadoop 1.x release series now (although equivalent old API MapFileOutputFormat class is available, located in package org.apache.hadoop.mapred).
To make use of this class, you have to port this class from hadoop 2.x or other version of hadoop that this class is available. The implementation is:
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.io.IOException; import java.util.Arrays; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.FileUtil; import org.apache.hadoop.io.MapFile; import org.apache.hadoop.io.WritableComparable; import org.apache.hadoop.io.Writable; import org.apache.hadoop.io.SequenceFile.CompressionType; import org.apache.hadoop.io.compress.CompressionCodec; import org.apache.hadoop.io.compress.DefaultCodec; import org.apache.hadoop.mapreduce.Partitioner; import org.apache.hadoop.mapreduce.RecordWriter; import org.apache.hadoop.mapreduce.TaskAttemptContext; import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; import org.apache.hadoop.mapreduce.lib.output.SequenceFileOutputFormat; import org.apache.hadoop.util.ReflectionUtils; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.conf.Configuration; /** * An {@link org.apache.hadoop.mapreduce.OutputFormat} that writes * {@link MapFile}s. * * Since this class is missing from hadoop 1.x, I ported it from main trunk. */ @InterfaceAudience.Public @InterfaceStability.Stable public class MapFileOutputFormat extends FileOutputFormat<WritableComparable<?>, Writable> { public RecordWriter<WritableComparable<?>, Writable> getRecordWriter( TaskAttemptContext context) throws IOException { Configuration conf = context.getConfiguration(); CompressionCodec codec = null; CompressionType compressionType = CompressionType.NONE; if (getCompressOutput(context)) { // find the kind of compression to do compressionType = SequenceFileOutputFormat.getOutputCompressionType(context); // find the right codec Class<?> codecClass = getOutputCompressorClass(context, DefaultCodec.class); codec = (CompressionCodec) ReflectionUtils.newInstance(codecClass, conf); } Path file = getDefaultWorkFile(context, ""); FileSystem fs = file.getFileSystem(conf); // ignore the progress parameter, since MapFile is local final MapFile.Writer out = new MapFile.Writer(conf, fs, file.toString(), context.getOutputKeyClass().asSubclass(WritableComparable.class), context.getOutputValueClass().asSubclass(Writable.class), compressionType, codec, context); return new RecordWriter<WritableComparable<?>, Writable>() { public void write(WritableComparable<?> key, Writable value) throws IOException { out.append(key, value); } public void close(TaskAttemptContext context) throws IOException { out.close(); } }; } /** Open the output generated by this format. */ public static MapFile.Reader[] getReaders(Path dir, Configuration conf) throws IOException { FileSystem fs = dir.getFileSystem(conf); Path[] names = FileUtil.stat2Paths(fs.listStatus(dir)); // sort names, so that hash partitioning works Arrays.sort(names); MapFile.Reader[] parts = new MapFile.Reader[names.length]; for (int i = 0; i < names.length; i++) { parts[i] = new MapFile.Reader(fs, names[i].toString(), conf); } return parts; } /** Get an entry from output generated by this class. */ public static <K extends WritableComparable<?>, V extends Writable> Writable getEntry(MapFile.Reader[] readers, Partitioner<K, V> partitioner, K key, V value) throws IOException { int part = partitioner.getPartition(key, value, readers.length); return readers[part].get(key, value); } }
Also you can refer to the MapReduce JIRA ticket: https://issues.apache.org/jira/browse/MAPREDUCE-4158 which is assigned to Tom White.
相关推荐
在探讨Hadoop1.x与Hadoop2.x配置的异同之前,我们首先简要回顾一下GridGain In-Memory HDFS的特性,这是基于行业首个高性能双模式内存文件系统,完全兼容HDFS。GridGain FileSystem(GGFS)作为Hadoop HDFS的即插即...
理清Hadoop1.x与Hadoop2.x区别,对比分析。 Hadoop是大数据惊世之作,必学的东西,需要知道: 它由哪些部分组成? 各自的作用是什么? 如果工作的?
Hadoop 3.x(HDFS)----【HDFS 的 API 操作】---- 代码 Hadoop 3.x(HDFS)----【HDFS 的 API 操作】---- 代码 Hadoop 3.x(HDFS)----【HDFS 的 API 操作】---- 代码 Hadoop 3.x(HDFS)----【HDFS 的 API 操作】--...
1. **多名称节点(Multi-Namenode)**:Hadoop 3.x引入了活性名称节点(Active NN)和热备份名称节点(Standby NN)的架构,提高了名称节点的可用性和容错性,减少了单点故障的风险。 2. **更大块大小**:Hadoop 3....
Hadoop3.x系统文档深入地介绍了Hadoop 3.x版本的新特性和配置方法。Hadoop作为一个开源框架,允许使用简单的编程模型跨计算机集群存储和处理大数据。它被广泛用于数据仓库和大规模数据集的应用程序,特别是用于处理...
标题“win32win64hadoop2.7.x.hadoop.dll.bin”暗示了这是一个与Hadoop 2.7.x版本相关的二进制文件,适用于32位和64位的Windows操作系统。描述中提到,这些文件是用于在Windows环境下部署Hadoop时必需的组件,并且在...
Hadoop是大数据技术中最重要的框架之一,是学习大数据必备的第一课,在Hadoop平台之上,可以更容易地开发和运行其他处理大规模数据的框架。尚硅谷Hadoop视频教程再次重磅升级!以企业实际生产环境为背景,增加了更...
1.Hadoop3.x通过什么方式来容错? 2.Hadoop3.x存储开销减少了多少? 3.Hadoop3.x MR API是否兼容hadoop1.x? 一、目的 在这篇文章中,我们将讨论Hadoop 2.x与Hadoop 3.x之间的比较。 Hadoop3版本中添加了哪些新功能...
这个版本特别针对Hadoop 3.x进行了优化,使得它能够充分利用Hadoop生态系统中的新特性和性能改进。在本文中,我们将深入探讨Spark 3.3.3与Hadoop 3.x的集成,以及它们在大数据处理领域的关键知识点。 首先,Spark的...
**Hadoop 2.x 入门指南** Hadoop 2.x 是一个开源的分布式计算框架,它是Apache Hadoop项目的最新版本,旨在提供高效、可扩展的数据处理能力。这个版本引入了若干关键改进,使得Hadoop更适合大数据处理的需求,提高...
hadoop2.x 介绍,及对比hadoop1.x的区别。hadoop2.x的新特性的详细介绍。
hadoop1.x环境搭建及其入门,如需获取更多hadoop资源
【标题】"hadoop3.x带snappy(可用于windows本地开发)"所涉及的知识点主要集中在Hadoop 3.0版本以及Snappy压缩算法在Windows环境下的应用。Hadoop是一个开源的大数据处理框架,由Apache软件基金会开发,它使得在...
Hadoop 2.X HDFS源码剖析-高清-完整目录-2016年3月,分享给所有需要的人!
Hadoop 3.x 笔记 Hadoop 是一个基于分布式存储的大数据处理框架,本文档将详细介绍 Hadoop 3.x 的配置和底层原理,从零搭建集群以及解决遇到的问题,通过图形化的方式更好地理解 Hadoop 的作用。 一、HDFS 组成 ...
### Hadoop 2.x 入门知识点概览 #### 一、大数据应用发展前景 随着信息技术的飞速发展,数据量呈爆炸式增长,这不仅带来了挑战也孕育着新的机遇。根据2015年中国(深圳)IT领袖峰会的讨论,大数据正逐渐成为推动...
在Hadoop生态系统中,`winutils.exe` 和 `hadoop.dll` 是两个关键的组件,主要用于Windows环境下运行Hadoop。由于Hadoop最初是为Linux设计的,因此在Windows上使用时需要这些特定的二进制文件来模拟某些Unix/Linux...
Hadoop 3.x(MapReduce)----【Hadoop 序列化】---- 代码 Hadoop 3.x(MapReduce)----【Hadoop 序列化】---- 代码 Hadoop 3.x(MapReduce)----【Hadoop 序列化】---- 代码 Hadoop 3.x(MapReduce)----【Hadoop ...
Hadoop 2.x Administration Cookbook 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除