-2

What changes do we need to make and on which class i.e. Mapper or Reducer, if we want to write a program for Word Count which will display result in descending order?

  • show you code you've already written! – codrelphi Mar 18 '18 at 14:43
  • Thanks for the quick response @ThexPhi . Please find my code here https://github.com/decsourabh/WordCount – Kumar Sourabh Mar 18 '18 at 17:54
  • In descending order based on the key or on the value? It is better to provide an example of the final result. It can help us to help you! Also, take a look on those posts: https://stackoverflow.com/questions/44679841/mapreduce-sort-by-value-in-descending-order https://stackoverflow.com/questions/2550784/sorted-word-count-using-hadoop-mapreduce – codrelphi Mar 18 '18 at 18:15

1 Answers1

0

As per the JavDoc

The output of the Reducer is not re-sorted.

The best way to achieve that is to create another job which would take the output of WordCount as input and produce a sorted result as per your requirement.

Gyanendra Dwivedi
  • 5,511
  • 2
  • 27
  • 53
  • Thank you for your response. I am able to do it using chaining now but it is there any other way to do it more efficiently? – Kumar Sourabh Mar 18 '18 at 19:25
  • Unfortunately no. There is no reliable way to control order in reducer, so it really depends on when each of the reducer gets complete.. further in wordcount program, there are multiple reducers, so that is not an option within just one job. – Gyanendra Dwivedi Mar 19 '18 at 04:02
  • Please do not forget to accept and upvote the answer, if it helped. – Gyanendra Dwivedi Mar 19 '18 at 04:03