You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by rzykov <rz...@gmail.com> on 2014/09/26 09:31:56 UTC

Access by name in "tuples" in Scala with Spark

Could you advise the  best practice of using some "named tuples" in Scala
with Spark RDD.
Currently we can access by a field number in a tuple:

RDD.map{_.2}

But want to see such construction:

RDD.map{_.itemId}

This one will be helpful for debugging purposes.



--
View this message in context: http://apache-spark-user-list.1001560.n3.nabble.com/Access-by-name-in-tuples-in-Scala-with-Spark-tp15212.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


Re: Access by name in "tuples" in Scala with Spark

Posted by Sean Owen <so...@cloudera.com>.
I think you are simply looking for a case class in Scala. It is a
simple way to define an object with named, typed fields.

On Fri, Sep 26, 2014 at 8:31 AM, rzykov <rz...@gmail.com> wrote:
> Could you advise the  best practice of using some "named tuples" in Scala
> with Spark RDD.
> Currently we can access by a field number in a tuple:
>
> RDD.map{_.2}
>
> But want to see such construction:
>
> RDD.map{_.itemId}
>
> This one will be helpful for debugging purposes.
>
>
>
> --
> View this message in context: http://apache-spark-user-list.1001560.n3.nabble.com/Access-by-name-in-tuples-in-Scala-with-Spark-tp15212.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