com presentations: MongoDB Stockholm aggregation talk.: mongo-aggregation-stockholm13.xml slides/mongodb/aggr-aggr-framework-img.xml
slides/mongodb/aggr-aggr-framework.xml slides/mongodb/aggr-collection.xml slides/mongodb/aggr-combined-section.xml
slides/mongodb/aggr-data-warehousing-img.xml slides/mongodb/aggr-database-cmd.xml slides/mongodb/aggr-enabling-devs.xml
slides/mongodb/aggr-fw-extending.xml slides/mongodb/aggr-fw-future.xml slides/mong

From: Date: Mon, 22 Apr 2013 13:58:18 +0000
Subject: com presentations: MongoDB Stockholm aggregation talk.: mongo-aggregation-stockholm13.xml slides/mongodb/aggr-aggr-framework-img.xml
slides/mongodb/aggr-aggr-framework.xml slides/mongodb/aggr-collection.xml slides/mongodb/aggr-combined-section.xml
slides/mongodb/aggr-data-warehousing-img.xml slides/mongodb/aggr-database-cmd.xml slides/mongodb/aggr-enabling-devs.xml
slides/mongodb/aggr-fw-extending.xml slides/mongodb/aggr-fw-future.xml slides/mong
Groups: php.pres 
Request: Send a blank email to pres+get-1885@lists.php.net to get a copy of this message
Commit: 4ba4c0f232e7bf6a1b4ea2dfd7afbd3b5d32a248 Author: Derick Rethans <github@derickrethans.nl> Mon, 22 Apr 2013 14:58:18 +0100 Parents: c06e3081f6a7c7197de51b50317fc2651cae1ab6 Branches: master Link: http://git.php.net/?p=presentations.git;a=commitdiff;h=4ba4c0f232e7bf6a1b4ea2dfd7afbd3b5d32a248 Log: MongoDB Stockholm aggregation talk. Changed paths: M mongo-aggregation-stockholm13.xml M slides/mongodb/aggr-aggr-framework-img.xml A slides/mongodb/aggr-aggr-framework.xml A slides/mongodb/aggr-collection.xml A slides/mongodb/aggr-combined-section.xml M slides/mongodb/aggr-data-warehousing-img.xml A slides/mongodb/aggr-database-cmd.xml A slides/mongodb/aggr-enabling-devs.xml A slides/mongodb/aggr-fw-extending.xml A slides/mongodb/aggr-fw-future.xml A slides/mongodb/aggr-fw-use-cases.xml A slides/mongodb/aggr-limitations.xml A slides/mongodb/aggr-looking-ahead-section.xml A slides/mongodb/aggr-map-reduce.jpg M slides/mongodb/aggr-mapreduce-img.xml A slides/mongodb/aggr-op-group-collect-example.xml A slides/mongodb/aggr-op-group-compound-example.xml A slides/mongodb/aggr-op-group-sum-count-example.xml A slides/mongodb/aggr-op-group.xml A slides/mongodb/aggr-op-limit-example.xml A slides/mongodb/aggr-op-match-example.xml A slides/mongodb/aggr-op-match-with-query-example.xml A slides/mongodb/aggr-op-match.xml A slides/mongodb/aggr-op-project-create-sub-example.xml A slides/mongodb/aggr-op-project-incl-excl-example.xml A slides/mongodb/aggr-op-project-rename-compute-example.xml A slides/mongodb/aggr-op-project.xml A slides/mongodb/aggr-op-skip-example.xml A slides/mongodb/aggr-op-sort-example.xml A slides/mongodb/aggr-op-sort-limit-skip-example.xml A slides/mongodb/aggr-op-sort-skip-limit.xml A slides/mongodb/aggr-op-unwind-example.xml A slides/mongodb/aggr-op-unwind.xml A slides/mongodb/aggr-our-example-data.xml A slides/mongodb/aggr-pipeline-section.xml A slides/mongodb/aggr-pipeline.xml A slides/mongodb/aggr-pipelines-ops.xml A slides/mongodb/aggr-shard.png A slides/mongodb/aggr-sharding-example1.xml A slides/mongodb/aggr-sharding-example2.xml A slides/mongodb/aggr-sharding-section.xml A slides/mongodb/aggr-sharding.xml A slides/mongodb/aggr-usage-and-limitations-section.xml A slides/mongodb/aggr-usage.xml A slides/mongodb/aggregation-framework.jpg A slides/mongodb/datawarehousing.jpg

