Some suggestions on optimization of Hadoop program

Source: Internet
Author: User
Tags hadoop mapreduce

I recently discovered in the process of writing code that some of the operations of the Hadoop MapReduce program are time-consuming and can make the program run 1 faster. I don't know if you've ever used that Partioner, this class can help us to export our data to the specified file in a custom way, such as: PRI vate static map<string, Integer > provider_map= new hashmap<string,integer> (), Static {Provider_map.put (" 135 ", 3);p rovider_map.put (" 136 ", 3);p Rovider_map.put (" 137 ", 1);p rovider_map.put (" 182 ", 1);p rovider_map.put (" 183 ", 1 );p Rovider_map.put ("2");p Rovider_map.put ("159", 2);p rovider_map.put ("150", 2);} public int getpartition (Text key, Databean value, int. numpartitions) {//TODO auto-generated method stubstring account = k Ey.tostring (); String str_num = account.substring (0, 3), Integer in = Provider_map.get (Str_num), if (in = = null) {in = 0;} return in;} This code is an example of an excerpt, defined in front of a few phone numbers: part of the corresponding 1, a portion corresponding to 2 and so on. In this case, the output of the reduce end will be automatically based on the value of the returned data in the corresponding document, such as part-000000/part-000001 then by what way can achieve this effect, partitioner after the end, will be sorted according to the return value of the same value of the data in one piece, a buffer will put a few different values of the data part, the allocation of the task of reduce the buffer to find its own corresponding number of data obtained in the cache of reduce to be sorted and processed. Here I would like to say, maybe your program does not need this step to separate file operation, then try not to use this partitioner, because this I use the process ofIt's really time-consuming, but it's necessary to say that your program needs this to complete your logic, but also to be prepared for a long time. 2.Combiner: Executes on the map side, performs a subtotal of the data, and then delivers the data to reduce, reducing the pressure on reduce to achieve efficiency gains. Combiner: If his function is consistent with the function of reduce, then it should be said to be feasible, because combiner to achieve pluggable, that is to say I have this combiner and no this combiner should be the same result. However, there are some such, through the combiner to achieve their business logic, and so on, so it is not pluggable, such as the filtering of data. For example, the word statistics of the program of Hadoop friends should have learned that at the end of the map end, will generate key values such as 

Some suggestions on optimization of Hadoop program

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.