Пример #1
0
        public void can_records_user_value()
        {
            var reservoir = new DefaultAlgorithmRReservoir(100);

            reservoir.Update(2L, "B");
            reservoir.Update(1L, "A");

            reservoir.GetSnapshot().MinUserValue.Should().Be("A");
            reservoir.GetSnapshot().MaxUserValue.Should().Be("B");
        }
Пример #2
0
        public void UniformReservoir()
        {
            var reservoir = new DefaultAlgorithmRReservoir(Constants.ReservoirSampling.DefaultSampleSize);

            foreach (var sample in _samples)
            {
                reservoir.Update(sample);
            }

            var snapshot = reservoir.GetSnapshot();

            AssertValues(snapshot);
        }
Пример #3
0
        public void of_100_out_of_1000_elements()
        {
            var reservoir = new DefaultAlgorithmRReservoir(100);

            for (var i = 0; i < 1000; i++)
            {
                reservoir.Update(i);
            }

            reservoir.Size.Should().Be(100);
            reservoir.GetSnapshot().Size.Should().Be(100);
            reservoir.GetSnapshot().Values.Should().OnlyContain(v => 0 <= v && v < 1000);
        }
 public void Update()
 {
     _reservoir.Update(_fixture.Rnd.Next(0, 1000), _fixture.RandomUserValue);
 }