MongoDB Questions and Answers – Map-Reduce and Sharded Collections

This set of MongoDB Multiple Choice Questions & Answers (MCQs) focuses on “Map-Reduce and Sharded Collections”.

1. The _____ JavaScript engine allows multiple JavaScript operations to execute at the same time.
a) V8
b) V12
c) V7
d) None of the mentioned
View Answer

Answer: a
Explanation: V8 JavaScript engine became the default engine in 2.4 version.

2. Point out the correct statement.
a) The read phase takes a exclusive lock
b) The map-reduce operation is composed of many tasks
c) Prior to version 3, JavaScript code executed in a single thread
d) All of the mentioned
View Answer

Answer: b
Explanation: It includes reads from the input collection, executions of the map function, executions of the reduce function, writes to a temporary collection during processing, and writes to the output collection.

3. If the ______ field for mapReduce has the sharded value, MongoDB shards the output collection using the _id field as the shard key.
a) input
b) $in
c) $out
d) none of the mentioned
View Answer

Answer: c
Explanation: During the post-processing, each shard will pull the results for its own chunks from the other shards, run the final reduce/finalize, and write locally to the output collection.

advertisement
advertisement

4. In MongoDB __________ mongos retrieves the results from each shard, performs a merge sort to order the results.
a) 3.0
b) 2.0
c) 1.0
d) None of the mentioned
View Answer

Answer: b
Explanation: This model requires only a small amount of memory, even for large data sets.

5. Point out the wrong statement.
a) If the output collection does not exist, MongoDB creates and shards the collection on the _id field
b) Map-reduce supports operations on sharded collections, both as an input and as an output
c) mongos dispatches, in parallel, a map-reduce post-processing job to every shard that owns a chunk
d) None of the mentioned
View Answer

Answer: d
Explanation: When using sharded collection as the input for a map-reduce operation, mongos will automatically dispatch the map-reduce job to each shard in parallel.

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. Which of the following function follows the reduce method and modifies the output?
a) finalize
b) final
c) max
d) all of the mentioned
View Answer

Answer: a
Explanation: Finalize fucntion is optional for mapreduce operation.

7. __________ specifies global variables that are accessible in the map.
a) jsMode
b) scope
c) finalize
d) Min
View Answer

Answer: b
Explanation: It can also access reduce functions.

advertisement

8. MongoDB converts the JavaScript objects emitted by the map function to ________ objects.
a) BSON
b) JSON
c) Javascript
d) None of the mentioned
View Answer

Answer: a
Explanation: These BSON objects are then converted back to JavaScript objects when calling the reduce function.

9. You can only use jsMode for result sets with fewer than 500,000 distinct key arguments to the mapper’s _______ function.
a) emit()
b) emitter()
c) emitted()
d) none of the mentioned
View Answer

Answer: a
Explanation: A single emit can only hold half of MongoDB’s maximum BSON document size.

advertisement

10. Which of the following mode defaults to false?
a) jsMode
b) scope
c) finalize
d) min
View Answer

Answer: a
Explanation: Internally, the JavaScript objects emitted during map function remain as JavaScript objects.

Sanfoundry Global Education & Learning Series – MongoDB.

Here’s the list of Best Books in MongoDB.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.