"Go" mapreduce read Lzo file

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.