Search in sources :

Example 21 with IndexUpdater

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

the class TokenIndexAccessorTest method processMustThrowAfterClose.

@Test
void processMustThrowAfterClose() throws Exception {
    // given
    IndexUpdater updater = accessor.newUpdater(ONLINE, NULL);
    updater.close();
    assertThrows(IllegalStateException.class, () -> updater.process(simpleUpdate()));
}
Also used : IndexUpdater(org.neo4j.kernel.api.index.IndexUpdater) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 22 with IndexUpdater

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

the class UniqueDatabaseIndexPopulatorTest method shouldRemoveEntryForNodeThatHasAlreadyBeenIndexed.

@Test
void shouldRemoveEntryForNodeThatHasAlreadyBeenIndexed() throws Exception {
    // given
    populator = newPopulator();
    addUpdate(populator, 1, "value1");
    // when
    IndexUpdater updater = populator.newPopulatingUpdater(nodePropertyAccessor, NULL);
    updater.process(remove(1, schemaDescriptor, "value1"));
    populator.close(true, NULL);
    // then
    assertEquals(Collections.EMPTY_LIST, getAllNodes(getDirectory(), "value1"));
}
Also used : IndexUpdater(org.neo4j.kernel.api.index.IndexUpdater) Test(org.junit.jupiter.api.Test)

Example 23 with IndexUpdater

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

the class UniqueDatabaseIndexPopulatorTest method shouldBeAbleToHandleSwappingOfIndexValues.

@Test
void shouldBeAbleToHandleSwappingOfIndexValues() throws Exception {
    // given
    populator = newPopulator();
    addUpdate(populator, 1, "value1");
    addUpdate(populator, 2, "value2");
    // when
    IndexUpdater updater = populator.newPopulatingUpdater(nodePropertyAccessor, NULL);
    updater.process(change(1, schemaDescriptor, "value1", "value2"));
    updater.process(change(2, schemaDescriptor, "value2", "value1"));
    populator.close(true, NULL);
    // then
    assertEquals(singletonList(2L), getAllNodes(getDirectory(), "value1"));
    assertEquals(singletonList(1L), getAllNodes(getDirectory(), "value2"));
}
Also used : IndexUpdater(org.neo4j.kernel.api.index.IndexUpdater) Test(org.junit.jupiter.api.Test)

Example 24 with IndexUpdater

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

the class UniqueDatabaseIndexPopulatorTest method shouldUpdateEntryForNodeThatHasPropertyRemovedAndThenAddedAgain.

@Test
void shouldUpdateEntryForNodeThatHasPropertyRemovedAndThenAddedAgain() throws Exception {
    // given
    populator = newPopulator();
    addUpdate(populator, 1, "value1");
    // when
    IndexUpdater updater = populator.newPopulatingUpdater(nodePropertyAccessor, NULL);
    updater.process(remove(1, schemaDescriptor, "value1"));
    updater.process(add(1, schemaDescriptor, "value1"));
    populator.close(true, NULL);
    // then
    assertEquals(singletonList(1L), getAllNodes(getDirectory(), "value1"));
}
Also used : IndexUpdater(org.neo4j.kernel.api.index.IndexUpdater) Test(org.junit.jupiter.api.Test)

Example 25 with IndexUpdater

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

the class UniqueDatabaseIndexPopulatorTest method shouldNotRejectDuplicateEntryOnSameNodeIdAfterUsingPopulatingUpdater.

@Test
void shouldNotRejectDuplicateEntryOnSameNodeIdAfterUsingPopulatingUpdater() throws Exception {
    // given
    populator = newPopulator();
    when(nodePropertyAccessor.getNodePropertyValue(1, PROPERTY_KEY_ID, NULL)).thenReturn(Values.of("value1"));
    IndexUpdater updater = populator.newPopulatingUpdater(nodePropertyAccessor, NULL);
    updater.process(add(1, schemaDescriptor, "value1"));
    updater.process(change(1, schemaDescriptor, "value1", "value1"));
    updater.close();
    addUpdate(populator, 2, "value2");
    addUpdate(populator, 3, "value3");
    // when
    populator.verifyDeferredConstraints(nodePropertyAccessor);
    populator.close(true, NULL);
    // then
    assertEquals(singletonList(1L), getAllNodes(getDirectory(), "value1"));
    assertEquals(singletonList(2L), getAllNodes(getDirectory(), "value2"));
    assertEquals(singletonList(3L), getAllNodes(getDirectory(), "value3"));
}
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