Reputation: 18810
I have following RDD:
res38: org.apache.spark.rdd.RDD[(String, Iterable[String])] = ShuffledRDD[5] at groupBy at <console>:14
now I want to get the second element of that tuple and put them in an array:
so I tried following:
scala> val items = data.map(x => x._2.toArray)
items: org.apache.spark.rdd.RDD[Array[String]] = MappedRDD[17] at map at <console>:16
and then to print the items:
items.take(4).foreach(printl
n)
but what I got is following:
[Ljava.lang.String;@223c67dc
[Ljava.lang.String;@2bc6ae13
[Ljava.lang.String;@ce77d9
[Ljava.lang.String;@731e47f8
I was expecting strings. What am I doing wrong?
Upvotes: 1
Views: 1025
Reputation: 6242
Try converting the arrays to String
before printing them. Something like:
items.take(4).foreach(x => println(x.mkString(" ")))
Upvotes: 1