use of org.neo4j.storageengine.api.IndexEntryUpdate 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.storageengine.api.IndexEntryUpdate in project neo4j by neo4j.
the class BatchingMultipleIndexPopulatorTest method populatorMarkedAsFailed.
@Test
void populatorMarkedAsFailed() throws Exception {
Update update1 = nodeUpdate(1, propertyId, "aaa", labelId);
Update update2 = nodeUpdate(1, propertyId, "bbb", labelId);
IndexStoreView storeView = newStoreView(update1, update2);
RuntimeException batchFlushError = new RuntimeException("Batch failed");
IndexPopulator populator;
ExecutorService executor = Executors.newSingleThreadExecutor();
ThreadPoolJobScheduler jobScheduler = new ThreadPoolJobScheduler(executor);
try {
MultipleIndexPopulator batchingPopulator = new MultipleIndexPopulator(storeView, NullLogProvider.getInstance(), EntityType.NODE, mock(SchemaState.class), jobScheduler, tokens, NULL, INSTANCE, "", AUTH_DISABLED, Config.defaults(GraphDatabaseInternalSettings.index_population_batch_max_byte_size, 1L));
populator = addPopulator(batchingPopulator, index1);
List<IndexEntryUpdate<IndexDescriptor>> expected = forUpdates(index1, update1, update2);
doThrow(batchFlushError).when(populator).add(eq(expected), any());
batchingPopulator.createStoreScan(NULL).run(NO_EXTERNAL_UPDATES);
} finally {
jobScheduler.shutdown();
executor.awaitTermination(1, TimeUnit.MINUTES);
}
verify(populator).markAsFailed(failure(batchFlushError).asString());
}
use of org.neo4j.storageengine.api.IndexEntryUpdate in project neo4j by neo4j.
the class BlockBasedIndexPopulator method newPopulatingUpdater.
@Override
public IndexUpdater newPopulatingUpdater(CursorContext cursorContext) {
if (scanCompleted) {
// Will need the reader from newReader, which a sub-class of this class implements
return new DelegatingIndexUpdater(super.newPopulatingUpdater(cursorContext)) {
@Override
public void process(IndexEntryUpdate<?> update) throws IndexEntryConflictException {
ValueIndexEntryUpdate<?> valueUpdate = asValueUpdate(update);
validateUpdate(valueUpdate);
numberOfIndexUpdatesSinceSample.incrementAndGet();
super.process(valueUpdate);
}
};
}
return new IndexUpdater() {
private volatile boolean closed;
@Override
public void process(IndexEntryUpdate<?> update) {
assertOpen();
ValueIndexEntryUpdate<?> valueUpdate = asValueUpdate(update);
try {
validateUpdate(valueUpdate);
externalUpdates.add(valueUpdate);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
@Override
public void close() {
closed = true;
}
private void assertOpen() {
if (closed) {
throw new IllegalStateException("Updater has been closed");
}
}
};
}
use of org.neo4j.storageengine.api.IndexEntryUpdate in project neo4j by neo4j.
the class NonUniqueDatabaseIndexPopulatorTest method addUpdates.
@Test
void addUpdates() throws Exception {
populator = newPopulator();
List<IndexEntryUpdate<?>> updates = Arrays.asList(add(1, labelSchemaDescriptor, "foo"), add(2, labelSchemaDescriptor, "bar"), add(42, labelSchemaDescriptor, "bar"));
populator.add(updates, NULL);
index.maybeRefreshBlocking();
try (ValueIndexReader reader = index.getIndexReader();
NodeValueIterator allEntities = new NodeValueIterator()) {
int propertyKeyId = labelSchemaDescriptor.getPropertyId();
reader.query(NULL_CONTEXT, allEntities, unconstrained(), PropertyIndexQuery.exists(propertyKeyId));
assertArrayEquals(new long[] { 1, 2, 42 }, PrimitiveLongCollections.asArray(allEntities));
}
}
use of org.neo4j.storageengine.api.IndexEntryUpdate in project neo4j by neo4j.
the class NonUniqueDatabaseIndexPopulatorTest method sampleIncludedUpdates.
@Test
void sampleIncludedUpdates() {
populator = newPopulator();
List<IndexEntryUpdate<?>> updates = Arrays.asList(add(1, labelSchemaDescriptor, "aaa"), add(2, labelSchemaDescriptor, "bbb"), add(3, labelSchemaDescriptor, "ccc"));
populator.add(updates, NULL);
IndexSample sample = populator.sample(NULL);
assertEquals(new IndexSample(3, 3, 3), sample);
}
Aggregations