use of org.neo4j.test.scheduler.CallingThreadJobScheduler in project neo4j by neo4j.
the class BatchingMultipleIndexPopulatorTest method populateFromQueuePopulatesWhenThresholdReached.
@Test
void populateFromQueuePopulatesWhenThresholdReached() throws Exception {
FullScanStoreView storeView = new FullScanStoreView(LockService.NO_LOCK_SERVICE, () -> mock(StorageReader.class), Config.defaults(), jobScheduler);
MultipleIndexPopulator batchingPopulator = new MultipleIndexPopulator(storeView, NullLogProvider.getInstance(), EntityType.NODE, mock(SchemaState.class), new CallingThreadJobScheduler(), tokens, NULL, INSTANCE, "", AUTH_DISABLED, Config.defaults(GraphDatabaseInternalSettings.index_population_queue_threshold, 2));
IndexPopulator populator1 = addPopulator(batchingPopulator, index1);
IndexUpdater updater1 = mock(IndexUpdater.class);
when(populator1.newPopulatingUpdater(any(), any())).thenReturn(updater1);
IndexPopulator populator2 = addPopulator(batchingPopulator, index42);
IndexUpdater updater2 = mock(IndexUpdater.class);
when(populator2.newPopulatingUpdater(any(), any())).thenReturn(updater2);
batchingPopulator.createStoreScan(NULL);
IndexEntryUpdate<?> update1 = add(1, index1.schema(), "foo");
IndexEntryUpdate<?> update2 = add(2, index42.schema(), "bar");
IndexEntryUpdate<?> update3 = add(3, index1.schema(), "baz");
batchingPopulator.queueConcurrentUpdate(update1);
batchingPopulator.queueConcurrentUpdate(update2);
batchingPopulator.queueConcurrentUpdate(update3);
batchingPopulator.applyExternalUpdates(42);
verify(updater1).process(update1);
verify(updater1).process(update3);
verify(updater2).process(update2);
}
use of org.neo4j.test.scheduler.CallingThreadJobScheduler in project neo4j by neo4j.
the class BatchingMultipleIndexPopulatorTest method pendingBatchesFlushedAfterStoreScan.
@Test
void pendingBatchesFlushedAfterStoreScan() throws Exception {
Update update1 = nodeUpdate(1, propertyId, "foo", labelId);
Update update2 = nodeUpdate(2, propertyId, "bar", labelId);
Update update3 = nodeUpdate(3, propertyId, "baz", labelId);
Update update42 = nodeUpdate(4, 42, "42", 42);
IndexStoreView storeView = newStoreView(update1, update2, update3, update42);
MultipleIndexPopulator batchingPopulator = new MultipleIndexPopulator(storeView, NullLogProvider.getInstance(), EntityType.NODE, mock(SchemaState.class), new CallingThreadJobScheduler(), tokens, NULL, INSTANCE, "", AUTH_DISABLED, Config.defaults());
IndexPopulator populator1 = addPopulator(batchingPopulator, index1);
IndexPopulator populator42 = addPopulator(batchingPopulator, index42);
batchingPopulator.createStoreScan(NULL).run(NO_EXTERNAL_UPDATES);
verify(populator1).add(eq(forUpdates(index1, update1, update2, update3)), any());
verify(populator42).add(eq(forUpdates(index42, update42)), any());
}
use of org.neo4j.test.scheduler.CallingThreadJobScheduler in project neo4j by neo4j.
the class BatchingMultipleIndexPopulatorTest method populateFromQueueDoesNothingIfThresholdNotReached.
@Test
void populateFromQueueDoesNothingIfThresholdNotReached() throws Exception {
MultipleIndexPopulator batchingPopulator = new MultipleIndexPopulator(mock(IndexStoreView.class), NullLogProvider.getInstance(), EntityType.NODE, mock(SchemaState.class), new CallingThreadJobScheduler(), tokens, NULL, INSTANCE, "", AUTH_DISABLED, Config.defaults(GraphDatabaseInternalSettings.index_population_queue_threshold, 5));
IndexPopulator populator = addPopulator(batchingPopulator, index1);
IndexUpdater updater = mock(IndexUpdater.class);
when(populator.newPopulatingUpdater(any(), any())).thenReturn(updater);
IndexEntryUpdate<?> update1 = add(1, index1.schema(), "foo");
IndexEntryUpdate<?> update2 = add(2, index1.schema(), "bar");
batchingPopulator.queueConcurrentUpdate(update1);
batchingPopulator.queueConcurrentUpdate(update2);
assertThat(batchingPopulator.needToApplyExternalUpdates()).isFalse();
verify(updater, never()).process(any(ValueIndexEntryUpdate.class));
verify(populator, never()).newPopulatingUpdater(any(), any());
}
Aggregations