To find the top 10 counts , which is better using top(10) with Ordering on
the value,
or swapping the key value and ordering on the key ?  For example which is
better below ?
Or does it matter

 val top10 = logs.filter(log => log.responseCode != 200).map(log =>
(log.endpoint, 1)).reduceByKey(_ + _).top(10)(Ordering[Long].on(x=>x._2))


 val top10 = logs.filter(log => log.responseCode != 200).map(log =>
(log.endpoint,
1)).reduceByKey((x,y)=>x+y).map(x=>(x._2,x._1)).sortByKey(false).take(10)


 val top10 = logs.filter(log => log.responseCode != 200).map(log =>
(log.endpoint, 1)).reduceByKey((x,y)=>x+y).map(pair => pair.swap).top(10)

Reply via email to