Ejemplo n.º 1
0
            public override float?Get()
            {
                assertNotNull(StoreScanConflict);
                PopulationProgress progress = StoreScanConflict.Progress;

                return(( float )progress.Completed / ( float )progress.Total);
            }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldCalculateProgressOfSingle()
        internal virtual void ShouldCalculateProgressOfSingle()
        {
            // given
            PopulationProgress populationProgress = single(50, 100);

            // when
            float progress = populationProgress.Progress;

            // then
            assertEquals(0.5f, progress);
        }
Ejemplo n.º 3
0
        internal virtual PopulationProgress GetPopulationProgress(MultipleIndexPopulator.IndexPopulation indexPopulation)
        {
            if (_storeScan == null)
            {
                // indexing hasn't begun yet
                return(Org.Neo4j.Storageengine.Api.schema.PopulationProgress_Fields.None);
            }
            PopulationProgress storeScanProgress = _storeScan.Progress;

            return(indexPopulation.Progress(storeScanProgress));
        }
Ejemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldCalculateProgressOfMultipleDifferentlyWeightedProgresses()
        internal virtual void ShouldCalculateProgressOfMultipleDifferentlyWeightedProgresses()
        {
            // given
            PopulationProgress part1 = single(1, 3);
            PopulationProgress part2 = single(4, 10);
            PopulationProgress multi = multiple().add(part1, 3).add(part2, 1).build();

            // when
            float progress = multi.Progress;

            // then
            assertEquals(((1f / 3f) * (3f / 4f)) + ((4f / 10) * (1f / 4f)), progress);
        }
Ejemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldCalculateProgressOfMultipleEquallyWeightedProgresses()
        internal virtual void ShouldCalculateProgressOfMultipleEquallyWeightedProgresses()
        {
            // given
            PopulationProgress part1 = single(1, 1);
            PopulationProgress part2 = single(4, 10);
            PopulationProgress multi = multiple().add(part1, 1).add(part2, 1).build();

            // when
            float progress = multi.Progress;

            // then
            assertEquals(0.5f + 0.2f, progress);
        }
Ejemplo n.º 6
0
        public override PopulationProgress Progress(PopulationProgress scanProgress)
        {
            // A general note on scanProgress.getTotal(). Before the scan is completed most progress parts will base their estimates on that value.
            // It is known that it may be slightly higher since it'll be based on store high-id, not the actual count.
            // This is fine, but it creates this small "jump" in the progress in the middle somewhere when it switches from scan to merge.
            // This also exists in the most basic population progress reports, but there it will be less visible since it will jump from
            // some close-to-100 percentage to 100% and ONLINE.

            // This progress report will consist of a couple of smaller parts, weighted differently based on empirically collected values.
            // The weights will not be absolutely correct in all environments, but they don't have to be either, it will just result in some
            // slices of the percentage progression range progressing at slightly different paces. However, progression of progress reporting
            // naturally fluctuates anyway due to data set and I/O etc. so this is not an actual problem.
            Org.Neo4j.Storageengine.Api.schema.PopulationProgress_MultiBuilder builder = PopulationProgress.multiple();

            // Add scan progress (this one weights a bit heavier than the others)
            builder.Add(scanProgress, 4);

            // Add merge progress
            if (_allScanUpdates.Count > 0)
            {
                // The parts are merged in parallel so just take the first one and it will represent the whole merge progress.
                // It will be fairly accurate, but slightly off sometimes if other threads gets scheduling problems, i.e. if this part
                // finish far apart from others.
                long completed = 0;
                long total     = 0;
                if (_scanCompleted)
                {
                    // We know the actual entry count to write during merge since we have been monitoring those values
                    ThreadLocalBlockStorage part = first(_allScanUpdates);
                    completed = part.EntriesMergedConflict;
                    total     = part.TotalEntriesToMerge;
                }
                builder.Add(PopulationProgress.single(completed, total), 1);
            }

            // Add tree building incl. external updates
            PopulationProgress treeBuildProgress;

            if (_allScanUpdates.All(part => part.mergeStarted))
            {
                long entryCount = _allScanUpdates.Select(part => part.count).Sum() + _externalUpdates.count();
                treeBuildProgress = PopulationProgress.single(_numberOfAppliedScanUpdates + _numberOfAppliedExternalUpdates, entryCount);
            }
            else
            {
                treeBuildProgress = Org.Neo4j.Storageengine.Api.schema.PopulationProgress_Fields.None;
            }
            builder.Add(treeBuildProgress, 2);

            return(builder.Build());
        }
