An e commerce site stores ( product, rating) tuples for data analysis. E.g. tuple is (““product_ 3), where rating is from 1 10 with 10 being the best. A user can rate many productsand products can be rated by many users. Write MapReduce pseud o code to find the range (min andmax) of ratings received for each product. So each output record contains (< to ).
Mapper
map(key, value):# key: not used in this case# value: tuple ("user", "hotel", "review")
user, hotel, review = value.split(", ") # assuming values are separated by ", "# Emit user and hotel as keys with count 1emit(user, 1)emit(hotel, 1)
Reducer
reduce(key, values):# key: user or hotel# values: iterator over counts
total_reviews = 0# Sum up the counts for each user or hotelfor count in values: total_reviews += count# Emit the result for user or hotelemit(key, total_reviews)