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();
}
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());
}
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());
}
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();
});
}
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);
}
Aggregations