mongodb的mapreduce




The working principle of mongodb's mapreduce
: 1. There is a procedure call to get all the collections that meet the conditions (there is no strip is the complete collection), and the MAP function is called for each collection, and the result is put into a Key-valueList pair returned by Map , the value of the same key is placed in the valueList of the same key, after traversing all the collections, call the reduce (also a for loop) function with this Key-valueList as a parameter, and finally reduce outputs the result of the key-value, the process Call it and then output the final result list to return the result.
2.Map: Generate new key-value pairs according to conditions.
3.Reduce: Receive the result of Map or other Reduce, and then perform calculation to become a new key-value pair until the final output result.
4. MapReduceOptions can specify to output the result to the mongo database, or it can be used as the data source of the next group of mapreduce.


Reference (quick example to learn mongodb's mapreduce): http://jackyrong.iteye.com/blog/1408548
Reference (using MapReduce in MongoDB): http://www.open-open.com/lib/view/open1394002780318. html
reference (MapReduceOptions): http://blog.csdn.net/ruishenh/article/details/12842331

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326766378&siteId=291194637