Home > Database > Mysql Tutorial > mongodb mapreduce小试

mongodb mapreduce小试

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:56:40
Original
971 people have browsed it

最近由于产品业务的需求,需要使用一些数据量比较相对有点大的计算,顺便试试mongodb的mapreduce功能,感觉还不错 下面是官方提供的一个例子: $ ./ mongo db.things.insert( { _id : , ] } ); db.things.insert( { _id : ] } ); db.things.insert( { _id :

最近由于产品业务的需求,虚拟主机,香港服务器,需要使用一些数据量比较相对有点大的计算,香港虚拟主机,顺便试试mongodb的mapreduce功能,感觉还不错

 

下面是官方提供的一个例子:

$ ./mongo > db.things.insert( { _id : , ] } ); > db.things.insert( { _id : ] } ); > db.things.insert( { _id : , , ] } ); > db.things.insert( { _id : 4, tags : [] } ); > // map function > m = function(){ ... this.tags.forEach( ... function(z){ ... emit( z , { count : 1 } ); ... } ... ); ...}; > // reduce function > r = function( key , values ){ ... var total = 0; ... for ( var i=0; i ) ... total += values[i].count; ... return { count : total }; ...}; > res = db.things.mapReduce(m,r); > res {: : , : : : : 0} > db[res.result].find() {: , : {: 3}} {: , : {: 2}} {: , : {: 1}} > db[res.result].drop()

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
mongodb start
From 1970-01-01 08:00:00
0
0
0
linux - ubuntu14 error installing mongodb
From 1970-01-01 08:00:00
0
0
0
Use of symfony2 mongodb
From 1970-01-01 08:00:00
0
0
0
mongodb _id rename
From 1970-01-01 08:00:00
0
0
0
Parameter understanding of mongodb
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template