--
--
--
--
--
--
--
--
You received this message because you are subscribed to the Google Groups "ReactiveMongo - http://reactivemongo.org" group.
To unsubscribe from this group and stop receiving emails from it, send an email to reactivemong...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "ReactiveMongo - http://reactivemongo.org" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/reactivemongo/agmPCHE8kOE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to reactivemong...@googlegroups.com.
You received this message because you are subscribed to a topic in the Google Groups "ReactiveMongo - http://reactivemongo.org" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/reactivemongo/agmPCHE8kOE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to reactivemong...@googlegroups.com.
Here's an example we useprotected def collectionName: String = "client"val mapStdDev ="""|function map() {| emit(1, // Or put a GROUP BY key here| {sum: NumberInt(this.metaData.activityTotal), // the field you want stats for| min: NumberInt(this.metaData.activityTotal),| max: NumberInt(this.metaData.activityTotal),| count:1,| diff: 0, // M2,n: sum((val-mean)^2)| });|}""".stripMargindef mapStdDevApi(api: String) =s"""|function map() {| emit(1, // Or put a GROUP BY key here| {sum: NumberInt(this.metaData.${api}Activity), // the field you want stats for| min: NumberInt(this.metaData.${api}Activity),| max: NumberInt(this.metaData.${api}Activity),| count:1,| diff: 0, // M2,n: sum((val-mean)^2)| });|}""".stripMarginval reduceStdDev ="""|function reduce(key, values) {| var a = values[0]; // will reduce into here| for (var i=1/*!*/; i < values.length; i++){| var b = values[i]; // will merge 'b' into 'a'||| // temp helpers| var delta = a.sum/a.count - b.sum/b.count; // a.mean - b.mean| var weight = (a.count * b.count)/(a.count + b.count);|| // do the reducing| a.diff += b.diff + delta*delta*weight;| a.sum += b.sum;| a.count += b.count;| a.min = Math.min(a.min, b.min);| a.max = Math.max(a.max, b.max);| }|| return a;|}|""".stripMargindef standardDeviationActivityByApi(clientId: String, api: String): Future[(Double, Double)] = {val mapReduceCommand = BSONDocument("mapreduce" -> BSONString("locations"),"map" -> BSONJavaScript(mapStdDevApi(api)),"reduce" -> BSONJavaScript(reduceStdDev),"finalize" -> BSONJavaScript(finalizeStdDev),"query" -> BSONDocument("clientRefId" -> clientId),"out" -> BSONDocument("inline" -> "1"))db.command(RawCommand(mapReduceCommand)).map(doc => {val d = BSONDocumentIdentity.write(doc)val value = d.getAs[BSONArray]("results").get.getAs[BSONDocument](0).getOrElse(BSONDocument()).getAs[BSONDocument]("value").getOrElse(BSONDocument())(value.getAs[Double]("avg").getOrElse(0.0), value.getAs[Double]("stddev").getOrElse(0.0))})}
--
...
I am very excited to introduce ReactiveMongo, a brand new Scala driver
for MongoDB. More than just non-blocking, it's a reactive driver that
allows you to design very scalable applications unleashing MongoDB
capabilities like streaming infinite live collections and files for
modern real-time Web applications.
With ReactiveMongo, you can build highly scalable web applications,
making heavy usage of streaming capabilities like streaming files from
and into MongoDB (GridFS), or tail a collection through a websocket.
Possibilities are endless!
You can read the complete announce here:
http://stephane.godbillon.com/2012/08/30/reactivemongo-for-scala-unleashing-mongodb-streaming-capabilities-for-realtime-web
. Checkout the driver repository on