Search in sources :

Example 6 with ValueIndexEntryUpdate

use of org.neo4j.storageengine.api.ValueIndexEntryUpdate 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);
}
Also used : ValueIndexEntryUpdate(org.neo4j.storageengine.api.ValueIndexEntryUpdate) Value(org.neo4j.values.storable.Value) PointValue(org.neo4j.values.storable.PointValue) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Test(org.junit.jupiter.api.Test)

Example 7 with ValueIndexEntryUpdate

use of org.neo4j.storageengine.api.ValueIndexEntryUpdate 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);
        }
    }
}
Also used : ValueIndexEntryUpdate(org.neo4j.storageengine.api.ValueIndexEntryUpdate) Value(org.neo4j.values.storable.Value) PointValue(org.neo4j.values.storable.PointValue) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Test(org.junit.jupiter.api.Test)

Example 8 with ValueIndexEntryUpdate

use of org.neo4j.storageengine.api.ValueIndexEntryUpdate 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);
}
Also used : ValueIndexEntryUpdate(org.neo4j.storageengine.api.ValueIndexEntryUpdate) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) IndexUpdater(org.neo4j.kernel.api.index.IndexUpdater) Test(org.junit.jupiter.api.Test)

Example 9 with ValueIndexEntryUpdate

use of org.neo4j.storageengine.api.ValueIndexEntryUpdate 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);
    }
}
Also used : IndexSample(org.neo4j.kernel.api.index.IndexSample) ValueIndexEntryUpdate(org.neo4j.storageengine.api.ValueIndexEntryUpdate) Value(org.neo4j.values.storable.Value) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) IndexUpdater(org.neo4j.kernel.api.index.IndexUpdater) Test(org.junit.jupiter.api.Test)

Example 10 with ValueIndexEntryUpdate

use of org.neo4j.storageengine.api.ValueIndexEntryUpdate 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);
}
Also used : ValueIndexEntryUpdate(org.neo4j.storageengine.api.ValueIndexEntryUpdate) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) IndexUpdater(org.neo4j.kernel.api.index.IndexUpdater) Test(org.junit.jupiter.api.Test)

Aggregations

ValueIndexEntryUpdate (org.neo4j.storageengine.api.ValueIndexEntryUpdate)26 Test (org.junit.jupiter.api.Test)15 IndexUpdater (org.neo4j.kernel.api.index.IndexUpdater)11 Value (org.neo4j.values.storable.Value)11 ArrayList (java.util.ArrayList)9 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)9 PointValue (org.neo4j.values.storable.PointValue)6 HashSet (java.util.HashSet)5 Test (org.junit.Test)5 PropertyIndexQuery (org.neo4j.internal.kernel.api.PropertyIndexQuery)5 ValueType (org.neo4j.values.storable.ValueType)5 List (java.util.List)3 Arrays (java.util.Arrays)2 Collections (java.util.Collections)2 Random (java.util.Random)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 MutableLong (org.apache.commons.lang3.mutable.MutableLong)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 IndexOrderCapability (org.neo4j.internal.schema.IndexOrderCapability)2