Skip to content

Commit 7072ec4

Browse files
committed
DOCSP-5629 POC: videos - agg pipeline
1 parent 9ed4c39 commit 7072ec4

File tree

4 files changed

+87
-16
lines changed

4 files changed

+87
-16
lines changed

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,16 @@ test: html ## Runs test framework over the corpus
3636

3737
html: examples ## Builds this branch's HTML under build/<branch>/html
3838
giza make html
39+
# TEMP copy of video file. Remove once video infrastructure in place.
40+
if [ -f source/images/agg-pipeline.mp4 ]; then cp source/images/agg-pipeline.mp4 build/${GIT_BRANCH}/html/_images/; fi
41+
3942

4043
publish: examples ## Builds this branch's publishable HTML and other artifacts under build/public
4144
if [ ${GIT_BRANCH} = master ]; then rm -rf build/master build/public; fi
4245
giza make publish
4346
if [ ${GIT_BRANCH} = master ]; then mut-redirects config/redirects -o build/public/.htaccess; fi
47+
# TEMP copy of video file. Remove once video infrastructure in place.
48+
if [ -f source/images/agg-pipeline.mp4 ]; then cp source/images/agg-pipeline.mp4 build/public/${GIT_BRANCH}/_images/; cp source/images/agg-pipeline.mp4 build/${GIT_BRANCH}/html/_images/; cp source/images/agg-pipeline.mp4 build/${GIT_BRANCH}/dirhtml/_images/;fi
4449

4550
# - Enter build/<branch>/html, and recurse over each regular file
4651
# <basename>/<filename>.

source/aggregation.txt

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,36 @@ Aggregation Pipeline
2727
MongoDB's :doc:`aggregation framework
2828
</core/aggregation-pipeline>` is modeled on the concept of data
2929
processing pipelines. Documents enter a multi-stage pipeline that
30-
transforms the documents into an aggregated result.
30+
transforms the documents into an aggregated result. For example:
31+
32+
.. only:: website and dirhtml
33+
34+
.. raw:: html
35+
36+
<video style="width:100%;" src="../_images/agg-pipeline.mp4" controls> </video>
37+
38+
.. only:: website and html and (not dirhtml)
39+
40+
.. raw:: html
41+
42+
<video style="width:100%;" src="_images/agg-pipeline.mp4" controls> </video>
43+
44+
In the example,
45+
46+
.. code-block:: javascript
47+
48+
db.orders.aggregate([
49+
{ $match: { status: "A" } },
50+
{ $group: { _id: "$cust_id", total: { $sum: "$amount" } } }
51+
])
52+
53+
**First Stage**: The :pipeline:`$match` stage filters the documents by
54+
the ``status`` field and passes to the next stage those documents that
55+
have ``status`` equal to ``"A"``.
56+
57+
**Second Stage**: The :pipeline:`$group` stage groups the documents by
58+
the ``cust_id`` field to calculate the sum of the amount for each
59+
unique ``cust_id``.
3160

3261
The most basic pipeline stages provide *filters* that operate like
3362
queries and *document transformations* that modify the form
@@ -53,8 +82,6 @@ internal optimization phase. See
5382
:ref:`aggregation-pipeline-operators-and-performance` and
5483
:doc:`/core/aggregation-pipeline-optimization` for details.
5584

56-
.. include:: /images/aggregation-pipeline.rst
57-
5885
.. _aggregation-map-reduce:
5986

6087
Map-Reduce

source/core/aggregation-pipeline.txt

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,36 @@ Aggregation Pipeline
1313
The aggregation pipeline is a framework for data aggregation modeled
1414
on the concept of data processing pipelines. Documents enter a
1515
multi-stage pipeline that transforms the documents into aggregated
16-
results.
16+
results. For example:
1717

18-
.. include:: /images/aggregation-pipeline.rst
18+
.. only:: website and dirhtml
1919

20-
The aggregation pipeline provides an alternative to :term:`map-reduce`
21-
and may be the preferred solution for aggregation tasks where the
22-
complexity of map-reduce may be unwarranted.
20+
.. raw:: html
2321

24-
Aggregation pipeline have some limitations on value types and result
25-
size. See :doc:`/core/aggregation-pipeline-limits` for details on
26-
limits and restrictions on the aggregation pipeline.
22+
<video style="width:100%;" src="../../_images/agg-pipeline.mp4" controls> </video>
23+
24+
.. only:: website and html and (not dirhtml)
25+
26+
.. raw:: html
27+
28+
<video style="width:100%;" src="../_images/agg-pipeline.mp4" controls> </video>
29+
30+
In the example,
31+
32+
.. code-block:: javascript
33+
34+
db.orders.aggregate([
35+
{ $match: { status: "A" } },
36+
{ $group: { _id: "$cust_id", total: { $sum: "$amount" } } }
37+
])
38+
39+
**First Stage**: The :pipeline:`$match` stage filters the documents by
40+
the ``status`` field and passes to the next stage those documents that
41+
have ``status`` equal to ``"A"``.
42+
43+
**Second Stage**: The :pipeline:`$group` stage groups the documents by
44+
the ``cust_id`` field to calculate the sum of the amount for each
45+
unique ``cust_id``.
2746

2847
.. _aggregation-pipeline:
2948

@@ -126,16 +145,36 @@ equivalent to a single query with a sort and can use an index. When
126145
possible, place :pipeline:`$match` operators at the beginning of the
127146
pipeline.
128147

129-
Additional Features
130-
~~~~~~~~~~~~~~~~~~~
148+
Considerations
149+
--------------
131150

132-
The aggregation pipeline has an internal optimization phase that
133-
provides improved performance for certain sequences of operators. For
134-
details, see :doc:`/core/aggregation-pipeline-optimization`.
151+
Sharded Collections
152+
~~~~~~~~~~~~~~~~~~~~
135153

136154
The aggregation pipeline supports operations on sharded collections.
137155
See :ref:`aggregation-pipeline-sharded-collection`.
138156

157+
Aggregation vs Map-Reduce
158+
~~~~~~~~~~~~~~~~~~~~~~~~~
159+
160+
The aggregation pipeline provides an alternative to :term:`map-reduce`
161+
and may be the preferred solution for aggregation tasks where the
162+
complexity of map-reduce may be unwarranted.
163+
164+
Limitations
165+
~~~~~~~~~~~
166+
167+
Aggregation pipeline have some limitations on value types and result
168+
size. See :doc:`/core/aggregation-pipeline-limits` for details on
169+
limits and restrictions on the aggregation pipeline.
170+
171+
Pipeline Optimization
172+
~~~~~~~~~~~~~~~~~~~~~
173+
174+
The aggregation pipeline has an internal optimization phase that
175+
provides improved performance for certain sequences of operators. For
176+
details, see :doc:`/core/aggregation-pipeline-optimization`.
177+
139178
.. toctree::
140179
:titlesonly:
141180
:hidden:

source/images/agg-pipeline.mp4

4.41 MB
Binary file not shown.

0 commit comments

Comments
 (0)