Mongodb--mapreduce Distribution Statistics S

Source: Internet
Author: User
Tags emit

MapReduce

Mapreduce: The set of targets to manipulate
Map : Map function (generate key-value pair sequence as reduce function parameter)//incoming group key and value to be counted
Reduce: Statistical functions//Format the returned Parameter object
Query: Target record filtering//Before MP filter criteria for the query
Sort : Target record sorting
limit: Limits the number of target records
Out : The statistics result holds the collection (does not specify the use temporary collection, after the client disconnects automatically deletes)//outputs the result in a table
keeptemp: Whether to keep temporary collections
Finalize: Final processing function (save result set after final collation of reduce return result)//result processing
Scope: Import external variables to map, reduce, finalize

Verbose: Displays detailed time statistics.



Data structure :



Db.runcommand ({mapreduce: "Students", map:function () {emit (This.classid,this.name);},reduce:function (key,values) { var res={classid:key,names:values} return res;},query:{"age": {"$GT": Ten}}, Finalize:function (key,reducevalues) {var Obj={};obj.keyname=key;obj.values=reducevalues.names;return obj;},out: "TEST_MP2"})





Db.runcommand ({mapreduce: "Students", map:function () {emit (This.classid,this.name);},reduce:function (key,values) { return values.length;},query:{"age": {"$gt": 10}},out: "TEST_MP2"})



For the second statistic step:

Mongodb--mapreduce Distribution Statistics S

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.