use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.
the class NativeIndexAccessorTests method shouldHandleMultipleConsecutiveUpdaters.
@Test
void shouldHandleMultipleConsecutiveUpdaters() throws Exception {
// given
ValueIndexEntryUpdate<IndexDescriptor>[] updates = someUpdatesSingleType();
// when
for (ValueIndexEntryUpdate<IndexDescriptor> update : updates) {
try (IndexUpdater updater = accessor.newUpdater(ONLINE, NULL)) {
updater.process(update);
}
}
// then
forceAndCloseAccessor();
valueUtil.verifyUpdates(updates, this::getTree);
}
use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.
the class IndexUpdaterMap method getUpdater.
IndexUpdater getUpdater(IndexDescriptor descriptor, CursorContext cursorContext) {
IndexUpdater updater = updaterMap.get(descriptor);
if (null == updater) {
IndexProxy indexProxy = indexMap.getIndexProxy(descriptor);
if (null != indexProxy) {
updater = indexProxy.newUpdater(indexUpdateMode, cursorContext);
updaterMap.put(descriptor, updater);
}
}
return updater;
}
use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.
the class TokenIndexAccessorTest method shouldAddWithUpdater.
@Test
void shouldAddWithUpdater() throws IndexEntryConflictException, IOException {
// Give
MutableLongObjectMap<long[]> entityTokens = LongObjectMaps.mutable.empty();
List<TokenIndexEntryUpdate<?>> updates = generateSomeRandomUpdates(entityTokens, random);
// When
try (IndexUpdater updater = accessor.newUpdater(ONLINE, NULL)) {
for (TokenIndexEntryUpdate<?> update : updates) {
updater.process(update);
}
}
// Then
forceAndCloseAccessor();
verifyUpdates(entityTokens, layout, this::getTree);
}
use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.
the class TokenIndexAccessorTest method doRandomizedUpdatesWithAdditionalOperation.
private void doRandomizedUpdatesWithAdditionalOperation(Executable additionalOperation, MutableLongObjectMap<long[]> trackingStructure) throws Throwable {
int numberOfEntities = 1_000;
long currentMaxEntityId = 0;
while (currentMaxEntityId < numberOfEntities) {
try (IndexUpdater updater = accessor.newUpdater(ONLINE, NULL)) {
// Simply add random token ids to a new batch of 100 entities
for (int i = 0; i < 100; i++) {
long[] afterTokens = generateRandomTokens(random);
if (afterTokens.length != 0) {
trackingStructure.put(currentMaxEntityId, Arrays.copyOf(afterTokens, afterTokens.length));
updater.process(IndexEntryUpdate.change(currentMaxEntityId, null, EMPTY_LONG_ARRAY, afterTokens));
}
currentMaxEntityId++;
}
}
additionalOperation.execute();
// Interleave updates in id range lower than currentMaxEntityId
try (IndexUpdater updater = accessor.newUpdater(ONLINE, NULL)) {
for (int i = 0; i < 100; i++) {
long entityId = random.nextLong(currentMaxEntityId);
// Current tokens for the entity in the tree
long[] beforeTokens = trackingStructure.get(entityId);
if (beforeTokens == null) {
beforeTokens = EMPTY_LONG_ARRAY;
}
long[] afterTokens = generateRandomTokens(random);
trackingStructure.put(entityId, Arrays.copyOf(afterTokens, afterTokens.length));
updater.process(IndexEntryUpdate.change(entityId, null, beforeTokens, afterTokens));
}
}
additionalOperation.execute();
}
}
use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.
the class NativeUniqueIndexPopulatorTest method updaterShouldThrowOnDuplicateValues.
@Test
void updaterShouldThrowOnDuplicateValues() throws Exception {
// given
populator.create();
IndexEntryUpdate<IndexDescriptor>[] updates = valueCreatorUtil.someUpdatesWithDuplicateValues(random);
IndexUpdater updater = populator.newPopulatingUpdater(null_property_accessor, NULL);
// when
for (IndexEntryUpdate<IndexDescriptor> update : updates) {
updater.process(update);
}
var e = assertThrows(Exception.class, () -> {
updater.close();
populator.scanCompleted(nullInstance, populationWorkScheduler, NULL);
});
assertTrue(hasCause(e, IndexEntryConflictException.class), e.getMessage());
populator.close(true, NULL);
}
Aggregations