[SPARK-3250] Implement Gap Sampling optimization for random sampling

More efficient sampling, based on Gap Sampling optimization:
http://erikerlandson.github.io/blog/2014/09/11/faster-random-samples-with-gap-sampling/

Here I'd argue 0.0 is clearer than 0d. Really minor, just curious if people wanted to have any informal standard or opinion about such things.