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