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
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
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: