use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.
the class NativeIndexPopulatorTests method updaterMustThrowIfProcessAfterClose.
@Test
void updaterMustThrowIfProcessAfterClose() throws Exception {
// given
populator.create();
IndexUpdater updater = populator.newPopulatingUpdater(null_property_accessor, NULL);
// when
updater.close();
assertThrows(IllegalStateException.class, () -> updater.process(valueCreatorUtil.add(1, Values.of(Long.MAX_VALUE))));
populator.close(true, NULL);
}
use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.
the class NativeIndexPopulatorTests method interleaveLargeAmountOfUpdates.
int interleaveLargeAmountOfUpdates(Random updaterRandom, Iterator<? extends IndexEntryUpdate<IndexDescriptor>> updates) throws IndexEntryConflictException {
int count = 0;
for (int i = 0; i < LARGE_AMOUNT_OF_UPDATES; i++) {
if (updaterRandom.nextFloat() < 0.1) {
try (IndexUpdater indexUpdater = populator.newPopulatingUpdater(null_property_accessor, NULL)) {
int numberOfUpdaterUpdates = updaterRandom.nextInt(100);
for (int j = 0; j < numberOfUpdaterUpdates; j++) {
indexUpdater.process(updates.next());
count++;
}
}
}
populator.add(Collections.singletonList(updates.next()), NULL);
count++;
}
return count;
}
use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.
the class NativeIndexPopulatorTests method applyInterleaved.
void applyInterleaved(IndexEntryUpdate<IndexDescriptor>[] updates, IndexPopulator populator) throws IndexEntryConflictException {
boolean useUpdater = true;
Collection<IndexEntryUpdate<IndexDescriptor>> populatorBatch = new ArrayList<>();
IndexUpdater updater = populator.newPopulatingUpdater(null_property_accessor, NULL);
for (IndexEntryUpdate<IndexDescriptor> update : updates) {
if (random.nextInt(100) < 20) {
if (useUpdater) {
updater.close();
populatorBatch = new ArrayList<>();
} else {
populator.add(populatorBatch, NULL);
updater = populator.newPopulatingUpdater(null_property_accessor, NULL);
}
useUpdater = !useUpdater;
}
if (useUpdater) {
updater.process(update);
} else {
populatorBatch.add(update);
}
}
if (useUpdater) {
updater.close();
} else {
populator.add(populatorBatch, NULL);
}
}
use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.
the class NativeNonUniqueIndexPopulatorTest method shouldSampleUpdatesIfConfiguredForOnlineSampling.
@Test
void shouldSampleUpdatesIfConfiguredForOnlineSampling() throws Exception {
// GIVEN
try {
populator.create();
ValueIndexEntryUpdate<IndexDescriptor>[] scanUpdates = valueCreatorUtil.someUpdates(random);
populator.add(asList(scanUpdates), NULL);
Iterator<ValueIndexEntryUpdate<IndexDescriptor>> generator = valueCreatorUtil.randomUpdateGenerator(random);
Value[] updates = new Value[5];
updates[0] = generator.next().values()[0];
updates[1] = generator.next().values()[0];
updates[2] = updates[1];
updates[3] = generator.next().values()[0];
updates[4] = updates[3];
try (IndexUpdater updater = populator.newPopulatingUpdater(null_property_accessor, NULL)) {
long nodeId = 1000;
for (Value value : updates) {
ValueIndexEntryUpdate<IndexDescriptor> update = valueCreatorUtil.add(nodeId++, value);
updater.process(update);
}
}
// WHEN
populator.scanCompleted(nullInstance, populationWorkScheduler, NULL);
IndexSample sample = populator.sample(NULL);
// THEN
assertEquals(scanUpdates.length, sample.sampleSize());
assertEquals(countUniqueValues(scanUpdates), sample.uniqueValues());
assertEquals(scanUpdates.length, sample.indexSize());
assertEquals(updates.length, sample.updates());
} finally {
populator.close(true, NULL);
}
}
use of org.neo4j.kernel.api.index.IndexUpdater in project neo4j by neo4j.
the class NativeNonUniqueIndexPopulatorTest method updaterShouldApplyDuplicateValues.
@Test
void updaterShouldApplyDuplicateValues() throws Exception {
// given
populator.create();
ValueIndexEntryUpdate<IndexDescriptor>[] updates = valueCreatorUtil.someUpdatesWithDuplicateValues(random);
try (IndexUpdater updater = populator.newPopulatingUpdater(null_property_accessor, NULL)) {
// when
for (ValueIndexEntryUpdate<IndexDescriptor> update : updates) {
updater.process(update);
}
}
// then
populator.scanCompleted(nullInstance, populationWorkScheduler, NULL);
populator.close(true, NULL);
valueUtil.verifyUpdates(updates, this::getTree);
}
Aggregations