In general, this looks like a single funciton. Maybe we should restructure it to turn this into an Object, and define a coalesce function the CoalescedRDD can call?