Search in sources :

Example 1 with PopulationProgress

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

the class NodeStoreScanTest method shouldSeeZeroProgressBeforeRunStarted.

@Test
void shouldSeeZeroProgressBeforeRunStarted() {
    // given
    NodeStoreScan scan = new NodeStoreScan(Config.defaults(), cursors, locks, mock(TokenScanConsumer.class), mock(PropertyScanConsumer.class), allPossibleLabelIds, k -> true, false, jobScheduler, NULL, INSTANCE);
    // when
    PopulationProgress progressBeforeStarted = scan.getProgress();
    // then
    assertThat(progressBeforeStarted.getCompleted()).isZero();
}
Also used : NodeStoreScan(org.neo4j.kernel.impl.transaction.state.storeview.NodeStoreScan) PopulationProgress(org.neo4j.internal.kernel.api.PopulationProgress) TestPropertyScanConsumer(org.neo4j.kernel.impl.transaction.state.storeview.TestPropertyScanConsumer) PropertyScanConsumer(org.neo4j.kernel.impl.api.index.PropertyScanConsumer) TokenScanConsumer(org.neo4j.kernel.impl.api.index.TokenScanConsumer) TestTokenScanConsumer(org.neo4j.kernel.impl.transaction.state.storeview.TestTokenScanConsumer) Test(org.junit.jupiter.api.Test)

Example 2 with PopulationProgress

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

the class IndexingServiceIntegrationTest method testManualRelationshipIndexPopulation.

@ParameterizedTest
@MethodSource("parameters")
void testManualRelationshipIndexPopulation(GraphDatabaseSettings.SchemaIndex schemaIndex) throws Exception {
    setUp(schemaIndex);
    IndexDescriptor index;
    Kernel kernel = ((GraphDatabaseAPI) database).getDependencyResolver().resolveDependency(Kernel.class);
    try (KernelTransaction tx = kernel.beginTransaction(EXPLICIT, AUTH_DISABLED)) {
        int foodId = tx.tokenWrite().relationshipTypeGetOrCreateForName(FOOD_LABEL);
        int propertyId = tx.tokenWrite().propertyKeyGetOrCreateForName(PROPERTY_NAME);
        RelationTypeSchemaDescriptor schema = forRelType(foodId, propertyId);
        index = tx.schemaWrite().indexCreate(schema, "food names");
        tx.commit();
    }
    IndexingService indexingService = getIndexingService(database);
    IndexProxy indexProxy = indexingService.getIndexProxy(index);
    waitIndexOnline(indexProxy);
    assertEquals(InternalIndexState.ONLINE, indexProxy.getState());
    PopulationProgress progress = indexProxy.getIndexPopulationProgress();
    assertEquals(progress.getCompleted(), progress.getTotal());
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) PopulationProgress(org.neo4j.internal.kernel.api.PopulationProgress) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) RelationTypeSchemaDescriptor(org.neo4j.internal.schema.RelationTypeSchemaDescriptor) Kernel(org.neo4j.kernel.api.Kernel) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 3 with PopulationProgress

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

the class IndexingServiceIntegrationTest method testManualIndexPopulation.

@ParameterizedTest
@MethodSource("parameters")
void testManualIndexPopulation(GraphDatabaseSettings.SchemaIndex schemaIndex) throws InterruptedException, IndexNotFoundKernelException {
    setUp(schemaIndex);
    IndexDescriptor index;
    try (Transaction tx = database.beginTx()) {
        IndexDefinitionImpl indexDefinition = (IndexDefinitionImpl) tx.schema().indexFor(Label.label(FOOD_LABEL)).on(PROPERTY_NAME).create();
        index = indexDefinition.getIndexReference();
        tx.commit();
    }
    IndexingService indexingService = getIndexingService(database);
    IndexProxy indexProxy = indexingService.getIndexProxy(index);
    waitIndexOnline(indexProxy);
    assertEquals(InternalIndexState.ONLINE, indexProxy.getState());
    PopulationProgress progress = indexProxy.getIndexPopulationProgress();
    assertEquals(progress.getCompleted(), progress.getTotal());
}
Also used : PopulationProgress(org.neo4j.internal.kernel.api.PopulationProgress) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) Transaction(org.neo4j.graphdb.Transaction) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) IndexDefinitionImpl(org.neo4j.kernel.impl.coreapi.schema.IndexDefinitionImpl) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 4 with PopulationProgress

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

the class IndexPopulationJob method getMonitoringParams.

public JobMonitoringParams getMonitoringParams() {
    return new JobMonitoringParams(subject, databaseName, getMonitoringDescription(), () -> {
        var stateDescriptionBuilder = new StringBuilder();
        // because if there is only one, its name will already be in the job description
        if (populatedIndexes.size() > 1) {
            stateDescriptionBuilder.append("Population of indexes ");
            boolean first = true;
            for (var index : populatedIndexes) {
                if (first) {
                    first = false;
                } else {
                    stateDescriptionBuilder.append(",");
                }
                stateDescriptionBuilder.append("'").append(index.getIndexDescriptor().getName()).append("'");
            }
            stateDescriptionBuilder.append("; ");
        }
        PopulationProgress populationProgress = PopulationProgress.NONE;
        if (storeScan != null) {
            populationProgress = storeScan.getProgress();
        }
        stateDescriptionBuilder.append("Total progress: ").append(populationProgress.toIndexPopulationProgress().getCompletedPercentage()).append("%");
        return stateDescriptionBuilder.toString();
    });
}
Also used : PopulationProgress(org.neo4j.internal.kernel.api.PopulationProgress) JobMonitoringParams(org.neo4j.scheduler.JobMonitoringParams)

Example 5 with PopulationProgress

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

the class PopulationProgressTest method shouldCalculateProgressOfMultipleDifferentlyWeightedProgresses.

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

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