use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.
the class NativeIndexAccessorTests method shouldIndexChange.
@Test
void shouldIndexChange() throws Exception {
// given
ValueIndexEntryUpdate<IndexDescriptor>[] updates = someUpdatesSingleType();
processAll(updates);
Iterator<ValueIndexEntryUpdate<IndexDescriptor>> generator = filter(skipExisting(updates), valueCreatorUtil.randomUpdateGenerator(random));
for (int i = 0; i < updates.length; i++) {
ValueIndexEntryUpdate<IndexDescriptor> update = updates[i];
Value newValue = generator.next().values()[0];
updates[i] = change(update.getEntityId(), indexDescriptor, update.values()[0], newValue);
}
// when
processAll(updates);
// then
forceAndCloseAccessor();
valueUtil.verifyUpdates(updates, this::getTree);
}
use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.
the class NativeIndexAccessorTests method shouldReturnMatchingEntriesForExactPredicate.
@Test
void shouldReturnMatchingEntriesForExactPredicate() throws Exception {
// given
ValueIndexEntryUpdate<IndexDescriptor>[] updates = someUpdatesSingleType();
processAll(updates);
// when
var reader = accessor.newValueReader();
for (ValueIndexEntryUpdate<IndexDescriptor> update : updates) {
Value value = update.values()[0];
try (NodeValueIterator result = query(reader, PropertyIndexQuery.exact(0, value))) {
assertEntityIdHits(extractEntityIds(updates, in(value)), result);
}
}
}
use of org.neo4j.internal.schema.IndexDescriptor in project neo4j by neo4j.
the class NativeIndexPopulatorTests method updaterShouldApplyUpdates.
@Test
void updaterShouldApplyUpdates() throws Exception {
// given
populator.create();
ValueIndexEntryUpdate<IndexDescriptor>[] updates = valueCreatorUtil.someUpdates(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);
}
use of org.neo4j.internal.schema.IndexDescriptor 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.internal.schema.IndexDescriptor 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);
}
}
Aggregations