Reduce sums counts for each key: 'apple' = 1+1=2, 'banana' = 1.
Final Answer:
[('apple', 2), ('banana', 1)] -> Option C
Quick Check:
Count of 'apple' = 2, 'banana' = 1 [OK]
Hint: Map emits value with 1, Reduce sums counts by key [OK]
Common Mistakes:
Counting keys instead of values
Confusing input keys with values
Adding counts incorrectly
4. Identify the error in this MapReduce job execution flow:
Map task reads input and emits key-value pairs. Reduce task tries to read input directly from HDFS instead of shuffle output. Reduce task aggregates values by key.
medium
A. Reduce task should emit key-value pairs before Map
B. Map task should aggregate values, not Reduce task
C. Map task should read from shuffle output
D. Reduce task should read from shuffle output, not directly from HDFS
Solution
Step 1: Understand Reduce input source
Reduce tasks receive data from the shuffle phase, not directly from HDFS input files.
Step 2: Identify incorrect flow
Reading directly from HDFS in Reduce breaks the flow and causes errors.
Final Answer:
Reduce task should read from shuffle output, not directly from HDFS -> Option D
Quick Check:
Reduce reads shuffle output [OK]
Hint: Reduce reads shuffle output, never direct HDFS input [OK]
Common Mistakes:
Thinking Reduce reads input files
Swapping Map and Reduce roles
Ignoring shuffle phase
5. You want to optimize a MapReduce job that processes large logs by filtering out entries with empty user IDs before counting occurrences. Where should you apply this filter for best performance?
hard
A. In the Reduce task after aggregation
B. In the Map task before emitting key-value pairs
C. During the shuffle phase
D. After the job completes on the output files
Solution
Step 1: Understand filtering impact
Filtering early reduces data volume, saving network and processing time.
Step 2: Apply filter in Map task
Filtering in Map avoids sending unnecessary data to shuffle and Reduce phases.
Final Answer:
In the Map task before emitting key-value pairs -> Option B
Quick Check:
Filter early in Map for best performance [OK]
Hint: Filter data early in Map to reduce workload [OK]
Common Mistakes:
Filtering only in Reduce wastes resources
Trying to filter during shuffle (not possible)
Filtering after job completion is too late
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.