[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/

This is quite minor and tangential, but, is it clearer to write doubles with a `.0`? and to omit the type of the definition?