One example is that you'd like to set up jdbc connection for each partition
and share this connection across the records.
mapPartitions is much more like the paradigm of mapper in mapreduce. In the
mapper of mapreduce, you have setup method to do any initialization stuff
before processing the spl
I think one of the primary cases where mapPartitions is useful if you are
going to be doing any setup work that can be re-used between processing
each element, this way the setup work only needs to be done once per
partition (for example creating an instance of jodatime).
Both map and mapPartition