spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Farrellee <m...@redhat.com>
Subject Re: transforming a Map object to RDD
Date Mon, 01 Sep 2014 14:38:04 GMT
and in python,

 >>> map = {'a': 1, 'b': 2, 'c': 3}
 >>> rdd = sc.parallelize(map.items())
 >>> rdd.collect()
[('a', 1), ('c', 3), ('b', 2)]

best,


matt

On 08/28/2014 07:01 PM, Sean Owen wrote:
> val map = Map("foo" -> 1, "bar" -> 2, "baz" -> 3)
> val rdd = sc.parallelize(map.toSeq)
>
> rdd is a an RDD[(String,Int)] and you can do what you like from there.
>
> On Thu, Aug 28, 2014 at 11:56 PM, SK <skrishna.id@gmail.com> wrote:
>> Hi,
>>
>> How do I convert a Map object to an RDD so that I can use the
>> saveAsTextFile() operation to output the Map object?
>>
>> thanks
>>
>>
>>
>> --
>> View this message in context: http://apache-spark-user-list.1001560.n3.nabble.com/transforming-a-Map-object-to-RDD-tp13071.html
>> Sent from the Apache Spark User List mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@spark.apache.org
>> For additional commands, e-mail: user-help@spark.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@spark.apache.org
> For additional commands, e-mail: user-help@spark.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@spark.apache.org
For additional commands, e-mail: user-help@spark.apache.org


Mime
View raw message