For completeness, we also need variants that accept PairFlatMapFunction and DoubleFlatMapFunction, etc. and produce JavaPairRDD, and JavaDoubleRDD.

See how this is done above for the version of mapPartitions without the preservesPartitioning argument.