1. Read Lzo file
You need to add the following code and import the Lzo related jar package
Job.setinputformatclass (Lzotextinputformat.class);
2. Write Lzo file
Lzo format is not supported by default splitable, you need to add an index file for it to support multiple map parallel to the Lzo file processing
If you want the reduce output to be a Lzo formatted file, add the following statement
Fileoutputformat.setcompressoutput (Job, true);
Fileoutputformat.setoutputcompressorclass (Job, Lzopcodec.class);
int result = Job.waitforcompletion (true)? 0:1;
After execution of the above statement, the final output file is generated, and the index of the lzo needs to be added on this basis
Lzoindexer lzoindexer = new Lzoindexer (conf);
Lzoindexer.index (New Path (args[1]));
If the Lzo file already exists, but no index is added, you can add the Lzo index to the file on the input path using the following method
Hadoop jar $HADOOP _home/lib/hadoop-lzo-0.4.17.jar com.hadoop.compression.lzo.LzoIndexer Hdf://inputpath
Or
Hadoop jar $HADOOP _home/lib/hadoop-lzo-0.4.17.jar com.hadoop.compression.lzo.DistributedLzoIndexe Hdf://inputpath
"Turn from" http://blog.csdn.net/wisgood/article/details/17080361
"Go" mapreduce read Lzo file