Some personal understanding of Hadoop MapReduce Programming

Source: Internet
Author: User
Tags hadoop mapreduce

The first to implement MapReduce is to rewrite two functions, one is map and the other is reduce
map(key ,value)The map function has two parameters, one is key, one is value
If your input type is Textinputformat (default), then the input of your map function will be:

  • Key: The offset of the file (that is, the values in the location of the file)
  • Value: This is a line of string (Hadoop takes each line of the file as input)

Hadoop executes the map function for each row, and the map function does this by splitting it into one of the functions you want to implement (such as WordCount) (Key,value)

(The wordcount is the key= Word, value=1)

Next, Hadoop aggregates all of the key,value, and it merges all keys with the same key, and value is a list, creating a new (key,values) and sending this to the reduce function.

reduce(key,value)The reduce function also has two parameters, one is key, and the other is value
Usually this value is a list,
The function to be implemented by the reduce function is to perform operations on one of the groups (Key,value) According to the function you want to implement.

(WordCount, then your key will be a word, and the value of the list of each item is 1, just calculate how many 1, then know the frequency of the word is how much.)

Some personal understanding of Hadoop MapReduce Programming

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.