Reservoir sampling implementation.

This is going to be used in https://issues.apache.org/jira/browse/SPARK-2568