1.单输出格局

指定输出格局ParquetInputFormat

//指定输出格局job.setInputFormatClass(ParquetInputFormat.class);ParquetInputFormat.addInputPath(job, new Path(args[1]));ParquetInputFormat.setReadSupportClass(job, CheckLevelRunner.MyReadSupport.class);//这个提供的是定义读文件的形式public static final class MyReadSupport extends DelegatingReadSupport<Group> {    public MyReadSupport() {        super(new GroupReadSupport());    }    @Override    public org.apache.parquet.hadoop.api.ReadSupport.ReadContext init(InitContext context) {        return super.init(context);    }}

解析Parquet遇到空文件的状况:

此时能够设置mapreduce容错参数:
Mapreduce.map.failures.maxpercent:这个参数示意当Map Task失败比例超过该值,则整个作业失败,默认值为0。在这里设置成5,在这里map的数量与输出文件数量统一,因而如果空文件的数量小于5%,则工作会胜利,大于5%,工作失败。

job.getConfiguration().set("mapreduce.map.failures.maxpercent", "5");

2.多输出格局

其中一个目录的文件格式是Text,另一个是Parquet。应用MultipleInputs依据输出源设置多个map来解决数据。

//设置多输出、多mapperMultipleInputs.addInputPath(job, new Path(path1), TextInputFormat.class, NormalMap.class);MultipleInputs.addInputPath(job, new Path(path2), ParquetInputFormat.class, ParquetMap.class);ParquetInputFormat.setReadSupportClass(job, CheckLevelRunner.MyReadSupport.class);

3.mapreduce中调用http接口遇到的问题

将程序部署服务器上,发现会报这个错:
Exception in thread "main" java.lang.NoSuchFieldError: INSTANCE,
考察发现,是因为httpclient有两个版本,本人引入了4的版本,而org.apache.hadoop这个包中蕴含了httpclient3.1的版本,两个版本抵触,最初去掉了本人引入的版本,应用了hadoop包中3.1的httpclient。