Esempio n. 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustCombineSamples()
        public virtual void MustCombineSamples()
        {
            // given
            int sumIndexSize    = 0;
            int sumUniqueValues = 0;
            int sumSampleSize   = 0;

            IndexSample[] samples = new IndexSample[_providers.Count];
            for (int i = 0; i < samples.Length; i++)
            {
                int indexSize    = Random.Next(0, 1_000_000);
                int uniqueValues = Random.Next(0, 1_000_000);
                int sampleSize   = Random.Next(0, 1_000_000);
                samples[i]       = new IndexSample(indexSize, uniqueValues, sampleSize);
                sumIndexSize    += indexSize;
                sumUniqueValues += uniqueValues;
                sumSampleSize   += sampleSize;
            }

            // when
            IndexSample fusionSample = FusionIndexSampler.CombineSamples(Arrays.asList(samples));

            // then
            assertEquals(sumIndexSize, fusionSample.IndexSize());
            assertEquals(sumUniqueValues, fusionSample.UniqueValues());
            assertEquals(sumSampleSize, fusionSample.SampleSize());
        }
Esempio n. 2
0
        private static void VerifySamplingResult(UniqueIndexSampler sampler, long expectedValue)
        {
            IndexSample sample = sampler.Result();

            assertEquals(expectedValue, sample.IndexSize());
            assertEquals(expectedValue, sample.UniqueValues());
            assertEquals(expectedValue, sample.SampleSize());
        }
Esempio n. 3
0
        public virtual IndexSample Combine(IndexSample sample1, IndexSample sample2)
        {
            long indexSize    = Math.addExact(sample1.IndexSize(), sample2.IndexSize());
            long uniqueValues = Math.addExact(sample1.UniqueValues(), sample2.UniqueValues());
            long sampleSize   = Math.addExact(sample1.SampleSize(), sample2.SampleSize());

            return(new IndexSample(indexSize, uniqueValues, sampleSize));
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSampleUpdatesIfConfiguredForOnlineSampling() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
            public virtual void ShouldSampleUpdatesIfConfiguredForOnlineSampling()
            {
                // GIVEN
                try
                {
                    outerInstance.populator.create();
                    IndexEntryUpdate <IndexDescriptor>[] scanUpdates = valueCreatorUtil.someUpdates(random);
                    outerInstance.populator.add(Arrays.asList(scanUpdates));
                    IEnumerator <IndexEntryUpdate <IndexDescriptor> > generator = valueCreatorUtil.randomUpdateGenerator(random);
                    Value[] updates = new Value[5];
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    updates[0] = generator.next().values()[0];
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    updates[1] = generator.next().values()[0];
                    updates[2] = updates[1];
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    updates[3] = generator.next().values()[0];
                    updates[4] = updates[3];
                    using (IndexUpdater updater = outerInstance.populator.newPopulatingUpdater(NullPropertyAccessor))
                    {
                        long nodeId = 1000;
                        foreach (Value value in updates)
                        {
                            IndexEntryUpdate <IndexDescriptor> update = valueCreatorUtil.add(nodeId++, value);
                            updater.Process(update);
                        }
                    }

                    // WHEN
                    outerInstance.populator.scanCompleted(nullInstance);
                    IndexSample sample = outerInstance.populator.sampleResult();

                    // THEN
                    Value[] allValues = Arrays.copyOf(updates, updates.Length + scanUpdates.Length);
                    Array.Copy(AsValues(scanUpdates), 0, allValues, updates.Length, scanUpdates.Length);
                    assertEquals(updates.Length + scanUpdates.Length, sample.SampleSize());
                    assertEquals(countUniqueValues(allValues), sample.UniqueValues());
                    assertEquals(updates.Length + scanUpdates.Length, sample.IndexSize());
                }
                finally
                {
                    outerInstance.populator.close(true);
                }
            }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSampleUpdates() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
            public virtual void ShouldSampleUpdates()
            {
                // GIVEN
                outerInstance.populator.create();
                IndexEntryUpdate <IndexDescriptor>[] updates = valueCreatorUtil.someUpdates(random);

                // WHEN
                outerInstance.populator.add(asList(updates));
                foreach (IndexEntryUpdate <IndexDescriptor> update in updates)
                {
                    outerInstance.populator.includeSample(update);
                }
                outerInstance.populator.scanCompleted(nullInstance);
                IndexSample sample = outerInstance.populator.sampleResult();

                // THEN
                assertEquals(updates.Length, sample.SampleSize());
                assertEquals(updates.Length, sample.UniqueValues());
                assertEquals(updates.Length, sample.IndexSize());
                outerInstance.populator.close(true);
            }