Implement reservoir sampling.