use of org.neo4j.kernel.api.index.IndexPopulator in project neo4j by neo4j.
the class BatchingMultipleIndexPopulatorTest method addPopulator.
private static IndexPopulator addPopulator(BatchingMultipleIndexPopulator batchingPopulator, NewIndexDescriptor descriptor) {
IndexPopulator populator = mock(IndexPopulator.class);
IndexProxyFactory indexProxyFactory = mock(IndexProxyFactory.class);
FailedIndexProxyFactory failedIndexProxyFactory = mock(FailedIndexProxyFactory.class);
FlippableIndexProxy flipper = new FlippableIndexProxy();
flipper.setFlipTarget(indexProxyFactory);
batchingPopulator.addPopulator(populator, descriptor.schema().getLabelId(), descriptor, new SchemaIndexProvider.Descriptor("foo", "1"), flipper, failedIndexProxyFactory, "testIndex");
return populator;
}
use of org.neo4j.kernel.api.index.IndexPopulator in project neo4j by neo4j.
the class BatchingMultipleIndexPopulatorTest method batchIsFlushedWhenThresholdReached.
@Test
public void batchIsFlushedWhenThresholdReached() throws Exception {
setProperty(BATCH_SIZE_NAME, 2);
NodeUpdates update1 = nodeUpdates(1, propertyId, "foo", labelId);
NodeUpdates update2 = nodeUpdates(2, propertyId, "bar", labelId);
NodeUpdates update3 = nodeUpdates(3, propertyId, "baz", labelId);
IndexStoreView storeView = newStoreView(update1, update2, update3);
BatchingMultipleIndexPopulator batchingPopulator = new BatchingMultipleIndexPopulator(storeView, sameThreadExecutor(), NullLogProvider.getInstance());
IndexPopulator populator = addPopulator(batchingPopulator, index1);
batchingPopulator.indexAllNodes().run();
verify(populator).add(Arrays.asList(forIndex(update1, index1), forIndex(update2, index1)));
verify(populator).add(singletonList(forIndex(update3, index1)));
}
use of org.neo4j.kernel.api.index.IndexPopulator in project neo4j by neo4j.
the class IndexPopulationJobTest method shouldLogJobProgress.
@Test
public void shouldLogJobProgress() throws Exception {
// Given
createNode(map(name, "irrelephant"), FIRST);
AssertableLogProvider logProvider = new AssertableLogProvider();
FlippableIndexProxy index = mock(FlippableIndexProxy.class);
IndexPopulator populator = spy(inMemoryPopulator(false));
IndexPopulationJob job = newIndexPopulationJob(populator, index, indexStoreView, logProvider, false);
// When
job.run();
// Then
LogMatcherBuilder match = inLog(IndexPopulationJob.class);
logProvider.assertExactly(match.info("Index population started: [%s]", ":FIRST(name)"), match.info("Index population completed. Index is now online: [%s]", ":FIRST(name)"));
}
use of org.neo4j.kernel.api.index.IndexPopulator in project neo4j by neo4j.
the class IndexPopulationJobTest method shouldPopulateIndexWithASmallDataset.
@Test
public void shouldPopulateIndexWithASmallDataset() throws Exception {
// GIVEN
String value = "Mattias";
long node1 = createNode(map(name, value), FIRST);
createNode(map(name, value), SECOND);
createNode(map(age, 31), FIRST);
long node4 = createNode(map(age, 35, name, value), FIRST);
IndexPopulator populator = spy(inMemoryPopulator(false));
IndexPopulationJob job = newIndexPopulationJob(populator, new FlippableIndexProxy(), false);
LabelSchemaDescriptor descriptor = SchemaDescriptorFactory.forLabel(0, 0);
// WHEN
job.run();
// THEN
IndexEntryUpdate update1 = IndexEntryUpdate.add(node1, descriptor, value);
IndexEntryUpdate update2 = add(node4, descriptor, value);
verify(populator).create();
verify(populator).configureSampling(true);
verify(populator).includeSample(update1);
verify(populator).includeSample(update2);
verify(populator, times(2)).add(anyListOf(IndexEntryUpdate.class));
verify(populator).sampleResult();
verify(populator).close(true);
verifyNoMoreInteractions(populator);
}
use of org.neo4j.kernel.api.index.IndexPopulator in project neo4j by neo4j.
the class IndexPopulationJobTest method shouldFlipToFailedUsingFailedIndexProxyFactory.
@Test
public void shouldFlipToFailedUsingFailedIndexProxyFactory() throws Exception {
// Given
FailedIndexProxyFactory failureDelegateFactory = mock(FailedIndexProxyFactory.class);
IndexPopulator populator = spy(inMemoryPopulator(false));
IndexPopulationJob job = newIndexPopulationJob(failureDelegateFactory, populator, new FlippableIndexProxy(), indexStoreView, NullLogProvider.getInstance(), false);
IllegalStateException failure = new IllegalStateException("not successful");
doThrow(failure).when(populator).close(true);
// When
job.run();
// Then
verify(failureDelegateFactory).create(any(Throwable.class));
}
Aggregations