No, you can wrap other types in value classes as well.  You can try it in
the REPL:

scala> case class ID(val id: String) extends AnyVal
defined class ID
scala> val i = ID("foo")
i: ID = ID(foo)


On Fri, Apr 18, 2014 at 4:14 PM, Koert Kuipers [via Apache Spark User List]
<ml-node+s1001560n4475...@n3.nabble.com> wrote:

> isn't valueclasses for primitives (AnyVal) only? that doesn't apply to
> string, which is an object (AnyRef)
>
>
> On Fri, Apr 18, 2014 at 2:51 PM, kamatsuoka <[hidden 
> email]<http://user/SendEmail.jtp?type=node&node=4475&i=0>
> > wrote:
>
>> I'm wondering if anyone has tried using value classes in RDDs?  My use
>> case
>> is that I have a number of RDDs containing strings, e.g.
>>
>> val r1: RDD[(String, (String, Int)] = ...
>> val r2: RDD[(String, (String, Int)] = ...
>>
>> and it might be clearer if I wrote
>>
>> case class ID(val id: String) extends AnyVal
>> case class Name(val id: String) extends AnyVal
>> val r1: RDD[(ID, (Name, Int)] = ...
>> val r2: RDD[(Name, (ID, Int)] = ...
>>
>> This seems like a pretty typical use case for value classes, but I haven't
>> noticed anyone talking about it.  Although, I think you'd have to read
>> through all of the Spark code paths to know whether allocation is required
>> (http://docs.scala-lang.org/overviews/core/value-classes.html), so some
>> comparative performance testing would be called for.
>>
>>
>>
>> --
>> View this message in context:
>> http://apache-spark-user-list.1001560.n3.nabble.com/Anyone-using-value-classes-in-RDDs-tp4464.html
>> Sent from the Apache Spark User List mailing list archive at Nabble.com.
>>
>
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://apache-spark-user-list.1001560.n3.nabble.com/Anyone-using-value-classes-in-RDDs-tp4464p4475.html
>  To unsubscribe from Anyone using value classes in RDDs?, click 
> here<http://apache-spark-user-list.1001560.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4464&code=a2VuamltQGdtYWlsLmNvbXw0NDY0fC02MzgwODY1NQ==>
> .
> NAML<http://apache-spark-user-list.1001560.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>



-- 
Kenji




--
View this message in context: 
http://apache-spark-user-list.1001560.n3.nabble.com/Anyone-using-value-classes-in-RDDs-tp4464p4494.html
Sent from the Apache Spark User List mailing list archive at Nabble.com.

Reply via email to