/**
* @note Due to complications in the internal implementation, this method will raise an
* exception if called on an RDD of
Nothing
or
Null
. This may be come up in practice
* because, for example, the type of
parallelize(Seq())
is
RDD[Nothing]
.
* (`parallelize(Seq())` should be avoided anyway in favor of
parallelize(Seq[T]())
.)
*
@return true if and only if the RDD contains no elements at all. Note that an RDD
* may be empty even when it has at least 1 partition.
*/
def isEmpty(): Boolean = withScope {
partitions.length == 0 || take(1).length == 0
}
https://github.com/apache/spark/blob/master/core/src/main/scala/org/apache/spark/rdd/RDD.scala#L1432-L1443