Configuration conf=new Configuration();
//map结果压缩
conf.setBoolean("mapred.compress.map.output", true);
conf.setClass("mapred.output.compression.codec", GzipCodec.class, CompressionCodec.class);
Job job=new Job(conf,"ufoshapestimes");
job.setJarByClass(Run.class);
job.setMapperClass(ShapeTimeMapper.class);
job.setReducerClass(ShapeTimeReducer.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(Text.class);
FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
//reduce结果压缩
FileOutputFormat.setCompressOutput(job, true);
FileOutputFormat.setOutputCompressorClass(job, GzipCodec.class);
System.exit(job.waitForCompletion(true)?1:0);
Hadoop学习笔记--对输出文件进行压缩
最新推荐文章于 2022-10-16 22:27:43 发布