I know the method rdd.first()
which gives me the first element in an RDD
.
Also, there is the method rdd.take(num)
Which gives me the first num
elements.
But isn't there a possibility to get an element by index?
RDDs are not indexed, in majority of cases don't guarantee the order and don't support efficient single item access.
You can
zipWithIndex
and filter
. zipWithIndex
, swap elements and lookup
. but this is not advised, requires linear scan, and might have non-deterministic behavior.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.