This a plain file that contains the commands that can be used to replicate the
hands-on example "MapReduce in MongoDB". It is based on the arXiv JSON
database of Assignment 2.

Commands are wrapped in a blocks of ``` (according to Markdown:
https://en.wikipedia.org/wiki/Markdown; please use a Markdown viewer for proper
readability) and on top the description of the code is underline with `=======`.

## (1) Execute MapReduce in MongoDB
================================================================================

The following call to MapReduce in MongoDB specifies (in this order):
 1. A map function that emits the number of authors for each submitter of a
    publication.
 2. A reduce function that sums up the number of authors for each submitter.
 3. A query that considers only publications that have been co-authored by
    a person whose name contains 'Stonebraker', and an output collection to
    which the result is written to.
```
db.arxiv.mapReduce(
  function() {
    emit(this.submitter, this.authors_parsed.length);
  },
  function(key,values) {
    return Array.sum(values)
  },
  {
    query: { "authors": /Stonebraker/ },
    out: "submitter_author_count"
  }
)
```

## (2) Check the Result of the MapReduce Operation
================================================================================

Execute the following command to print the collection that contains the result
of the MapReduce operation:
```
db.submitter_author_count.find().pretty()
```

### Expected Result

```
{ "_id" : "Jeremy Kepner", "value" : 9 }
{ "_id" : "Vijay Gadepally", "value" : 17 }
```

### Explanation

'Jeremy Kepner' submitted one publication that has been (co-)authored by 9
authors (including Michael Stonebraker).
'Vijay Gadepally' submitted two publications that have been (co-)authored by 7
and 10 authors, respectively (both including Michael Stonebraker). These results
have been summed up: 10 + 7 = 17.