Explanation: Mapper will produce the output as below.
A green,190 A blue,300 A yellow,299 A blue,199 A green,199 A yellow,299 A green,799
In the reducer, it will go to same reducer and single reduce method call will have all the values. All the color as key and all the widths in a single ArrayList instance will hold.
blue ( 300,199) green (190,199,799) yellow (299,299)
Final output it will emit as green 1188
Question : You have following data in a hive table
Explanation: Mapper will produce the following output
A green,190 A blue,300 A yellow,299 A blue,199 A green,199 A yellow,299 A green,799
Hence each key and values will go to the same simulator. In the reducer we will create the reverse order TreeMap (Descending order of the key, in this case it would be descending order of color)
And finally we will sum all the widths of the single color, and emits the values as below.