Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- val r = sc.textFile("data96/data.csv")
- val rm = r.map(x=>(x.split(",")(0), x.split(",")(1)))
- val r_grp = rm.groupByKey
- r_grp.foreach(println(_))
- (1,CompactBuffer(Lokesh, Pavan, Tejas, Kumar, Venkat))
- (2,CompactBuffer(Bhupesh, Amit, Ratan, Dinesh, Sheela))
- val swapped = rm.map(item=>item.swap)
- val com= rm.combineByKey(List(_), (x:List[String], y:String) =>y::x,(x:List[String], y:List[String])=>x:::y) //this is terrible to me, I don't want to do this way
- com.repartition(1).saveAsTextFile("data96/s43")
- hdfs dfs -cat data96/s43/*
- (2,List(Dinesh, Ratan, Amit, Bhupesh, Sheela))
- (1,List(Lokesh, Venkat, Kumar, Tejas, Pavan))
Add Comment
Please, Sign In to add comment