Search in sources :

Example 41 with IndexUpdater

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

the class MultipleIndexPopulatorTest method testMultiplePopulatorUpdater.

@Test
void testMultiplePopulatorUpdater() throws IndexEntryConflictException, FlipFailedKernelException {
    IndexUpdater indexUpdater1 = mock(IndexUpdater.class);
    IndexPopulator indexPopulator1 = createIndexPopulator(indexUpdater1);
    IndexPopulator indexPopulator2 = createIndexPopulator();
    addPopulator(indexPopulator1, 1);
    addPopulator(indexPopulator2, 2);
    doThrow(getPopulatorException()).when(indexPopulator2).newPopulatingUpdater(any(NodePropertyAccessor.class), any());
    IndexUpdater multipleIndexUpdater = multipleIndexPopulator.newPopulatingUpdater(mock(NodePropertyAccessor.class), NULL);
    IndexEntryUpdate<?> propertyUpdate = createIndexEntryUpdate(index1);
    multipleIndexUpdater.process(propertyUpdate);
    checkPopulatorFailure(indexPopulator2);
    verify(indexUpdater1).process(propertyUpdate);
}
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 42 with IndexUpdater

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

the class MultipleIndexPopulatorTest method testMultiplePropertyUpdateFailures.

@Test
void testMultiplePropertyUpdateFailures() throws IndexEntryConflictException, FlipFailedKernelException {
    NodePropertyAccessor nodePropertyAccessor = mock(NodePropertyAccessor.class);
    IndexEntryUpdate<?> update1 = add(1, index1, "foo");
    IndexEntryUpdate<?> update2 = add(2, index1, "bar");
    IndexUpdater updater = mock(IndexUpdater.class);
    IndexPopulator populator = createIndexPopulator(updater);
    addPopulator(populator, 1);
    doThrow(getPopulatorException()).when(updater).process(any(IndexEntryUpdate.class));
    IndexUpdater multipleIndexUpdater = multipleIndexPopulator.newPopulatingUpdater(nodePropertyAccessor, NULL);
    multipleIndexUpdater.process(update1);
    multipleIndexUpdater.process(update2);
    verify(updater).process(update1);
    verify(updater, never()).process(update2);
    verify(updater).close();
    checkPopulatorFailure(populator);
}
Also used : IndexPopulator(org.neo4j.kernel.api.index.IndexPopulator) IndexEntryUpdate(org.neo4j.storageengine.api.IndexEntryUpdate) ValueIndexEntryUpdate(org.neo4j.storageengine.api.ValueIndexEntryUpdate) NodePropertyAccessor(org.neo4j.storageengine.api.NodePropertyAccessor) IndexUpdater(org.neo4j.kernel.api.index.IndexUpdater) Test(org.junit.jupiter.api.Test)

Example 43 with IndexUpdater

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

the class MultipleIndexPopulatorTest method updateForHigherNodeIgnoredWhenUsingFullNodeStoreScan.

@Test
void updateForHigherNodeIgnoredWhenUsingFullNodeStoreScan() throws IndexEntryConflictException, FlipFailedKernelException {
    // given
    createIndexPopulator();
    multipleIndexPopulator.create(NULL);
    IndexUpdater updater = mock(IndexUpdater.class);
    IndexPopulator populator = createIndexPopulator(updater);
    IndexUpdater indexUpdater = mock(IndexUpdater.class);
    LabelSchemaDescriptor schema = SchemaDescriptor.forLabel(1, 1);
    addPopulator(populator, 1);
    // when external updates comes in
    ValueIndexEntryUpdate<LabelSchemaDescriptor> lowUpdate = IndexEntryUpdate.add(10, schema, intValue(99));
    ValueIndexEntryUpdate<LabelSchemaDescriptor> highUpdate = IndexEntryUpdate.add(20, schema, intValue(101));
    multipleIndexPopulator.queueConcurrentUpdate(lowUpdate);
    multipleIndexPopulator.queueConcurrentUpdate(highUpdate);
    // and we ask to apply them, given an entity in between the two
    multipleIndexPopulator.applyExternalUpdates(15);
    // then only the lower one should be applied, the higher one ignored
    verify(populator, times(1)).newPopulatingUpdater(any(), any());
    verify(updater).process(lowUpdate);
    verify(updater, never()).process(highUpdate);
    verify(indexUpdater, never()).process(any(IndexEntryUpdate.class));
}
Also used : IndexPopulator(org.neo4j.kernel.api.index.IndexPopulator) IndexEntryUpdate(org.neo4j.storageengine.api.IndexEntryUpdate) ValueIndexEntryUpdate(org.neo4j.storageengine.api.ValueIndexEntryUpdate) LabelSchemaDescriptor(org.neo4j.internal.schema.LabelSchemaDescriptor) IndexUpdater(org.neo4j.kernel.api.index.IndexUpdater) Test(org.junit.jupiter.api.Test)

Example 44 with IndexUpdater

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

the class IndexUpdaterMapTest method shouldRetrieveSameUpdaterFromIndexMapForExistingIndexWhenCalledTwice.

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

Example 45 with IndexUpdater

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

the class IndexUpdaterMapTest method shouldRetrieveUpdateUsingLabelAndProperty.

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

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