rdd.map(e=>e.split("\\s")).map(e=>(e(0),e(1))).groupByKey()

On Fri, Feb 26, 2016 at 3:20 PM, Bonsen <hengbohe...@126.com> wrote:

> I have a file,like 1.txt:
> 1 2
> 1 3
> 1 4
> 1 5
> 1 6
> 1 7
> 2 4
> 2 5
> 2 7
> 2 9
>
> I want to merge them,results like this
> map(1->List(2,3,4,5,6,7),2->List(4,5,7,9))
> what should I do?。。
> val file1=sc.textFile("1.txt")
> val q1=file1.flatMap(_.split(' '))???,maybe I should change RDD[int] to
> RDD[int,int]?
>
>
>
> --
> View this message in context:
> http://apache-spark-user-list.1001560.n3.nabble.com/When-I-merge-some-datas-can-t-go-on-tp26341.html
> Sent from the Apache Spark User List mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@spark.apache.org
> For additional commands, e-mail: user-h...@spark.apache.org
>
>


-- 
Best Regards

Jeff Zhang

Reply via email to