Commit 62ebe104 authored by 高雅喆's avatar 高雅喆

add sortbykey

parent 891aee74
...@@ -655,7 +655,10 @@ object GetLevelCount { ...@@ -655,7 +655,10 @@ object GetLevelCount {
diary_level1.show() diary_level1.show()
println(diary_level1.count()) println(diary_level1.count())
val level1_count = diary_level1.rdd.map(x => (x(1).toString)).map(level1 => (level1,1)).reduceByKey((a,b) => a+b).map(p => (p._1,p._2)).sortByKey(false,2) val cid_xiong = diary_level1.rdd.filter(_.getAs("diary_feat")==7)
cid_xiong.collect().foreach(println)
val level1_count = diary_level1.rdd.map(x => (x(1).toString)).map(level1 => (level1,1)).reduceByKey((a,b) => a+b).sortBy(_._2,false)
level1_count.collect().foreach(println) level1_count.collect().foreach(println)
println(level1_count.count()) println(level1_count.count())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment