I have a scala.collection.Set scalaSet : Set[Long]
.
How will I be able to convert it into a java.util.Set
with serializable. I tried the following code, but got
java.io.notserializableexception: scala.collection.convert.wrappers$setWrapper
import scala.collection.JavaConversions._
Class MySerializableClass extends Serializable {
// method to implement the Scala to Java operations on the given RDD
def rddOps(dummyRDD: RDD[(Long, Set[Long])]) = {
val dummyRDDWithJavaSet = dummyRDD.map( {
case(key, value) => (key, scalaToJavaSetConverter(value))
}
// scala Set to Java Set Converters
def scalaToJavaSetConverter(scalaSet: Set[Long]): java.util.Set[Long] = {
val javaSet : java.util.Set[Long] = setAsJavaSet(scalaSet)
javaSet
}
}
I have seen the thread notserializable exception when trying to serialize java map converted from scala for an answer, but the solution didn't work with serialization