[hadoop] top n 소팅

hadoop 2016. 2. 16. 20:56


hadoop을 돌려서 키와 개수를 얻었고, 이에 대한 top n 소팅을 하고 싶다.


url별 개수별로 hadoop map-reduce를 돌려 다음과 같이 얻었다고 가정한다.


hadoop fs -text /user/google/count/2016/02/15/*


/search/test  15

/search/abc  10

/search/check  20

...





sort와 head를 그냥 사용하면 결과를 얻을 수 있다.

hadoop fs -text /user/google/count/2016/02/15/* | sort -n -k2 -r | head -n3


/search/check  20

/search/test  15

/search/abc  10





Posted by '김용환'
,