One important amendment to your question - the partition data structure that is open in time mapPartitionsis Iterator, not Iterable. Here's the difference in the interface:
Iterator next() hasNext(), . next() ( ).Iterable Iterator, . , .
, Iterator . , next(). Spark (sc.textFile), .
iterator.toArray, , , . (Spark , ), ( , Int) ( AnyRef, Array[_]). .
, - , , . - GC, , !