Github user srowen commented on the pull request:
https://github.com/apache/spark/pull/4534#issuecomment-73955339
I think I have a solution. A `Seq[Nothing]` must be empty since there are
no instances of `Nothing`. So I think this can be fixed (and optimized) by
returning an `EmptyRDD` from `parallelize` when given an empty argument.
```
def parallelize[T: ClassTag](seq: Seq[T], numSlices: Int =
defaultParallelism): RDD[T] = {
assertNotStopped()
if (seq.isEmpty) {
new EmptyRDD[T](this)
} else {
new ParallelCollectionRDD[T](this, seq, numSlices, Map[Int,
Seq[String]]())
}
}
```
Witness:
```
scala> sc.parallelize(Seq(), 1).isEmpty
res0: Boolean = true
scala> sc.parallelize(Seq(), 1).take(1)
res1: Array[Nothing] = Array()
```
It deserves a unit test for both of these and a run through all the tests.
Want to try that?
---
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.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]