Using Mrunit to test mapper and reducer

Source: Internet
Author: User

Mrunit can take less time and can test mapper and reducer separately

Steps:

1, the use of Mrunit test mapper and Reducer

2, the implementation of the MapReduce code localization test

3. Using Hadoop logs

4. Track execution metrics by counter

The process of testing mapper

1, instantiate the Mapdirver class, as the test mapper is parameterized

2. Call the Withmapper method to add the mapper instance you want to test

3, according to the situation select Withconfiguration Method Set Mapper configuration file

4. Call the Withinput method to pass the required key and value

5. Set the desired output by calling the Withoutput method

6, call the function Rantest method to pass the input value of the set to Mapper

The process of testing reducer

1. First create a list of Intwritable objects to be used as reducer input

2. Instantiating Reducedriver objects

3. Call the Withreduce method to set the reducer instance to be tested

4, through the withconfiguration to pass the desired configuration

5. Call the Withinput method to pass the input value to reducer

6. Call the Withoutput method to set the desired reducer output

7. Finally call the Runtest method and pass the input of the setting to the reducer

Using Mrunit to test mapper and reducer

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.