Search in sources :

Example 6 with PopulationProgress

use of org.neo4j.internal.kernel.api.PopulationProgress in project neo4j by neo4j.

the class PopulationProgressTest method shouldAlwaysResultInFullyCompleted.

@Test
void shouldAlwaysResultInFullyCompleted() {
    // given
    int partCount = random.nextInt(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.nextInt(1, 10));
    }
    PopulationProgress populationProgress = builder.build();
    // when
    float progress = populationProgress.getProgress();
    // then
    assertEquals(1f, progress);
}
Also used : PopulationProgress(org.neo4j.internal.kernel.api.PopulationProgress) Test(org.junit.jupiter.api.Test)

Example 7 with PopulationProgress

use of org.neo4j.internal.kernel.api.PopulationProgress in project neo4j by neo4j.

the class PopulationProgressTest method shouldCalculateProgressOfMultipleEquallyWeightedProgresses.

@Test
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.getProgress();
    // then
    assertEquals(0.5f + 0.2f, progress);
}
Also used : PopulationProgress(org.neo4j.internal.kernel.api.PopulationProgress) Test(org.junit.jupiter.api.Test)

Example 8 with PopulationProgress

use of org.neo4j.internal.kernel.api.PopulationProgress in project neo4j by neo4j.

the class PopulationProgressTest method shouldCalculateProgressOfSingle.

@Test
void shouldCalculateProgressOfSingle() {
    // given
    PopulationProgress populationProgress = single(50, 100);
    // when
    float progress = populationProgress.getProgress();
    // then
    assertEquals(0.5f, progress);
}
Also used : PopulationProgress(org.neo4j.internal.kernel.api.PopulationProgress) Test(org.junit.jupiter.api.Test)

Example 9 with PopulationProgress

use of org.neo4j.internal.kernel.api.PopulationProgress in project neo4j by neo4j.

the class PopulationProgressTest method shouldCalculateProgressForNestedMultipleParts.

@Test
void shouldCalculateProgressForNestedMultipleParts() {
    // given
    // should result in 60%
    PopulationProgress multiPart1 = multiple().add(single(1, 1), 1).add(single(1, 5), 1).build();
    assertEquals(0.6f, multiPart1.getProgress());
    // should result in 40%
    PopulationProgress multiPart2 = multiple().add(single(6, 10), 1).add(single(1, 5), 1).build();
    assertEquals(0.4f, multiPart2.getProgress());
    // when
    PopulationProgress.MultiBuilder builder = multiple();
    PopulationProgress all = builder.add(multiPart1, 1).add(multiPart2, 1).build();
    // then
    assertEquals(0.5, all.getProgress());
}
Also used : PopulationProgress(org.neo4j.internal.kernel.api.PopulationProgress) Test(org.junit.jupiter.api.Test)

Example 10 with PopulationProgress

use of org.neo4j.internal.kernel.api.PopulationProgress in project neo4j by neo4j.

the class SchemaImpl method getIndexPopulationProgress.

@Override
public IndexPopulationProgress getIndexPopulationProgress(IndexDefinition index) {
    try {
        transaction.assertOpen();
        SchemaRead schemaRead = transaction.schemaRead();
        IndexDescriptor descriptor = getIndexReference(schemaRead, transaction.tokenRead(), (IndexDefinitionImpl) index);
        PopulationProgress progress = schemaRead.indexGetPopulationProgress(descriptor);
        return progress.toIndexPopulationProgress();
    } catch (KernelException e) {
        throw newIndexNotFoundException(index, e);
    }
}
Also used : PopulationProgress(org.neo4j.internal.kernel.api.PopulationProgress) IndexPopulationProgress(org.neo4j.graphdb.schema.IndexPopulationProgress) SchemaRead(org.neo4j.internal.kernel.api.SchemaRead) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) InvalidTransactionTypeKernelException(org.neo4j.internal.kernel.api.exceptions.InvalidTransactionTypeKernelException) IndexNotFoundKernelException(org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException) TokenCapacityExceededKernelException(org.neo4j.internal.kernel.api.exceptions.schema.TokenCapacityExceededKernelException) SchemaKernelException(org.neo4j.internal.kernel.api.exceptions.schema.SchemaKernelException) KernelException(org.neo4j.exceptions.KernelException)

Aggregations

PopulationProgress (org.neo4j.internal.kernel.api.PopulationProgress)12 Test (org.junit.jupiter.api.Test)6 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 IndexNotFoundKernelException (org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException)2 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)2 KernelException (org.neo4j.exceptions.KernelException)1 Transaction (org.neo4j.graphdb.Transaction)1 IndexPopulationProgress (org.neo4j.graphdb.schema.IndexPopulationProgress)1 InternalIndexState (org.neo4j.internal.kernel.api.InternalIndexState)1 SchemaRead (org.neo4j.internal.kernel.api.SchemaRead)1 InvalidTransactionTypeKernelException (org.neo4j.internal.kernel.api.exceptions.InvalidTransactionTypeKernelException)1 SchemaKernelException (org.neo4j.internal.kernel.api.exceptions.schema.SchemaKernelException)1 TokenCapacityExceededKernelException (org.neo4j.internal.kernel.api.exceptions.schema.TokenCapacityExceededKernelException)1 RelationTypeSchemaDescriptor (org.neo4j.internal.schema.RelationTypeSchemaDescriptor)1 Kernel (org.neo4j.kernel.api.Kernel)1 PropertyScanConsumer (org.neo4j.kernel.impl.api.index.PropertyScanConsumer)1 TokenScanConsumer (org.neo4j.kernel.impl.api.index.TokenScanConsumer)1 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)1