I have s simple map like
val parameters: Map[String, Any] = Map("digits" -> Seq(1, 2, 3, 4, 5, 6, 7, 8,
an want to multiply each number by 3 like shown below
class PrintMap extends App {
val conf: SparkConf = new SparkConf()
.setAppName("sparkApiSample")
.setMaster("local[*]")
val session: SparkSession = SparkSession
.builder()
.config(conf)
.getOrCreate()
val parameters: Map[String, Any] = Map("digits" -> Seq(1, 2, 3, 4, 5, 6, 7, 8, 9, 0))
val numbers: Seq[Int] = parameters("digits").asInstanceOf[Seq[Int]]
val rdd = session.sparkContext.parallelize(numbers)
val result = Map("result" -> rdd.map(x => x * 3).collect())
// want to "access / print the contents of the Array at result
result.get("result") match {
case Some(x) => x.asInstanceOf[Seq[Any]].foreach(println)
case None => println("error occurred")
}
Why does it result in the following exception and how could I actually access the map? java.lang.ClassCastException: [I cannot be cast to scala.collection.Seq