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