Search in sources :

Example 11 with StorageProperty

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

the class TransactionToRecordStateVisitor method visitRelPropertyChanges.

@Override
public void visitRelPropertyChanges(long id, Iterator<StorageProperty> added, Iterator<StorageProperty> changed, IntIterable removed) {
    removed.each(relId -> recordState.relRemoveProperty(id, relId));
    while (changed.hasNext()) {
        StorageProperty prop = changed.next();
        recordState.relChangeProperty(id, prop.propertyKeyId(), prop.value());
    }
    while (added.hasNext()) {
        StorageProperty prop = added.next();
        recordState.relAddProperty(id, prop.propertyKeyId(), prop.value());
    }
}
Also used : StorageProperty(org.neo4j.storageengine.api.StorageProperty)

Example 12 with StorageProperty

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

the class TxStateVisitorTest method shouldSeeAddedRelationshipProperties.

@Test
void shouldSeeAddedRelationshipProperties() throws Exception {
    // Given
    long relId = 1L;
    int propKey = 2;
    GatheringVisitor visitor = new GatheringVisitor();
    Value value = Values.of("hello");
    state.relationshipDoReplaceProperty(relId, propKey, Values.of(""), value);
    // When
    state.accept(visitor);
    // Then
    StorageProperty prop = new PropertyKeyValue(propKey, Values.of("hello"));
    assertThat(visitor.relPropertyChanges).containsExactly(propChange(relId, noProperty, singletonList(prop), IntSets.immutable.empty()));
}
Also used : PropertyKeyValue(org.neo4j.storageengine.api.PropertyKeyValue) PropertyKeyValue(org.neo4j.storageengine.api.PropertyKeyValue) Value(org.neo4j.values.storable.Value) StorageProperty(org.neo4j.storageengine.api.StorageProperty) Test(org.junit.jupiter.api.Test)

Example 13 with StorageProperty

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

the class TxStateTest method doNotVisitNotModifiedPropertiesOnModifiedNodes.

@Test
void doNotVisitNotModifiedPropertiesOnModifiedNodes() throws KernelException {
    state.nodeDoAddLabel(5, 1);
    MutableBoolean labelsChecked = new MutableBoolean();
    state.accept(new TxStateVisitor.Adapter() {

        @Override
        public void visitNodeLabelChanges(long id, LongSet added, LongSet removed) {
            labelsChecked.setTrue();
            assertEquals(1, id);
            assertEquals(1, added.size());
            assertTrue(added.contains(5));
            assertTrue(removed.isEmpty());
        }

        @Override
        public void visitNodePropertyChanges(long id, Iterator<StorageProperty> added, Iterator<StorageProperty> changed, IntIterable removed) {
            fail("Properties were not changed.");
        }
    });
    assertTrue(labelsChecked.booleanValue());
}
Also used : TxStateVisitor(org.neo4j.storageengine.api.txstate.TxStateVisitor) MutableBoolean(org.apache.commons.lang3.mutable.MutableBoolean) LongSet(org.eclipse.collections.api.set.primitive.LongSet) StorageProperty(org.neo4j.storageengine.api.StorageProperty) IntIterable(org.eclipse.collections.api.IntIterable) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test)

Aggregations

StorageProperty (org.neo4j.storageengine.api.StorageProperty)13 Test (org.junit.jupiter.api.Test)3 PropertyKeyValue (org.neo4j.storageengine.api.PropertyKeyValue)3 MutableBoolean (org.apache.commons.lang3.mutable.MutableBoolean)2 IntIterable (org.eclipse.collections.api.IntIterable)2 LongSet (org.eclipse.collections.api.set.primitive.LongSet)2 RepeatedTest (org.junit.jupiter.api.RepeatedTest)2 Relationship (org.neo4j.graphdb.Relationship)2 PropertyKeyIdNotFoundKernelException (org.neo4j.internal.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)2 NodeState (org.neo4j.storageengine.api.txstate.NodeState)2 RelationshipState (org.neo4j.storageengine.api.txstate.RelationshipState)2 TxStateVisitor (org.neo4j.storageengine.api.txstate.TxStateVisitor)2 Value (org.neo4j.values.storable.Value)2 HashMap (java.util.HashMap)1 Test (org.junit.Test)1 LabelNotFoundKernelException (org.neo4j.kernel.api.exceptions.LabelNotFoundKernelException)1 PropertyKeyIdNotFoundKernelException (org.neo4j.kernel.api.exceptions.PropertyKeyIdNotFoundKernelException)1 DefinedProperty (org.neo4j.kernel.api.properties.DefinedProperty)1 Lock (org.neo4j.kernel.impl.locking.Lock)1 NodeItem (org.neo4j.storageengine.api.NodeItem)1