Ejemplo n.º 7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldCalculateProgressForNestedMultipleParts()
        internal virtual void ShouldCalculateProgressForNestedMultipleParts()
        {
            // given
            PopulationProgress multiPart1 = multiple().add(single(1, 1), 1).add(single(1, 5), 1).build();               // should result in 60%

            assertEquals(0.6f, multiPart1.Progress);
            PopulationProgress multiPart2 = multiple().add(single(6, 10), 1).add(single(1, 5), 1).build();               // should result in 40%

            assertEquals(0.4f, multiPart2.Progress);

            // when
            PopulationProgress_MultiBuilder builder = multiple();
            PopulationProgress all = builder.Add(multiPart1, 1).add(multiPart2, 1).build();

            // then
            assertEquals(0.5, all.Progress);
        }
Ejemplo n.º 8
0
        public override IndexPopulationProgress GetIndexPopulationProgress(IndexDefinition index)
        {
            KernelTransaction transaction = SafeAcquireTransaction(_transactionSupplier);

            try
            {
                using (Statement ignore = transaction.AcquireStatement())
                {
                    SchemaRead         schemaRead = transaction.SchemaRead();
                    IndexReference     descriptor = GetIndexReference(schemaRead, transaction.TokenRead(), (IndexDefinitionImpl)index);
                    PopulationProgress progress   = schemaRead.IndexGetPopulationProgress(descriptor);
                    return(progress.ToIndexPopulationProgress());
                }
            }
            catch (Exception e) when(e is SchemaRuleNotFoundException || e is IndexNotFoundKernelException)
            {
                throw NewIndexNotFoundException(index, e);
            }
        }
Ejemplo n.º 9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldAlwaysResultInFullyCompleted()
        internal virtual void ShouldAlwaysResultInFullyCompleted()
        {
            // given
            int partCount = Random.Next(5, 10);
            PopulationProgress_MultiBuilder builder = multiple();

            for (int i = 0; i < partCount; i++)
            {
                long total = Random.nextLong(10_000_000);
                builder.Add(single(total, total), Random.nextFloat() * Random.Next(1, 10));
            }
            PopulationProgress populationProgress = builder.Build();

            // when
            float progress = populationProgress.Progress;

            // then
            assertEquals(1f, progress);
        }
Ejemplo n.º 10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testManualIndexPopulation() throws InterruptedException, org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TestManualIndexPopulation()
        {
            using (Transaction tx = _database.beginTx())
            {
                _database.schema().indexFor(Label.label(FOOD_LABEL)).on(PROPERTY_NAME).create();
                tx.Success();
            }

            int labelId       = GetLabelId(FOOD_LABEL);
            int propertyKeyId = GetPropertyKeyId(PROPERTY_NAME);

            IndexingService indexingService = GetIndexingService(_database);
            IndexProxy      indexProxy      = indexingService.getIndexProxy(forLabel(labelId, propertyKeyId));

            WaitIndexOnline(indexProxy);
            assertEquals(InternalIndexState.ONLINE, indexProxy.State);
            PopulationProgress progress = indexProxy.IndexPopulationProgress;

            assertEquals(progress.Completed, progress.Total);
        }
Ejemplo n.º 11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testManualRelationshipIndexPopulation() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TestManualRelationshipIndexPopulation()
        {
            RelationTypeSchemaDescriptor descriptor;

            using ([email protected] tx = (( GraphDatabaseAPI )_database).DependencyResolver.resolveDependency(typeof(Kernel)).beginTransaction(@explicit, AUTH_DISABLED))
            {
                int foodId     = tx.TokenWrite().relationshipTypeGetOrCreateForName(FOOD_LABEL);
                int propertyId = tx.TokenWrite().propertyKeyGetOrCreateForName(PROPERTY_NAME);
                descriptor = forRelType(foodId, propertyId);
                tx.SchemaWrite().indexCreate(descriptor);
                tx.Success();
            }

            IndexingService indexingService = GetIndexingService(_database);
            IndexProxy      indexProxy      = indexingService.getIndexProxy(descriptor);

            WaitIndexOnline(indexProxy);
            assertEquals(InternalIndexState.ONLINE, indexProxy.State);
            PopulationProgress progress = indexProxy.IndexPopulationProgress;

            assertEquals(progress.Completed, progress.Total);
        }
Ejemplo n.º 12
0
 internal virtual PopulationProgress Progress(PopulationProgress storeScanProgress)
 {
     return(Populator.progress(storeScanProgress));
 }
Ejemplo n.º 13
0
 public virtual PopulationProgress_MultiBuilder Add(PopulationProgress part, float weight)
 {
     Parts.Add(Pair.of(part, weight));
     TotalWeight += weight;
     return(this);
 }