use of org.neo4j.kernel.api.index.IndexPopulator in project neo4j by neo4j.
the class MultipleIndexPopulatorTest method populationsRemovedDuringFlip.
@Test
public void populationsRemovedDuringFlip() throws Exception {
IndexPopulator indexPopulator1 = createIndexPopulator();
IndexPopulator indexPopulator2 = createIndexPopulator();
addPopulator(indexPopulator1, 1);
addPopulator(indexPopulator2, 2);
assertTrue(multipleIndexPopulator.hasPopulators());
multipleIndexPopulator.flipAfterPopulation();
assertFalse(multipleIndexPopulator.hasPopulators());
}
use of org.neo4j.kernel.api.index.IndexPopulator in project neo4j by neo4j.
the class MultipleIndexPopulatorTest method testIndexFlip.
@Test
public void testIndexFlip() throws IOException {
IndexProxyFactory indexProxyFactory = mock(IndexProxyFactory.class);
FailedIndexProxyFactory failedIndexProxyFactory = mock(FailedIndexProxyFactory.class);
FlippableIndexProxy flipper = new FlippableIndexProxy();
flipper.setFlipTarget(indexProxyFactory);
IndexPopulator indexPopulator1 = createIndexPopulator();
IndexPopulator indexPopulator2 = createIndexPopulator();
addPopulator(indexPopulator1, 1, flipper, failedIndexProxyFactory);
addPopulator(indexPopulator2, 2, flipper, failedIndexProxyFactory);
when(indexPopulator1.sampleResult()).thenThrow(getSampleError());
multipleIndexPopulator.indexAllNodes();
multipleIndexPopulator.flipAfterPopulation();
verify(indexPopulator1).close(false);
verify(failedIndexProxyFactory, times(1)).create(any(RuntimeException.class));
verify(indexPopulator2).close(true);
verify(indexPopulator2).sampleResult();
verify(indexStoreView).replaceIndexCounts(anyLong(), anyLong(), anyLong(), anyLong());
}
use of org.neo4j.kernel.api.index.IndexPopulator in project neo4j by neo4j.
the class MultipleIndexPopulatorTest method testFlipAfterPopulation.
@Test
public void testFlipAfterPopulation() throws Exception {
IndexPopulator indexPopulator1 = createIndexPopulator();
IndexPopulator indexPopulator2 = createIndexPopulator();
FlippableIndexProxy flipper1 = addPopulator(indexPopulator1, 1).flipper;
FlippableIndexProxy flipper2 = addPopulator(indexPopulator2, 2).flipper;
multipleIndexPopulator.flipAfterPopulation();
verify(flipper1).flip(any(Callable.class), any(FailedIndexProxyFactory.class));
verify(flipper2).flip(any(Callable.class), any(FailedIndexProxyFactory.class));
}
use of org.neo4j.kernel.api.index.IndexPopulator in project neo4j by neo4j.
the class BatchInsertTest method dbWithIndexAndSingleIndexedNode.
private long dbWithIndexAndSingleIndexedNode() throws Exception {
IndexPopulator populator = mock(IndexPopulator.class);
SchemaIndexProvider provider = mock(SchemaIndexProvider.class);
when(provider.getProviderDescriptor()).thenReturn(InMemoryIndexProviderFactory.PROVIDER_DESCRIPTOR);
when(provider.getPopulator(anyLong(), any(NewIndexDescriptor.class), any(IndexSamplingConfig.class))).thenReturn(populator);
BatchInserter inserter = newBatchInserterWithSchemaIndexProvider(singleInstanceSchemaIndexProviderFactory(InMemoryIndexProviderFactory.KEY, provider));
inserter.createDeferredSchemaIndex(label("Hacker")).on("handle").create();
long nodeId = inserter.createNode(map("handle", "Jakewins"), label("Hacker"));
inserter.shutdown();
return nodeId;
}
use of org.neo4j.kernel.api.index.IndexPopulator in project neo4j by neo4j.
the class BatchInsertTest method shouldRunConstraintPopulationJobAtShutdown.
@Test
public void shouldRunConstraintPopulationJobAtShutdown() throws Throwable {
// GIVEN
IndexPopulator populator = mock(IndexPopulator.class);
SchemaIndexProvider provider = mock(SchemaIndexProvider.class);
when(provider.getProviderDescriptor()).thenReturn(InMemoryIndexProviderFactory.PROVIDER_DESCRIPTOR);
when(provider.getPopulator(anyLong(), any(NewIndexDescriptor.class), any(IndexSamplingConfig.class))).thenReturn(populator);
BatchInserter inserter = newBatchInserterWithSchemaIndexProvider(singleInstanceSchemaIndexProviderFactory(InMemoryIndexProviderFactory.KEY, provider));
inserter.createDeferredConstraint(label("Hacker")).assertPropertyIsUnique("handle").create();
long nodeId = inserter.createNode(map("handle", "Jakewins"), label("Hacker"));
// WHEN
inserter.shutdown();
// THEN
verify(provider).init();
verify(provider).start();
verify(provider).getPopulator(anyLong(), any(NewIndexDescriptor.class), any(IndexSamplingConfig.class));
verify(populator).create();
verify(populator).add(singletonList(IndexEntryUpdate.add(nodeId, internalUniqueIndex.schema(), "Jakewins")));
verify(populator).verifyDeferredConstraints(any(PropertyAccessor.class));
verify(populator).close(true);
verify(provider).stop();
verify(provider).shutdown();
verifyNoMoreInteractions(populator);
}
Aggregations