Reservoir Sampler extracted from Alex Holmes's Hadoop in Practice repository.