FastReservoirSampler { public List<T> sample() { return Collections.unmodifiableList(candidates); } FastReservoirSampler(int nbSamples, long seed);  FastReservoirSampler(int samples); void onCompleted(boolean b); void onNext(T v); List<T> sample(); void clear();  }
@Test public void testSample() { sampler = new FastReservoirSampler<TestRowStruct>(SAMPLE_SIZE, TestConstants.RANDOM_SEED); sampler.clear(); for (TestRowStruct row : testers) { sampler.onNext(row); } sampler.onCompleted(true); List<TestRowStruct> sampleList = sampler.sample(); for (int i = 0; i < sampleList.size(); i++) { assertEquals(EXPECTED_SAMPLES[i], sampleList.get(i).getId()); } }