Key code points of Hadoopskipmode

Source: Internet
Author: User
If the Hadoop dataset contains data of different specifications or some data may cause program crash, you can set the Skip mode. The program code does not handle these exceptions and throws the exception to cause the program to crash, the hadoop framework re-executes the program and skips the record. But no code example is provided here.

If the Hadoop dataset contains data of different specifications or some data may cause program crash, you can set the Skip mode. The program code does not handle these exceptions and throws the exception to cause the program to crash, the hadoop framework re-executes the program and skips the record, see http://hadoop.apache.org/common/docs/current/mapred_tutorial.html#Skipping+Bad+Records. However, no code example is provided here. I have tried several times and cannot work properly. After some troubleshooting, I finally confirmed the code mode that can work normally.

The following is a piece of code that can work:

Public class PwdSorter extends ConfiguredIMplements Tool {

......

Public int run (String [] args) throws Exception {

SkipBadRecords.SetMapperMaxSkipRecords(GetConf (), 5 );

JobConf jobConf = new JobConf (getConf (), getClass ());

......

}

Public static void main (String [] args) throws Exception {

Int res = ToolRunner.Run(New PwdSorter (), args );

System.Exit(Res );

}

}

The key point is SkipBadRecords.SetMapperMaxSkipRecordsBefore new JobConf. If the order of the two statements is reversed, the skip mode cannot work normally ., The default error data is recorded in the output/_ logs/skip directory. The storage format is sequence file.

In addition, if the new API, org. hadoop. mapreduce package, does not contain the SkipBadRecords class, mapred. SkipBadRecords can also be used to skip recording. (Fixed: I tried again later. The new API Skip mode failed and may still not work properly. It was recorded as incorrect .)

For more information about Hadoop, see Hadoop topic page http://www.linuxidc.com/topicnews.aspx? Tid = 13

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.