2015 Byron Ellis - Real-Time Analytics by Techniques to Analyze & Visualize Streaming Data Rbl
Author:Techniques to Analyze & Visualize Streaming Data Rbl [Analyze, Techniques to & Rbl, Visualize Streaming Data]
Language: eng
Format: epub, azw3
ISBN: 2147483648
Publisher: Wiley
Published: 2015-10-10T19:49:09+00:00
Like SQL databases, MongoDB also offers facilities for grouping and aggregating data in queries. The original facility for aggregation was either the group() or mapReduce() commands, but versions of MongoDB after 2.2 also support an optimized aggregate() command.
Unlike SQL, the pipeline command uses a pipeline approach for computing its results, taking an array of filtering and grouping commands used to reach a final result. This is easiest to understand in action, so first build a collection with some example data:
> abc = ['A','B','C','D','E','F','G','H','I','J','K','L', 'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']; > db.createCollection("aggtest"); > for(var i=0;i<1000;i++) { ... db.aggtest.insert({ ... first:abc[Math.floor(Math.random()*abc.length)], ... second:abc[Math.floor(Math.random()*abc.length)], ... count:Math.floor(1000*Math.random()) ... }); ... } > db.aggtest.find({}) { "_id" : ObjectId("53213bc8ae5fcad63d0563e9"), "first" : "S", "second" : "W", "count" : 762 } { "_id" : ObjectId("53213bc8ae5fcad63d0563ea"), "first" : "E", "second" : "V", "count" : 381 } { "_id" : ObjectId("53213bc8ae5fcad63d0563eb"), "first" : "Q", "second" : "O", "count" : 143 } { "_id" : ObjectId("53213bc8ae5fcad63d0563ec"), "first" : "C", "second" : "I", "count" : 601 } { "_id" : ObjectId("53213bc8ae5fcad63d0563ed"), "first" : "B", "second" : "C", "count" : 413 } { "_id" : ObjectId("53213bc8ae5fcad63d0563ee"), "first" : "M", "second" : "D", "count" : 790 } { "_id" : ObjectId("53213bc8ae5fcad63d0563ef"), "first" : "S", "second" : "Q", "count" : 699 } { "_id" : ObjectId("53213bc8ae5fcad63d0563f0"), "first" : "A", "second" : "M", "count" : 615 } ... other output omitted Type "it" for more
The first stage of an aggregation pipeline is usually a filtering step that acts like the WHERE clause of a SQL statement. It is identified by a $match statement, as in this example, which selects all of the elements with the “A” as their value for the “first” element:
> db.aggtest.aggregate([{$match:{first:"A"}}]); { "result" : [ { "_id" : ObjectId("53213bc8ae5fcad63d0563f0"), "first" : "A", "second" : "M", "count" : 615 }, { "_id" : ObjectId("53213bc8ae5fcad63d0563f4"), "first" : "A", "second" : "F", "count" : 806 }, { "_id" : ObjectId("53213bc8ae5fcad63d056402"), "first" : "A", "second" : "Q", "count" : 377 }, ...more content omitted... { "_id" : ObjectId("53213bc9ae5fcad63d0567c5"), "first" : "A", "second" : "G", "count" : 769 } ], "ok" : 1 }
Other filtering options are $limit and $skip. Mostly used for testing as an initial filter, the $limit filter restricts the number of elements entering the aggregation, as in this example:
> db.aggtest.aggregate([{$limit:1}]); { "result" : [ { "_id" : ObjectId("53213bc8ae5fcad63d0563e9"), "first" : "S", "second" : "W", "count" : 762 } ], "ok" : 1 }
The $limit command is more typically used after a grouping and sorting operation to limit the output to the user. Similarly, the $skip command will ignore some number of documents entering the filter. Combined with $limit, it is often used after grouping, as well as to implement pagination:
> db.aggtest.aggregate([{$skip:10},{$limit:1}]); { "result" : [ { "_id" : ObjectId("53213bc8ae5fcad63d0563f3"), "first" : "M", "second" : "E", "count" : 437 } ], "ok" : 1 }
After filtering commands are applied in the pipeline, group management commands are applied. The most commonly used command is the $group operator, which specifies an identifier field and some number of accumulators. For example, to sum
Download
2015 Byron Ellis - Real-Time Analytics by Techniques to Analyze & Visualize Streaming Data Rbl.azw3
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
What's Done in Darkness by Kayla Perrin(26304)
Shot Through the Heart: DI Grace Fisher 2 by Isabelle Grey(18832)
Shot Through the Heart by Mercy Celeste(18710)
The Fifty Shades Trilogy & Grey by E L James(18642)
The Subtle Art of Not Giving a F*ck by Mark Manson(13955)
The 3rd Cycle of the Betrayed Series Collection: Extremely Controversial Historical Thrillers (Betrayed Series Boxed set) by McCray Carolyn(13882)
Stepbrother Stories 2 - 21 Taboo Story Collection (Brother Sister Stepbrother Stepsister Taboo Pseudo Incest Family Virgin Creampie Pregnant Forced Pregnancy Breeding) by Roxi Harding(12888)
Scorched Earth by Nick Kyme(12535)
Drei Generationen auf dem Jakobsweg by Stein Pia(10763)
Suna by Ziefle Pia(10700)
Scythe by Neal Shusterman(10061)
International Relations from the Global South; Worlds of Difference; First Edition by Arlene B. Tickner & Karen Smith(9312)
Successful Proposal Strategies for Small Businesses: Using Knowledge Management ot Win Govenment, Private Sector, and International Contracts 3rd Edition by Robert Frey(9127)
This is Going to Hurt by Adam Kay(8780)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 10 by Isuna Hasekura and Jyuu Ayakura(7619)
Wolf & Parchment: New Theory Spice & Wolf, Vol. 03 by Isuna Hasekura and Jyuu Ayakura & Jyuu Ayakura(7582)
Python GUI Applications using PyQt5 : The hands-on guide to build apps with Python by Verdugo Leire(7570)
Peren F. Statistics for Business and Economics...Essential Formulas 3ed 2025 by Unknown(7519)
Dirty Filthy Fix: A Fixed Trilogy Novella by Laurelin Paige(7423)
