MongoDB Aggregation of MapReduce

Source: Internet
Author: User
Understanding Aggregations

In a relational database, aggregation is the merging of data records based on a field in the data record. For example, the amount of each order needs to be counted from the order schedule, usually following several steps:

  • Extract the order number and amount of each record from the order schedule;
  • Group the amount according to the order number so that each group amount has the same order number;
  • Sums the sum of each group of amounts, returning the result in the form of the order number-total amount;
Understanding MapReduce

In MapReduce, the map function does include the first two steps of the process, where the emit function is responsible for the implementation of step one. The result of the map function is more than one Key-values collection, Note: Here a key corresponds to multiple values, that is, one of the preceding order numbers corresponds to multiple amounts.

  Next, the return value of map is used as the parameter of the reduce function, which is combined by reduce for each set of data, that is, the third step of the above process is summed.

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.