The Setup method and cleanup method in Mapper class/reducer class and the introduction of the Run method

Source: Internet
Author: User

In the source code of Hadoop, the base class Mapper class and the Reducer class contain only four methods: The Setup method, the cleanup method, the Run method, and the map method. As shown below:

The method is called in the Run method, as follows:

As you can see, the above three methods are called in the Run Method: The Setup method, the map method, and the cleanup method. The Setup method and the cleanup method do not do anything by default, and they are executed only once. However, the Setup method usually performs some preparatory work before the map function, such as some configuration information of the job, etc., the cleanup method is executed after the map method is run, and the method is to complete some end cleanup tasks, such as: resource release, etc. If you need to do some configuration and cleanup work, you need to rewrite the mapper/reducer subclasses to implement the appropriate functionality. The map method is re-implemented in the corresponding subclass, which is our custom map method. This method is inside a while loop, indicating that the method is executed many times. The Run method is the method that each maptask invokes.

The Setup method and cleanup method in Mapper class/reducer class and the introduction of the Run method

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.