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()));
}
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"));
}
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"));
}
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"));
}
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"));
}
Aggregations