Search in sources :

Example 46 with EntityUpdates

use of org.neo4j.storageengine.api.EntityUpdates in project neo4j by neo4j.

the class EntityValueUpdatesTest method shouldGenerateUpdateWhenRemovingLastTokenForNonSchemaIndex.

@Test
void shouldGenerateUpdateWhenRemovingLastTokenForNonSchemaIndex() {
    // When
    EntityUpdates updates = EntityUpdates.forEntity(ENTITY_ID, false).withTokens(TOKEN).withTokensAfter(EMPTY).build();
    // Then
    assertThat(updates.valueUpdatesForIndexKeys(singleton(NON_SCHEMA_NODE_INDEX), propertyLoader(PROPERTY_1, PROPERTY_2, PROPERTY_3), EntityType.NODE, NULL, INSTANCE)).contains(IndexEntryUpdate.remove(ENTITY_ID, NON_SCHEMA_NODE_INDEX, VALUES_123));
}
Also used : EntityUpdates(org.neo4j.storageengine.api.EntityUpdates) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 47 with EntityUpdates

use of org.neo4j.storageengine.api.EntityUpdates in project neo4j by neo4j.

the class FullCheckIntegrationTest method shouldReportNodesThatAreNotIndexed.

@ParameterizedTest
@EnumSource(IndexSize.class)
void shouldReportNodesThatAreNotIndexed(IndexSize indexSize) throws Exception {
    indexSize.createAdditionalData(fixture);
    // given
    Iterator<IndexDescriptor> indexDescriptorIterator = getValueIndexDescriptors();
    while (indexDescriptorIterator.hasNext()) {
        IndexDescriptor indexDescriptor = indexDescriptorIterator.next();
        IndexAccessor accessor = fixture.indexAccessorLookup().apply(indexDescriptor);
        try (IndexUpdater updater = accessor.newUpdater(IndexUpdateMode.ONLINE, NULL)) {
            for (long nodeId : indexedNodes) {
                EntityUpdates updates = fixture.nodeAsUpdates(nodeId);
                for (IndexEntryUpdate<?> update : updates.valueUpdatesForIndexKeys(singletonList(indexDescriptor))) {
                    updater.process(IndexEntryUpdate.remove(nodeId, indexDescriptor, ((ValueIndexEntryUpdate<?>) update).values()));
                }
            }
        }
    }
    // when
    ConsistencySummaryStatistics stats = check();
    // then
    // 1 node missing from 1 index + 1 node missing from 2 indexes
    on(stats).verify(RecordType.NODE, 3).andThatsAllFolks();
}
Also used : EntityUpdates(org.neo4j.storageengine.api.EntityUpdates) IndexAccessor(org.neo4j.kernel.api.index.IndexAccessor) ValueIndexEntryUpdate(org.neo4j.storageengine.api.ValueIndexEntryUpdate) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) IndexUpdater(org.neo4j.kernel.api.index.IndexUpdater) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 48 with EntityUpdates

use of org.neo4j.storageengine.api.EntityUpdates in project neo4j by neo4j.

the class PropertyPhysicalToLogicalConverterTest method shouldConvertDynamicChangedProperty.

@Test
void shouldConvertDynamicChangedProperty() {
    // GIVEN
    int key = 10;
    PropertyRecord before = propertyRecord(property(key, longString));
    PropertyRecord after = propertyRecord(property(key, longerString));
    // WHEN
    EntityUpdates update = convert(none, none, change(before, after));
    // THEN
    EntityUpdates expected = EntityUpdates.forEntity(0, false).changed(key, longString, longerString).build();
    assertEquals(expected, update);
}
Also used : EntityUpdates(org.neo4j.storageengine.api.EntityUpdates) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) Test(org.junit.jupiter.api.Test)

Example 49 with EntityUpdates

use of org.neo4j.storageengine.api.EntityUpdates in project neo4j by neo4j.

the class PropertyPhysicalToLogicalConverterTest method shouldTreatPropertyThatMovedToAnotherRecordAsChange.

@Test
void shouldTreatPropertyThatMovedToAnotherRecordAsChange() {
    // GIVEN
    int key = 12;
    Value oldValue = Values.of("value1");
    Value newValue = Values.of("value two");
    Command.PropertyCommand movedFrom = change(propertyRecord(property(key, oldValue)), propertyRecord());
    Command.PropertyCommand movedTo = change(propertyRecord(), propertyRecord(property(key, newValue)));
    // WHEN
    EntityUpdates update = convert(none, none, movedFrom, movedTo);
    // THEN
    EntityUpdates expected = EntityUpdates.forEntity(0, false).changed(key, oldValue, newValue).build();
    assertEquals(expected, update);
}
Also used : EntityUpdates(org.neo4j.storageengine.api.EntityUpdates) Value(org.neo4j.values.storable.Value) Test(org.junit.jupiter.api.Test)

Example 50 with EntityUpdates

use of org.neo4j.storageengine.api.EntityUpdates in project neo4j by neo4j.

the class PropertyPhysicalToLogicalConverterTest method shouldConvertInlinedRemovedProperty.

@Test
void shouldConvertInlinedRemovedProperty() {
    // GIVEN
    int key = 10;
    Value value = Values.of(12341);
    PropertyRecord before = propertyRecord(property(key, value));
    PropertyRecord after = propertyRecord();
    // WHEN
    EntityUpdates update = convert(none, none, change(before, after));
    // THEN
    EntityUpdates expected = EntityUpdates.forEntity(0, false).removed(key, value).build();
    assertEquals(expected, update);
}
Also used : EntityUpdates(org.neo4j.storageengine.api.EntityUpdates) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) Value(org.neo4j.values.storable.Value) Test(org.junit.jupiter.api.Test)

Aggregations

EntityUpdates (org.neo4j.storageengine.api.EntityUpdates)50 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)41 Test (org.junit.jupiter.api.Test)22 EnumSource (org.junit.jupiter.params.provider.EnumSource)21 Value (org.neo4j.values.storable.Value)6 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)4 ArrayList (java.util.ArrayList)3 MethodSource (org.junit.jupiter.params.provider.MethodSource)3 Transaction (org.neo4j.graphdb.Transaction)3 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)3 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)3 PropertyKeyValue (org.neo4j.storageengine.api.PropertyKeyValue)3 StorageNodeCursor (org.neo4j.storageengine.api.StorageNodeCursor)2 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)1 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)1 IndexAccessor (org.neo4j.kernel.api.index.IndexAccessor)1 IndexUpdater (org.neo4j.kernel.api.index.IndexUpdater)1 StoragePropertyCursor (org.neo4j.storageengine.api.StoragePropertyCursor)1 StorageReader (org.neo4j.storageengine.api.StorageReader)1 ValueIndexEntryUpdate (org.neo4j.storageengine.api.ValueIndexEntryUpdate)1