Github user marmbrus commented on a diff in the pull request:
https://github.com/apache/spark/pull/363#discussion_r11426010
--- Diff: core/src/main/scala/org/apache/spark/api/python/PythonRDD.scala
---
@@ -284,6 +286,42 @@ private[spark] object PythonRDD {
file.close()
}
+ def pythonToJava(pyRDD: JavaRDD[Array[Byte]]): JavaRDD[_] = {
+ pyRDD.rdd.mapPartitions { iter =>
+ val unpickle = new Unpickler
+ // TODO: Figure out why flatMap is necessay for pyspark
+ iter.flatMap { row =>
+ unpickle.loads(row) match {
+ case objs: java.util.ArrayList[Any] => objs
+ // Incase the partition doesn't have a collection
+ case obj => Seq(obj)
+ }
+ }
+ }
+ }
+
+ def pythonToJavaMap(pyRDD: JavaRDD[Array[Byte]]): JavaRDD[Map[String,
_]] = {
+ pyRDD.rdd.mapPartitions { iter =>
+ val unpickle = new Unpickler
+ // TODO: Figure out why flatMap is necessay for pyspark
+ iter.flatMap { row =>
+ unpickle.loads(row) match {
+ case objs: java.util.ArrayList[JMap[String, _]] =>
objs.map(_.toMap)
--- End diff --
Probably use `@unchecked` here:
- `java.util.ArrayList[JMap[String, _] @unchecked]`
- `JMap[String @unchecked, _] => Seq(obj.toMap)`
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---