Search in sources :

Example 41 with IndexPopulator

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());
}
Also used : IndexPopulator(org.neo4j.kernel.api.index.IndexPopulator) Test(org.junit.Test)

Example 42 with IndexPopulator

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());
}
Also used : IndexPopulator(org.neo4j.kernel.api.index.IndexPopulator) Test(org.junit.Test)

Example 43 with IndexPopulator

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));
}
Also used : IndexPopulator(org.neo4j.kernel.api.index.IndexPopulator) Callable(java.util.concurrent.Callable) Test(org.junit.Test)

Example 44 with IndexPopulator

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;
}
Also used : IndexPopulator(org.neo4j.kernel.api.index.IndexPopulator) IndexSamplingConfig(org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig) BatchInserter(org.neo4j.unsafe.batchinsert.BatchInserter) SchemaIndexProvider(org.neo4j.kernel.api.index.SchemaIndexProvider) NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor)

Example 45 with IndexPopulator

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);
}
Also used : IndexPopulator(org.neo4j.kernel.api.index.IndexPopulator) IndexSamplingConfig(org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig) BatchInserter(org.neo4j.unsafe.batchinsert.BatchInserter) SchemaIndexProvider(org.neo4j.kernel.api.index.SchemaIndexProvider) NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) PropertyAccessor(org.neo4j.kernel.api.index.PropertyAccessor) Test(org.junit.Test)

Aggregations

IndexPopulator (org.neo4j.kernel.api.index.IndexPopulator)45 Test (org.junit.Test)37 IndexEntryUpdate (org.neo4j.kernel.api.index.IndexEntryUpdate)11 PropertyAccessor (org.neo4j.kernel.api.index.PropertyAccessor)8 IndexUpdater (org.neo4j.kernel.api.index.IndexUpdater)7 IndexSamplingConfig (org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig)7 NeoStoreIndexStoreView (org.neo4j.kernel.impl.transaction.state.storeview.NeoStoreIndexStoreView)7 NodeUpdates (org.neo4j.kernel.api.index.NodeUpdates)6 SchemaIndexProvider (org.neo4j.kernel.api.index.SchemaIndexProvider)6 NewIndexDescriptor (org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor)6 BatchInserter (org.neo4j.unsafe.batchinsert.BatchInserter)5 ExecutorService (java.util.concurrent.ExecutorService)3 LabelSchemaDescriptor (org.neo4j.kernel.api.schema_new.LabelSchemaDescriptor)3 IndexPopulation (org.neo4j.kernel.impl.api.index.MultipleIndexPopulator.IndexPopulation)3 NeoStores (org.neo4j.kernel.impl.store.NeoStores)3 NodeStore (org.neo4j.kernel.impl.store.NodeStore)3 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)3 AssertableLogProvider (org.neo4j.logging.AssertableLogProvider)3 IntPredicate (java.util.function.IntPredicate)2 NodeLabelUpdate (org.neo4j.kernel.api.labelscan.NodeLabelUpdate)2