Search in sources :

Example 1 with IndexPopulator

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

Example 2 with IndexPopulator

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

Example 3 with IndexPopulator

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

Example 4 with IndexPopulator

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

Example 5 with IndexPopulator

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