diff --git a/mongo-aggregation-stockholm13.xml b/mongo-aggregation-stockholm13.xml index 4ab47b1..e602bbb 100644 --- a/mongo-aggregation-stockholm13.xml +++ b/mongo-aggregation-stockholm13.xml @@ -35,15 +35,16 @@ <slide>slides/mongodb/aggr-op-project-rename-compute-example.xml</slide> <slide>slides/mongodb/aggr-op-project-create-sub-example.xml</slide> <slide>slides/mongodb/aggr-op-group.xml</slide> -<slide>slides/mongodb/aggr-op-group-calc-avg-example.xml</slide> <slide>slides/mongodb/aggr-op-group-sum-count-example.xml</slide> <slide>slides/mongodb/aggr-op-group-collect-example.xml</slide> +<slide>slides/mongodb/aggr-op-group-compound-example.xml</slide> <slide>slides/mongodb/aggr-op-unwind.xml</slide> <slide>slides/mongodb/aggr-op-unwind-example.xml</slide> <slide>slides/mongodb/aggr-op-sort-skip-limit.xml</slide> <slide>slides/mongodb/aggr-op-sort-example.xml</slide> <slide>slides/mongodb/aggr-op-limit-example.xml</slide> <slide>slides/mongodb/aggr-op-skip-example.xml</slide> +<slide>slides/mongodb/aggr-op-sort-limit-skip-example.xml</slide> <slide>slides/mongodb/aggr-usage-and-limitations-section.xml</slide> <slide>slides/mongodb/aggr-usage.xml</slide> @@ -55,7 +56,7 @@ <slide>slides/mongodb/aggr-sharding.xml</slide> <slide>slides/mongodb/aggr-sharding-example1.xml</slide> <slide>slides/mongodb/aggr-sharding-example2.xml</slide> - +<!-- <slide>slides/mongodb/aggr-expressions-section.xml</slide> <slide>slides/mongodb/aggr-expressions.xml</slide> <slide>slides/mongodb/aggr-expr-boolean.xml</slide> @@ -64,7 +65,7 @@ <slide>slides/mongodb/aggr-expr-string.xml</slide> <slide>slides/mongodb/aggr-expr-date.xml</slide> <slide>slides/mongodb/aggr-expr-conditional.xml</slide> - +--> <slide>slides/mongodb/aggr-looking-ahead-section.xml</slide> <slide>slides/mongodb/aggr-fw-use-cases.xml</slide> <slide>slides/mongodb/aggr-fw-extending.xml</slide> diff --git a/slides/mongodb/aggr-aggr-framework-img.xml b/slides/mongodb/aggr-aggr-framework-img.xml index 150d885..91a71ca 100644 --- a/slides/mongodb/aggr-aggr-framework-img.xml +++ b/slides/mongodb/aggr-aggr-framework-img.xml @@ -1,7 +1,7 @@ <slide> <title>&#160;</title> -<image filename="aggregation-framework.png"/> +<image filename="aggregation-framework.jpg"/> <blurb align="center">Aggregation Framework</blurb> </slide> diff --git a/slides/mongodb/aggr-aggr-framework.xml b/slides/mongodb/aggr-aggr-framework.xml new file mode 100644 index 0000000..241143b --- /dev/null +++ b/slides/mongodb/aggr-aggr-framework.xml @@ -0,0 +1,14 @@ +<slide> +<title>Aggregation Framework</title> + +<list> + <bullet>Declared in JSON, executes in C++</bullet> + <bullet>Flexible, functional, and *simple* + <list> + <bullet>Operation pipeline</bullet> + <bullet>Computational expressions</bullet> + </list> + </bullet> + <bullet>Plays nice with sharding</bullet> +</list> +</slide> diff --git a/slides/mongodb/aggr-collection.xml b/slides/mongodb/aggr-collection.xml new file mode 100644 index 0000000..19c8836 --- /dev/null +++ b/slides/mongodb/aggr-collection.xml @@ -0,0 +1,31 @@ +<slide> +<title>Collection Method</title> + +<example inline="3"> +db.poi.aggregate( [ + { $match: { 'tags.amenity': 'restaurant' } }, + { $skip: 100 }, + { $limit: 1 } +] } +</example> + +<blurb>Result:</blurb> + +<example inline="3"> +{ + "result" : [ + { + "_id" : "n272078075", + "type" : NumberLong(1), + "tags" : { + "amenity" : "restaurant", + "cuisine" : "turkish", + "name" : "Cyprus Mangal" + } + }, + ], + "ok" : 1 +} +</example> + +</slide> diff --git a/slides/mongodb/aggr-combined-section.xml b/slides/mongodb/aggr-combined-section.xml new file mode 100644 index 0000000..fc1f7a8 --- /dev/null +++ b/slides/mongodb/aggr-combined-section.xml @@ -0,0 +1,3 @@ +<slide type="section"> +<blurb>Pipeline Example</blurb> +</slide> diff --git a/slides/mongodb/aggr-data-warehousing-img.xml b/slides/mongodb/aggr-data-warehousing-img.xml index 444702a..9a3e04d 100644 --- a/slides/mongodb/aggr-data-warehousing-img.xml +++ b/slides/mongodb/aggr-data-warehousing-img.xml @@ -1,7 +1,7 @@ <slide> <title>&#160;</title> -<image filename="aggr-data-warehousing.png"/> +<image filename="datawarehousing.jpg"/> <blurb align="center">Data Warehousing</blurb> </slide> diff --git a/slides/mongodb/aggr-database-cmd.xml b/slides/mongodb/aggr-database-cmd.xml new file mode 100644 index 0000000..13b9292 --- /dev/null +++ b/slides/mongodb/aggr-database-cmd.xml @@ -0,0 +1,35 @@ +<slide> +<title>Database Command</title> + +<example inline="3"> +db.runCommand({ + aggregate: "poi", + pipeline: [ + [ + { $match: { 'tags.amenity': 'restaurant' } }, + { $skip: 100 }, + { $limit: 1 } + ] +}); +</example> + +<blurb>Result:</blurb> + +<example inline="3"> +{ + "result" : [ + { + "_id" : "n272078075", + "type" : NumberLong(1), + "tags" : { + "amenity" : "restaurant", + "cuisine" : "turkish", + "name" : "Cyprus Mangal" + } + }, + ], + "ok" : 1 +} +</example> + +</slide> diff --git a/slides/mongodb/aggr-enabling-devs.xml b/slides/mongodb/aggr-enabling-devs.xml new file mode 100644 index 0000000..e1fec51 --- /dev/null +++ b/slides/mongodb/aggr-enabling-devs.xml @@ -0,0 +1,14 @@ +<slide> +<title>Enabling Developers</title> + +<list> + <bullet>Doing more within MongoDB, faster</bullet> + <bullet>Refactoring MapReduce and groupings + <list> + <bullet>Replace pages of JavaScript</bullet> + <bullet>Longer aggregation pipelines</bullet> + </list> + </bullet> + <bullet>Quick aggregations from the shell</bullet> +</list> +</slide> diff --git a/slides/mongodb/aggr-fw-extending.xml b/slides/mongodb/aggr-fw-extending.xml new file mode 100644 index 0000000..877772e --- /dev/null +++ b/slides/mongodb/aggr-fw-extending.xml @@ -0,0 +1,13 @@ +<slide> +<title>Extending the Framework</title> + +<list> + <bullet>Adding new pipeline operators, expressions</bullet> + <bullet>$out and $tee for output control + <list> + <bullet>https://jira.mongodb.org/browse/SERVER-3253</bullet> + </list> + </bullet> + <bullet>Cursor support</bullet> +</list> +</slide> diff --git a/slides/mongodb/aggr-fw-future.xml b/slides/mongodb/aggr-fw-future.xml new file mode 100644 index 0000000..233945b --- /dev/null +++ b/slides/mongodb/aggr-fw-future.xml @@ -0,0 +1,14 @@ +<slide> +<title>Future Enhancements</title> + +<list> + <bullet>Automatically move %$match% earlier if possible</bullet> + <bullet>Pipeline explain facility</bullet> + <bullet>Memory usage improvements + <list> + <bullet>Grouping input sorted by _id</bullet> + <bullet>Sorting with limited output</bullet> + </list> + </bullet> +</list> +</slide> diff --git a/slides/mongodb/aggr-fw-use-cases.xml b/slides/mongodb/aggr-fw-use-cases.xml new file mode 100644 index 0000000..e881603 --- /dev/null +++ b/slides/mongodb/aggr-fw-use-cases.xml @@ -0,0 +1,10 @@ +<slide> +<title>Framework Use Cases</title> + +<list> + <bullet>Basic aggregation queries</bullet> + <bullet>Ad-hoc reporting</bullet> + <bullet>Real-time analytics</bullet> + <bullet>Visualizing time series data</bullet> +</list> +</slide> diff --git a/slides/mongodb/aggr-limitations.xml b/slides/mongodb/aggr-limitations.xml new file mode 100644 index 0000000..378aa02 --- /dev/null +++ b/slides/mongodb/aggr-limitations.xml @@ -0,0 +1,18 @@ +<slide> +<title>Limitations</title> + +<list> + <bullet>Result limited by BSON document size + <list> + <bullet>Final command result</bullet> + <bullet>Intermediate shard results</bullet> + </list> + </bullet> + <bullet>Pipeline operator memory limits</bullet> + <bullet>Some BSON types unsupported + <list> + <bullet>Binary, Code, deprecated types</bullet> + </list> + </bullet> +</list> +</slide> diff --git a/slides/mongodb/aggr-looking-ahead-section.xml b/slides/mongodb/aggr-looking-ahead-section.xml new file mode 100644 index 0000000..ee2fbb0 --- /dev/null +++ b/slides/mongodb/aggr-looking-ahead-section.xml @@ -0,0 +1,3 @@ +<slide type="section"> +<blurb>Looking Ahead</blurb> +</slide> diff --git a/slides/mongodb/aggr-map-reduce.jpg b/slides/mongodb/aggr-map-reduce.jpg new file mode 100644 index 0000000..f573863 Binary files /dev/null and b/slides/mongodb/aggr-map-reduce.jpg differ diff --git a/slides/mongodb/aggr-mapreduce-img.xml b/slides/mongodb/aggr-mapreduce-img.xml index c35b81d..be8d4e1 100644 --- a/slides/mongodb/aggr-mapreduce-img.xml +++ b/slides/mongodb/aggr-mapreduce-img.xml @@ -1,7 +1,7 @@ <slide> <title>&#160;</title> -<image filename="mapreduce.png"/> +<image filename="aggr-map-reduce.jpg"/> <blurb align="center">MapReduce</blurb> </slide> diff --git a/slides/mongodb/aggr-op-group-collect-example.xml b/slides/mongodb/aggr-op-group-collect-example.xml new file mode 100644 index 0000000..45d09bd --- /dev/null +++ b/slides/mongodb/aggr-op-group-collect-example.xml @@ -0,0 +1,62 @@ +<slide> +<title>Collecting Distinct Values</title> + +<table class="columns"> +<tr> +<td> +<example inline="3"> +{ + "_id" : "n388320891", + "tags" : { +* "amenity" : "restaurant",* +* "cuisine" : "chinese",* + "name" : "China GaGa" + } +}, +{ + "_id" : "n388826644", + "tags" : { +* "amenity" : "restaurant",* +* "cuisine" : "japanese",* + "name" : "Oisi" + } +}, +{ + "_id" : "n389031406", + "tags" : { +* "amenity" : "pub",* +* "cuisine" : "tapas",* + "food" : "yes", + "name" : "Tonic" + } +} +</example> +</td> +<td> +<blurb class="large">→</blurb> +</td> +<td> +<example inline="3"> +{ $group: { +* _id: '$tags.amenity',* + cuisines: { *'$addToSet': '$tags.cuisine'* } +} } +</example> + +<example inline="3"> +{ + "_id" : "pub", + "cuisines" : [ + "tapas" + ] +}, +{ + "_id" : "restaurant", + "cuisines" : [ + "japanese", + "chinese" + ] +} +</example> +</td></tr></table> +</slide> diff --git a/slides/mongodb/aggr-op-group-compound-example.xml b/slides/mongodb/aggr-op-group-compound-example.xml new file mode 100644 index 0000000..8a06430 --- /dev/null +++ b/slides/mongodb/aggr-op-group-compound-example.xml @@ -0,0 +1,71 @@ +<slide> +<title>Grouping with a Compound Key</title> + +<table class="columns"> +<tr> +<td> +<example inline="3"> +{ + "_id" : "n322270228", + "tags" : { +* "amenity" : "restaurant",* +* "cuisine" : "italian",* + "name" : "Ristorante LA COLLINA", + } +}, +{ + "_id" : "n322270302", + "tags" : { +* "amenity" : "restaurant",* +* "cuisine" : "indian",* + "name" : "The Connoisseur", + } +}, +{ + "_id" : "n322270304", + "tags" : { +* "amenity" : "restaurant",* +* "cuisine" : "italian",* + "deli" : "yes", + "name" : "Incanto", + } +} +</example> +</td> +<td> +<blurb class="large">→</blurb> +</td> +<td> +<example inline="3"> +{ $group: { + _id: *{* +* 'amenity' : '$tags.amenity',* +* 'cuisine' : '$tags.cuisine'* +* }* + names: { *'$addToSet': '$tags.name'* } +} } +</example> + +<example inline="3"> +{ +* "_id" : {* +* "amenity" : "restaurant",* +* "cuisine" : "indian"* +* },* + "names" : [ + "The Connoisseur" + ] +}, +{ +* "_id" : {* +* "amenity" : "restaurant",* +* "cuisine" : "italian"* +* },* + "names" : [ + "Incanto", + "Ristorante LA COLLINA" + ] +} +</example> +</td></tr></table> +</slide> diff --git a/slides/mongodb/aggr-op-group-sum-count-example.xml b/slides/mongodb/aggr-op-group-sum-count-example.xml new file mode 100644 index 0000000..fcdcd67 --- /dev/null +++ b/slides/mongodb/aggr-op-group-sum-count-example.xml @@ -0,0 +1,58 @@ +<slide> +<title>Summating Fields and Counting</title> + +<table class="columns"> +<tr> +<td> +<example inline="3"> +{ + "_id" : "n306036143", + "tags" : { +* "amenity" : "cafe",* + "cuisine" : "italian", + "name" : "Saponara" + } +}, +{ + "_id" : "n306042529", + "tags" : { +* "amenity" : "restaurant",* + "cuisine" : "asian", + "layer" : "2", + "name" : "Wagamama" + } +}, +{ + "_id" : "n306042546", + "tags" : { +* "amenity" : "restaurant",* + "cuisine" : "sushi", + "layer" : "2", + "name" : "Yo! Sushi" + } +} +</example> +</td> +<td> +<blurb class="large">→</blurb> +</td> +<td> +<example inline="3"> +{ $group: { +* _id: '$tags.amenity',* + count: { *'$sum': 1* } +} } +</example> + +<example inline="3"> +{ + "_id" : "restaurant", + "count" : 2 +}, +{ + "_id" : "cafe", + "count" : 1 +}, +</example> +</td></tr></table> +</slide> diff --git a/slides/mongodb/aggr-op-group.xml b/slides/mongodb/aggr-op-group.xml new file mode 100644 index 0000000..bfb522a --- /dev/null +++ b/slides/mongodb/aggr-op-group.xml @@ -0,0 +1,17 @@ +<slide> +<title>$group</title> + + <bullet>Group documents by an ID + <list> + <bullet>Field reference, object, constant</bullet> + </list> + </bullet> + <bullet>Other output fields are computed + <list> + <bullet>%$max%, %$min%, %$avg%, %$sum%</bullet> + <bullet>%$addToSet%, %$push%</bullet> + <bullet>%$first%, %$last%</bullet> + </list> + </bullet> + <bullet>Processes all data in memory</bullet> +</slide> diff --git a/slides/mongodb/aggr-op-limit-example.xml b/slides/mongodb/aggr-op-limit-example.xml new file mode 100644 index 0000000..67c2302 --- /dev/null +++ b/slides/mongodb/aggr-op-limit-example.xml @@ -0,0 +1,35 @@ +<slide> +<title>Limit Documents through the Pipeline</title> + +<table class="columns"> +<tr> +<td> +<example inline="3"> +{ "name" : "Blues Restaurant &amp; Bar" }, +{ "name" : "Yard" }, +{ "name" : "Le Sacré Coeur" }, +{ "name" : "Ask" }, +{ "name" : "Vigata" }, +{ "name" : "Sedir" }, +{ "name" : "Parveen" }, +{ "name" : "Mem &amp; Laz" }, +{ "name" : "Gallipoli" } +</example> +</td> +<td> +<blurb class="large">→</blurb> +</td> +<td> +<example inline="3"> +*{ $limit : 5 }* +</example> + +<example inline="3"> +{ "name" : "Blues Restaurant &amp; Bar" }, +{ "name" : "Yard" }, +{ "name" : "Le Sacré Coeur" }, +{ "name" : "Ask" }, +{ "name" : "Vigata" }, +</example> +</td></tr></table> +</slide> diff --git a/slides/mongodb/aggr-op-match-example.xml b/slides/mongodb/aggr-op-match-example.xml new file mode 100644 index 0000000..fde5db4 --- /dev/null +++ b/slides/mongodb/aggr-op-match-example.xml @@ -0,0 +1,57 @@ +<slide> +<title>Matching Field Values</title> + +<table class="columns"> +<tr> +<td> +<example inline="3"> +{ + "_id" : "w42931536", + "tags" : { + "amenity" : "restaurant", +* "cuisine" : "french",* + "name" : "Le Comptoir Gascon", + } +} +{ + "_id" : "w50732182", + "tags" : { + "amenity" : "restaurant", +* "cuisine" : "burger",* + "name" : "Starving Marvin's", + } +} +{ + "_id" : "w58537927", + "tags" : { + "amenity" : "restaurant", +* "cuisine" : "chinese",* + "name" : "Royal Garden Restaurant" + } +} +</example> +</td> +<td> +<blurb class="large">→</blurb> +</td> +<td> +<example inline="3"> +{ +* $match: {* +* "tags.cuisine": "chinese"* +* }* +} +</example> + +<example inline="3"> +{ + "_id" : "w58537927", + "tags" : { + "building" : "yes", +* "cuisine" : "chinese",* + "name" : "Royal Garden Restaurant" + } +} +</example> +</td></tr></table> +</slide> diff --git a/slides/mongodb/aggr-op-match-with-query-example.xml b/slides/mongodb/aggr-op-match-with-query-example.xml new file mode 100644 index 0000000..8d45523 --- /dev/null +++ b/slides/mongodb/aggr-op-match-with-query-example.xml @@ -0,0 +1,59 @@ +<slide> +<title>Matching with Query Operators</title> + +<table class="columns"> +<tr> +<td> +<example inline="3"> +{ + "_id" : "n1240135999", + "tags" : { + "amenity" : "restaurant", + "cuisine" : "thai", + "name" : "Addie's Thai" + } +} +{ + "_id" : "n1242469688", + "tags" : { +* "addr:postcode" : "CR6 9EG",* + "addr:street" : "Farleigh Road", + "amenity" : "restaurant", + "cuisine" : "regional", + "name" : "The Horseshoe" + } +} +{ + "_id" : "n1242549289", + "tags" : { + "amenity" : "restaurant", + "cuisine" : "ethiopian", + "name" : "Queen of Sheba" + } +} +</example> +</td> +<td> +<blurb class="large">→</blurb> +</td> +<td> +<example inline="3"> +{ $match: { +* "tags.addr:postcode": { $exists: true }* +} } +</example> + +<example inline="3"> +{ + "_id" : "n1242469688", + "tags" : { +* "addr:postcode" : "CR6 9EG",* + "addr:street" : "Farleigh Road", + "amenity" : "restaurant", + "cuisine" : "regional", + "name" : "The Horseshoe" + } +} +</example> +</td></tr></table> +</slide> diff --git a/slides/mongodb/aggr-op-match.xml b/slides/mongodb/aggr-op-match.xml new file mode 100644 index 0000000..f1bbc5a --- /dev/null +++ b/slides/mongodb/aggr-op-match.xml @@ -0,0 +1,9 @@ +<slide> +<title>$match</title> + +<list> + <bullet>Filter documents</bullet> + <bullet>Uses existing query syntax</bullet> + <bullet>No geospatial operations or %$where%</bullet> +</list> +</slide> diff --git a/slides/mongodb/aggr-op-project-create-sub-example.xml b/slides/mongodb/aggr-op-project-create-sub-example.xml new file mode 100644 index 0000000..f5a157b --- /dev/null +++ b/slides/mongodb/aggr-op-project-create-sub-example.xml @@ -0,0 +1,56 @@ +<slide> +<title>Reformat Sub-Documents</title> + +<table class="columns"> +<tr> +<td> +<example inline="3"> +{ + "_id" : "n691721239", + "type" : NumberLong(1), + "loc" : [ + -0.135621, + 51.515325 + ], + "tags" : { + "addr:city" : "London", + "addr:country" : "GB", + "addr:housenumber" : "187b", + "addr:street" : "Wardour Street", + "amenity" : "restaurant", + "cuisine" : "korean", + "name" : "Red Devil" + } +} +</example> +</td> +<td> +<blurb class="large">→</blurb> +</td> +<td> +<example inline="3"> +{ $project: { + *name: '$tags.name',* + cuisine: '$tags.cuisine', +* address: {* +* nr: '$tags.addr:housenumber',* +* street: '$tags.addr:street',* +* city: '$tags.addr:city'* +* }* +} } +</example> + +<example inline="3"> + { + "_id" : "n691721239", + *"name" : "Red Devil",* + "cuisine" : "korean", +* "address" : {* +* "nr" : "187b",* +* "street" : "Wardour Street",* +* "city" : "London"* +* }* + } +</example> +</td></tr></table> +</slide> diff --git a/slides/mongodb/aggr-op-project-incl-excl-example.xml b/slides/mongodb/aggr-op-project-incl-excl-example.xml new file mode 100644 index 0000000..4fb3716 --- /dev/null +++ b/slides/mongodb/aggr-op-project-incl-excl-example.xml @@ -0,0 +1,43 @@ +<slide> +<title>Including and Excluding Fields</title> + +<table class="columns"> +<tr> +<td> +<example inline="3"> +{ +* "_id" : "n47733711",* + "type" : NumberLong(1), + "loc" : [ + 0.2344868, + 51.5938555 + ], +* "tags" : {* +* "amenity" : "fast_food",* +* "cuisine" : "fish_and_chips",* +* "name" : "The Frying Pan"* +* }* +}, +</example> +</td> +<td> +<blurb class="large">→</blurb> +</td> +<td> +<example inline="3"> +{ +* $project: { _id: 0, tags: 1 }* +} +</example> + +<example inline="3"> +{ +* "tags" : {* +* "amenity" : "fast_food",* +* "cuisine" : "fish_and_chips",* +* "name" : "The Frying Pan"* +* }* +}, +</example> +</td></tr></table> +</slide> diff --git a/slides/mongodb/aggr-op-project-rename-compute-example.xml b/slides/mongodb/aggr-op-project-rename-compute-example.xml new file mode 100644 index 0000000..6c4292d --- /dev/null +++ b/slides/mongodb/aggr-op-project-rename-compute-example.xml @@ -0,0 +1,54 @@ +<slide> +<title>Renaming and Computing Fields</title> + +<table class="columns"> +<tr> +<td> +<example inline="3"> +{ + "_id" : "n375475617", + "type" : NumberLong(1), + "loc" : [ + -0.1502324, + 51.4440935 + ], +* "tags"* : { + "addr:housenumber" : "37", + "addr:street" : "Bedford Hill", + "amenity" : "restaurant", + "cuisine" : "greek", + "name" : "Meze Kitchen" + } +}, +</example> +</td> +<td> +<blurb class="large">→</blurb> +</td> +<td> +<example inline="3"> +{ $project: { + address: { *$concat: [* +* '$tags.addr:housenumber',* +* ' ',* +* '$tags.addr:street'* +* ]* }, + 'desc': *'$tags'* +} } +</example> + +<example inline="3"> +{ + "_id" : "n375475617", +* "address" : "37 Bedford Hill",* +* "desc"* : { + "addr:housenumber" : "37", + "addr:street" : "Bedford Hill", + "amenity" : "restaurant", + "cuisine" : "greek", + "name" : "Meze Kitchen" + } +}, +</example> +</td></tr></table> +</slide> diff --git a/slides/mongodb/aggr-op-project.xml b/slides/mongodb/aggr-op-project.xml new file mode 100644 index 0000000..bc11b4b --- /dev/null +++ b/slides/mongodb/aggr-op-project.xml @@ -0,0 +1,10 @@ +<slide> +<title>$project</title> + +<list> + <bullet>Reshape documents</bullet> + <bullet>Include, exclude or rename fields</bullet> + <bullet>Inject computed fields</bullet> + <bullet>Create sub-document fields</bullet> +</list> +</slide> diff --git a/slides/mongodb/aggr-op-skip-example.xml b/slides/mongodb/aggr-op-skip-example.xml new file mode 100644 index 0000000..ff31e1b --- /dev/null +++ b/slides/mongodb/aggr-op-skip-example.xml @@ -0,0 +1,36 @@ +<slide> +<title>Skip Over Documents in the Pipeline</title> + +<table class="columns"> +<tr> +<td> +<example inline="3"> +{ "name" : "Blues Restaurant &amp; Bar" }, +{ "name" : "Yard" }, +{ "name" : "Le Sacré Coeur" }, +{ "name" : "Ask" }, +{ "name" : "Vigata" }, +{ "name" : "Sedir" }, +{ "name" : "Parveen" }, +{ "name" : "Mem &amp; Laz" }, +{ "name" : "Gallipoli" } +</example> +</td> +<td> +<blurb class="large">→</blurb> +</td> +<td> +<example inline="3"> +*{ $skip : 3 }* +</example> + +<example inline="3"> +{ "name" : "Ask" }, +{ "name" : "Vigata" }, +{ "name" : "Sedir" }, +{ "name" : "Parveen" }, +{ "name" : "Mem &amp; Laz" }, +{ "name" : "Gallipoli" } +</example> +</td></tr></table> +</slide> diff --git a/slides/mongodb/aggr-op-sort-example.xml b/slides/mongodb/aggr-op-sort-example.xml new file mode 100644 index 0000000..9de7dce --- /dev/null +++ b/slides/mongodb/aggr-op-sort-example.xml @@ -0,0 +1,41 @@ +<slide> +<title>Sort All the Documents in the Pipeline</title> + +<table class="columns"> +<tr> +<td> +<example inline="3"> +{ "name" : "Blues Restaurant &amp; Bar" }, +{ "name" : "Yard" }, +{ "name" : "Le Sacré Coeur" }, +{ "name" : "Ask" }, +{ "name" : "Vigata" }, +{ "name" : "Sedir" }, +{ "name" : "Parveen" }, +{ "name" : "Mem &amp; Laz" }, +{ "name" : "Gallipoli" } +</example> +</td> +<td> +<blurb class="large">→</blurb> +</td> +<td> +<example inline="3"> +{ $sort: { +* name: 1* +} } +</example> + +<example inline="3"> +{ "name" : "Ask" }, +{ "name" : "Blues Restaurant &amp; Bar" }, +{ "name" : "Gallipoli" } +{ "name" : "Le Sacré Coeur" }, +{ "name" : "Mem &amp; Laz" }, +{ "name" : "Parveen" }, +{ "name" : "Sedir" }, +{ "name" : "Vigata" }, +{ "name" : "Yard" }, +</example> +</td></tr></table> +</slide> diff --git a/slides/mongodb/aggr-op-sort-limit-skip-example.xml b/slides/mongodb/aggr-op-sort-limit-skip-example.xml new file mode 100644 index 0000000..da89de1 --- /dev/null +++ b/slides/mongodb/aggr-op-sort-limit-skip-example.xml @@ -0,0 +1,73 @@ +<slide> +<title>Order of $sort, $limit, $skip is Important</title> + +<table class="columns"> +<tr> +<td> +<example inline="3"> +*{ "name" : "Blues Restaurant &amp; Bar" },* +*{ "name" : "Yard" },* +*{ "name" : "Le Sacré Coeur" },* +*{ "name" : "Ask" },* +{ "name" : "Vigata" }, +{ "name" : "Sedir" }, +{ "name" : "Parveen" }, +{ "name" : "Mem &amp; Laz" }, +{ "name" : "Gallipoli" } +</example> +</td> +<td> +<blurb class="large">→</blurb> +</td> +<td> +<example inline="3"> +[ +* { $limit : 4 },* +* { $sort : { name: 1 } }* +] +</example> + +<example inline="3"> +{ "name" : "Ask" }, +{ "name" : "Blues Restaurant &amp; Bar" }, +{ "name" : "Le Sacré Coeur" }, +{ "name" : "Yard" }, +</example> +</td></tr></table> +<break /> + +<table class="columns"> +<tr> +<td> +<example inline="3"> +*{ "name" : "Blues Restaurant &amp; Bar" },* +{ "name" : "Yard" }, +*{ "name" : "Le Sacré Coeur" },* +*{ "name" : "Ask" },* +{ "name" : "Vigata" }, +{ "name" : "Sedir" }, +{ "name" : "Parveen" }, +{ "name" : "Mem &amp; Laz" }, +*{ "name" : "Gallipoli" }* +</example> +</td> +<td> +<blurb class="large">→</blurb> +</td> +<td> +<example inline="3"> +[ +* { $sort : { name: 1 } },* +* { $limit : 4 }* +] +</example> + +<example inline="3"> +{ "name" : "Ask" }, +{ "name" : "Blues Restaurant &amp; Bar" }, +{ "name" : "Gallipoli" } +{ "name" : "Le Sacré Coeur" }, +</example> +</td></tr></table> + +</slide> diff --git a/slides/mongodb/aggr-op-sort-skip-limit.xml b/slides/mongodb/aggr-op-sort-skip-limit.xml new file mode 100644 index 0000000..2a511e5 --- /dev/null +++ b/slides/mongodb/aggr-op-sort-skip-limit.xml @@ -0,0 +1,14 @@ +<slide> +<title>$sort, $limit, $skip</title> + +<list> + <bullet>Sort documents by one or more fields + <list> + <bullet>Same order syntax as cursors</bullet> + <bullet>Waits for earlier pipeline operator to return</bullet> + <bullet>In-memory unless early and indexed</bullet> + </list> + </bullet> + <bullet>Limit and skip follow cursor behaviour</bullet> +</list> +</slide> diff --git a/slides/mongodb/aggr-op-unwind-example.xml b/slides/mongodb/aggr-op-unwind-example.xml new file mode 100644 index 0000000..708558e --- /dev/null +++ b/slides/mongodb/aggr-op-unwind-example.xml @@ -0,0 +1,58 @@ +<slide> +<title>Yielding Multiple Documents from One</title> + +<table class="columns"> +<tr> +<td> +<example inline="3"> +{ + "_id" : "n476033502", + "type" : NumberLong(1), +* "tags" : [* +* "addr:housenumber=125",* +* "addr:street=Alban Gate",* +* "amenity=restaurant",* +* "cuisine=pizza",* +* "level=1",* +* "name=Pizza Express",* +* "phone=020 7600 8880",* +* "postcode=EC2Y 5AS"* +* ]* +} +</example> +</td> +<td> +<blurb class="large">→</blurb> +</td> +<td> +<example inline="3"> +{ +* $unwind: '$tags'* +} +</example> + +<example inline="3"> +{ + "_id" : "n476033502", + "type" : NumberLong(1), +* "tags" : "addr:housenumber=125"* +}, +{ + "_id" : "n476033502", + "type" : NumberLong(1), +* "tags" : "addr:street=Alban Gate"* +}, +{ + "_id" : "n476033502", + "type" : NumberLong(1), +* "tags" : "amenity=restaurant"* +}, +{ + "_id" : "n476033502", + "type" : NumberLong(1), +* "tags" : "cuisine=pizza"* +}, +… +</example> +</td></tr></table> +</slide> diff --git a/slides/mongodb/aggr-op-unwind.xml b/slides/mongodb/aggr-op-unwind.xml new file mode 100644 index 0000000..e426de9 --- /dev/null +++ b/slides/mongodb/aggr-op-unwind.xml @@ -0,0 +1,15 @@ +<slide> +<title>$unwind</title> + +<list> + <bullet>Operate on an array field</bullet> + <bullet>Yield new documents for each array element + <list> + <bullet>Array replaced by element value</bullet> + <bullet>Missing/empty fields → no output</bullet> + <bullet>Non-array fields → error</bullet> + </list> + </bullet> + <bullet>Pipe to %$group% to aggregate array values</bullet> +</list> +</slide> diff --git a/slides/mongodb/aggr-our-example-data.xml b/slides/mongodb/aggr-our-example-data.xml new file mode 100644 index 0000000..57fce13 --- /dev/null +++ b/slides/mongodb/aggr-our-example-data.xml @@ -0,0 +1,17 @@ +<slide> +<title>Our Example data</title> + +<example> +{ + "_id" : "w94069675", + "tags" : { + "addr:housenumber" : "64", + "addr:street" : "Borough High Street", + "amenity" : "restaurant", + "building" : "yes", + "cuisine" : "indian", + "name" : "Truly Indian" + }, +} +</example> +</slide> diff --git a/slides/mongodb/aggr-pipeline-section.xml b/slides/mongodb/aggr-pipeline-section.xml new file mode 100644 index 0000000..fa415ce --- /dev/null +++ b/slides/mongodb/aggr-pipeline-section.xml @@ -0,0 +1 @@ +<slide type="section"><blurb>Pipeline</blurb></slide> diff --git a/slides/mongodb/aggr-pipeline.xml b/slides/mongodb/aggr-pipeline.xml new file mode 100644 index 0000000..206fcb0 --- /dev/null +++ b/slides/mongodb/aggr-pipeline.xml @@ -0,0 +1,21 @@ +<slide> +<title>Pipeline</title> + +<list> + <bullet>Process a stream of documents + <list> + <bullet>Original input is a collection</bullet> + <bullet>Final output is a result document</bullet> + </list> + </bullet> + <bullet>Series of operators + <list> + <bullet>Filter or transform data</bullet> + <bullet>Input/output chain</bullet> + </list> + </bullet> +</list> + +<blurb align="center">%ps ax | grep mongod | head -n 1%</blurb> +</slide> + diff --git a/slides/mongodb/aggr-pipelines-ops.xml b/slides/mongodb/aggr-pipelines-ops.xml new file mode 100644 index 0000000..c9fdf19 --- /dev/null +++ b/slides/mongodb/aggr-pipelines-ops.xml @@ -0,0 +1,13 @@ +<slide> +<title>Pipeline Operators</title> + +<list> + <bullet>%$match%</bullet> + <bullet>%$project%</bullet> + <bullet>%$group%</bullet> + <bullet>%$unwind%</bullet> + <bullet>%$sort%</bullet> + <bullet>%$limit%</bullet> + <bullet>%$skip%</bullet> +</list> +</slide> diff --git a/slides/mongodb/aggr-shard.png b/slides/mongodb/aggr-shard.png new file mode 100644 index 0000000..26fb8ca Binary files /dev/null and b/slides/mongodb/aggr-shard.png differ diff --git a/slides/mongodb/aggr-sharding-example1.xml b/slides/mongodb/aggr-sharding-example1.xml new file mode 100644 index 0000000..0d434dc --- /dev/null +++ b/slides/mongodb/aggr-sharding-example1.xml @@ -0,0 +1,13 @@ +<slide> +<title>Sharding</title> + +<example> +[ + { $match: { /* filter by shard key */ } }, + { $project: { /* select fields */ } }, + { $group: { /* group by some field */ } }, + { $sort: { /* sort by some field */ } }, + { $project: { /* reshape result */ } } +] +</example> +</slide> diff --git a/slides/mongodb/aggr-sharding-example2.xml b/slides/mongodb/aggr-sharding-example2.xml new file mode 100644 index 0000000..98ada73 --- /dev/null +++ b/slides/mongodb/aggr-sharding-example2.xml @@ -0,0 +1,9 @@ +<slide> +<title>&#160;</title> + +<image filename="aggr-shard.png"/> + +<blurb align="center"> +Sharding +</blurb> +</slide> diff --git a/slides/mongodb/aggr-sharding-section.xml b/slides/mongodb/aggr-sharding-section.xml new file mode 100644 index 0000000..9778846 --- /dev/null +++ b/slides/mongodb/aggr-sharding-section.xml @@ -0,0 +1,3 @@ +<slide type="section"> +<blurb>Sharding</blurb> +</slide> diff --git a/slides/mongodb/aggr-sharding.xml b/slides/mongodb/aggr-sharding.xml new file mode 100644 index 0000000..335d22b --- /dev/null +++ b/slides/mongodb/aggr-sharding.xml @@ -0,0 +1,14 @@ +<slide> +<title>Sharding</title> + +<list> + <bullet>Split the pipeline at first %$group% or %$sort% + <list> + <bullet>Shards execute pipeline up to that point</bullet> + <bullet>mongos merges results and continues</bullet> + </list> + </bullet> + <bullet>Early %$match% may excuse shards</bullet> + <bullet>CPU and memory implications for mongos</bullet> +</list> +</slide> diff --git a/slides/mongodb/aggr-usage-and-limitations-section.xml b/slides/mongodb/aggr-usage-and-limitations-section.xml new file mode 100644 index 0000000..c514e2e --- /dev/null +++ b/slides/mongodb/aggr-usage-and-limitations-section.xml @@ -0,0 +1,3 @@ +<slide type="section"> +<blurb>Usage and Limitations</blurb> +</slide> diff --git a/slides/mongodb/aggr-usage.xml b/slides/mongodb/aggr-usage.xml new file mode 100644 index 0000000..30926f8 --- /dev/null +++ b/slides/mongodb/aggr-usage.xml @@ -0,0 +1,13 @@ +<slide> +<title>Usage</title> + +<list> + <bullet>%collection.aggregate()% method + <list> + <bullet>Mongo shell</bullet> + <bullet>Most drivers</bullet> + </list> + </bullet> + <bullet>%aggregate% database command</bullet> +</list> +</slide> diff --git a/slides/mongodb/aggregation-framework.jpg b/slides/mongodb/aggregation-framework.jpg new file mode 100644 index 0000000..75859b3 Binary files /dev/null and b/slides/mongodb/aggregation-framework.jpg differ diff --git a/slides/mongodb/datawarehousing.jpg b/slides/mongodb/datawarehousing.jpg new file mode 100644 index 0000000..b4e962a Binary files /dev/null and b/slides/mongodb/datawarehousing.jpg differ
« previous php.pres (#1885) next »