代码改变世界

hadoop mapreduce lzo

2016-01-07 18:38  【戈多】  阅读(291)  评论(0编辑  收藏  举报
import com.hadoop.compression.lzo.LzoIndexer;
import com.hadoop.compression.lzo.LzopCodec;

FileOutputFormat. setCompressOutput( job, true); // 设置压缩
FileOutputFormat. setOutputCompressorClass( job, LzopCodec.class ); // 选择压缩类型

result = job .waitForCompletion( true) ? 0 : -1;

// 输出路径 生成索引
LzoIndexer lzoIndexer = new LzoIndexer(getConf());
lzoIndexer.index( new Path( args[1]));

生成lzo文件 并生成索引

 

job.setInputFormatClass(LzoTextInputFormat.class);

读取lzo类型的文件