[SPARK-2534] Avoid pulling in the entire RDD in various operators

This should go into both master and branch-1.0.
And when I said non-obvious, I mean just from looking at the function name and input arguments. Here it is actually straightforward to infer from the remaining lines, but in other situations it is less so.