Search in sources :

Example 61 with IndexUpdater

use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.

the class MultipleIndexPopulatorTest method testPropertyUpdateFailure.

@Test
void testPropertyUpdateFailure() throws IndexEntryConflictException, FlipFailedKernelException {
    IndexEntryUpdate<?> propertyUpdate = createIndexEntryUpdate(index1);
    IndexUpdater indexUpdater1 = mock(IndexUpdater.class);
    IndexPopulator indexPopulator1 = createIndexPopulator(indexUpdater1);
    addPopulator(indexPopulator1, 1);
    doThrow(getPopulatorException()).when(indexUpdater1).process(propertyUpdate);
    IndexUpdater multipleIndexUpdater = multipleIndexPopulator.newPopulatingUpdater(mock(NodePropertyAccessor.class), NULL);
    multipleIndexUpdater.process(propertyUpdate);
    verify(indexUpdater1).close();
    checkPopulatorFailure(indexPopulator1);
}
Also used : IndexPopulator(org.neo4j.kernel.api.index.IndexPopulator) IndexUpdater(org.neo4j.kernel.api.index.IndexUpdater) NodePropertyAccessor(org.neo4j.storageengine.api.NodePropertyAccessor) Test(org.junit.jupiter.api.Test)

Example 62 with IndexUpdater

use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.

the class MultipleIndexPopulatorTest method testNonApplicableUpdaterDoNotUpdatePopulator.

@Test
void testNonApplicableUpdaterDoNotUpdatePopulator() throws IndexEntryConflictException, FlipFailedKernelException {
    IndexUpdater indexUpdater1 = mock(IndexUpdater.class);
    IndexPopulator indexPopulator1 = createIndexPopulator(indexUpdater1);
    addPopulator(indexPopulator1, 2);
    IndexUpdater multipleIndexUpdater = multipleIndexPopulator.newPopulatingUpdater(mock(NodePropertyAccessor.class), NULL);
    IndexEntryUpdate<?> propertyUpdate = createIndexEntryUpdate(index1);
    multipleIndexUpdater.process(propertyUpdate);
    verifyNoInteractions(indexUpdater1);
}
Also used : IndexPopulator(org.neo4j.kernel.api.index.IndexPopulator) IndexUpdater(org.neo4j.kernel.api.index.IndexUpdater) NodePropertyAccessor(org.neo4j.storageengine.api.NodePropertyAccessor) Test(org.junit.jupiter.api.Test)

Example 63 with IndexUpdater

use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.

the class IndexUpdaterMapTest method shouldRetrieveUpdaterFromIndexMapForExistingIndex.

@Test
void shouldRetrieveUpdaterFromIndexMapForExistingIndex() {
    // given
    indexMap.putIndexProxy(indexProxy1);
    // when
    IndexUpdater updater = updaterMap.getUpdater(schemaIndexDescriptor1, NULL);
    // then
    assertEquals(indexUpdater1, updater);
    assertEquals(1, updaterMap.size());
}
Also used : IndexUpdater(org.neo4j.kernel.api.index.IndexUpdater) Test(org.junit.jupiter.api.Test)

Example 64 with IndexUpdater

use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.

the class IndexUpdaterMapTest method before.

@BeforeEach
void before() {
    indexMap = new IndexMap();
    indexProxy1 = mock(IndexProxy.class);
    schemaIndexDescriptor1 = forSchema(forLabel(2, 3), PROVIDER_DESCRIPTOR).withName("a").materialise(0);
    indexUpdater1 = mock(IndexUpdater.class);
    when(indexProxy1.getDescriptor()).thenReturn(schemaIndexDescriptor1);
    when(indexProxy1.newUpdater(any(IndexUpdateMode.class), any(CursorContext.class))).thenReturn(indexUpdater1);
    indexProxy2 = mock(IndexProxy.class);
    schemaIndexDescriptor = forSchema(forLabel(5, 6), PROVIDER_DESCRIPTOR).withName("b").materialise(1);
    IndexUpdater indexUpdater2 = mock(IndexUpdater.class);
    when(indexProxy2.getDescriptor()).thenReturn(schemaIndexDescriptor);
    when(indexProxy2.newUpdater(any(IndexUpdateMode.class), any(CursorContext.class))).thenReturn(indexUpdater2);
    updaterMap = new IndexUpdaterMap(indexMap, IndexUpdateMode.ONLINE);
}
Also used : CursorContext(org.neo4j.io.pagecache.context.CursorContext) IndexUpdater(org.neo4j.kernel.api.index.IndexUpdater) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 65 with IndexUpdater

use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.

the class LuceneIndexAccessorIT method writeRandomThings.

private BitSet writeRandomThings(IndexAccessor index, IndexDescriptor descriptor) throws IndexEntryConflictException {
    int rounds = 200;
    int updatesPerRound = 200;
    BitSet liveEntityIds = new BitSet(rounds * updatesPerRound);
    MutableLong highEntityId = new MutableLong();
    for (int i = 0; i < rounds; i++) {
        try (IndexUpdater updater = index.newUpdater(IndexUpdateMode.RECOVERY, NULL)) {
            for (int j = 0; j < updatesPerRound; j++) {
                IndexEntryUpdate<?> update = randomUpdate(highEntityId, liveEntityIds, descriptor, random.random());
                updater.process(update);
            }
        }
        if (random.nextInt(100) == 0) {
            index.force(NULL);
        }
    }
    index.force(NULL);
    return liveEntityIds;
}
Also used : MutableLong(org.apache.commons.lang3.mutable.MutableLong) BitSet(java.util.BitSet) IndexUpdater(org.neo4j.kernel.api.index.IndexUpdater)

Aggregations

IndexUpdater (org.neo4j.kernel.api.index.IndexUpdater)94 Test (org.junit.jupiter.api.Test)61 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)22 ValueIndexEntryUpdate (org.neo4j.storageengine.api.ValueIndexEntryUpdate)13 IndexAccessor (org.neo4j.kernel.api.index.IndexAccessor)12 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)11 IndexPopulator (org.neo4j.kernel.api.index.IndexPopulator)9 Value (org.neo4j.values.storable.Value)9 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)7 CursorContext (org.neo4j.io.pagecache.context.CursorContext)7 IndexEntryUpdate (org.neo4j.storageengine.api.IndexEntryUpdate)6 SwallowingIndexUpdater (org.neo4j.kernel.impl.api.index.SwallowingIndexUpdater)5 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 Transaction (org.neo4j.graphdb.Transaction)4 IndexEntryConflictException (org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException)4 SchemaIndexTestHelper.mockIndexProxy (org.neo4j.kernel.impl.api.index.SchemaIndexTestHelper.mockIndexProxy)4 NodePropertyAccessor (org.neo4j.storageengine.api.NodePropertyAccessor)4 HashMap (java.util.HashMap)3 EnumSource (org.junit.jupiter.params.provider.EnumSource)3