Re: Class-based key in groupByKey?

2014-05-13 Thread Matei Zaharia
Your key needs to implement hashCode in addition to equals. Matei On May 13, 2014, at 3:30 PM, Michael Malak wrote: > Is it permissible to use a custom class (as opposed to e.g. the built-in > String or Int) for the key in groupByKey? It doesn't seem to be working for > me on Spark 0.9.0/Scal

Class-based key in groupByKey?

2014-05-13 Thread Michael Malak
Is it permissible to use a custom class (as opposed to e.g. the built-in String or Int) for the key in groupByKey? It doesn't seem to be working for me on Spark 0.9.0/Scala 2.10.3: import org.apache.spark.SparkContext import org.apache.spark.SparkContext._ class C(val s:String) extends Serializ

Re: Class-based key in groupByKey?

2014-05-13 Thread Andrew Ash
In Scala, if you override .equals() you also need to override .hashCode(), just like in Java: http://www.scala-lang.org/api/2.10.3/index.html#scala.AnyRef I suspect if your .hashCode() delegates to just the hashcode of s then you'd be good. On Tue, May 13, 2014 at 3:30 PM, Michael Malak wrote: