Search in sources :

Example 16 with DefinedProperty

use of org.neo4j.kernel.api.properties.DefinedProperty in project neo4j by neo4j.

the class IndexTxStateUpdater method getOrderedPropertyValues.

private OrderedPropertyValues getOrderedPropertyValues(KernelStatement state, NodeItem node, DefinedProperty changedProperty, int[] indexPropertyIds) {
    DefinedProperty[] values = new DefinedProperty[indexPropertyIds.length];
    Cursor<PropertyItem> propertyCursor = readOps.nodeGetProperties(state, node);
    while (propertyCursor.next()) {
        PropertyItem property = propertyCursor.get();
        int k = ArrayUtils.indexOf(indexPropertyIds, property.propertyKeyId());
        if (k >= 0) {
            values[k] = indexPropertyIds[k] == changedProperty.propertyKeyId() ? changedProperty : Property.property(indexPropertyIds[k], property.value());
        }
    }
    if (changedProperty != NO_SUCH_PROPERTY) {
        int k = ArrayUtils.indexOf(indexPropertyIds, changedProperty.propertyKeyId());
        if (k >= 0) {
            values[k] = changedProperty;
        }
    }
    return OrderedPropertyValues.of(values);
}
Also used : DefinedProperty(org.neo4j.kernel.api.properties.DefinedProperty) PropertyItem(org.neo4j.storageengine.api.PropertyItem)

Example 17 with DefinedProperty

use of org.neo4j.kernel.api.properties.DefinedProperty in project neo4j by neo4j.

the class LockingStatementOperationsTest method shouldNotAcquireEntityWriteLockBeforeSettingPropertyOnJustCreatedNode.

@Test
public void shouldNotAcquireEntityWriteLockBeforeSettingPropertyOnJustCreatedNode() throws Exception {
    // given
    txState.nodeDoCreate(123);
    DefinedProperty property = Property.property(8, 9);
    // when
    lockingOps.nodeSetProperty(state, 123, property);
    // then
    order.verify(locks, never()).acquireExclusive(LockTracer.NONE, ResourceTypes.NODE, 123);
    order.verify(entityWriteOps).nodeSetProperty(state, 123, property);
}
Also used : DefinedProperty(org.neo4j.kernel.api.properties.DefinedProperty) Test(org.junit.Test)

Example 18 with DefinedProperty

use of org.neo4j.kernel.api.properties.DefinedProperty in project neo4j by neo4j.

the class LockingStatementOperationsTest method shouldAcquireSchemaReadLockBeforeSettingPropertyOnNode.

@Test
public void shouldAcquireSchemaReadLockBeforeSettingPropertyOnNode() throws Exception {
    // given
    DefinedProperty property = Property.property(8, 9);
    // when
    lockingOps.nodeSetProperty(state, 123, property);
    // then
    order.verify(locks).acquireShared(LockTracer.NONE, ResourceTypes.SCHEMA, schemaResource());
    order.verify(entityWriteOps).nodeSetProperty(state, 123, property);
}
Also used : DefinedProperty(org.neo4j.kernel.api.properties.DefinedProperty) Test(org.junit.Test)

Example 19 with DefinedProperty

use of org.neo4j.kernel.api.properties.DefinedProperty in project neo4j by neo4j.

the class LockingStatementOperationsTest method shouldAcquireEntityWriteLockBeforeSettingPropertyOnRelationship.

@Test
public void shouldAcquireEntityWriteLockBeforeSettingPropertyOnRelationship() throws Exception {
    // given
    DefinedProperty property = Property.property(8, 9);
    // when
    lockingOps.relationshipSetProperty(state, 123, property);
    // then
    order.verify(locks).acquireExclusive(LockTracer.NONE, ResourceTypes.RELATIONSHIP, 123);
    order.verify(entityWriteOps).relationshipSetProperty(state, 123, property);
}
Also used : DefinedProperty(org.neo4j.kernel.api.properties.DefinedProperty) Test(org.junit.Test)

Example 20 with DefinedProperty

use of org.neo4j.kernel.api.properties.DefinedProperty in project neo4j by neo4j.

the class LockingStatementOperationsTest method shouldNotAcquireEntityWriteLockBeforeSettingPropertyOnJustCreatedRelationship.

@Test
public void shouldNotAcquireEntityWriteLockBeforeSettingPropertyOnJustCreatedRelationship() throws Exception {
    // given
    txState.relationshipDoCreate(123, 1, 2, 3);
    DefinedProperty property = Property.property(8, 9);
    // when
    lockingOps.relationshipSetProperty(state, 123, property);
    // then
    order.verify(locks, never()).acquireExclusive(LockTracer.NONE, ResourceTypes.RELATIONSHIP, 123);
    order.verify(entityWriteOps).relationshipSetProperty(state, 123, property);
}
Also used : DefinedProperty(org.neo4j.kernel.api.properties.DefinedProperty) Test(org.junit.Test)

Aggregations

DefinedProperty (org.neo4j.kernel.api.properties.DefinedProperty)47 Test (org.junit.Test)23 Pair (org.neo4j.helpers.collection.Pair)9 IOException (java.io.IOException)8 InterruptedIOException (java.io.InterruptedIOException)8 PropertyBlock (org.neo4j.kernel.impl.store.record.PropertyBlock)8 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)8 ArrayMap (org.neo4j.kernel.impl.util.ArrayMap)8 PropertyItem (org.neo4j.storageengine.api.PropertyItem)8 NodeItem (org.neo4j.storageengine.api.NodeItem)7 RelationshipItem (org.neo4j.storageengine.api.RelationshipItem)7 Property (org.neo4j.kernel.api.properties.Property)6 PropertyEntry (org.neo4j.graphdb.event.PropertyEntry)4 DataWriteOperations (org.neo4j.kernel.api.DataWriteOperations)4 NodeUpdates (org.neo4j.kernel.api.index.NodeUpdates)4 NeoStores (org.neo4j.kernel.impl.store.NeoStores)4 StorageProperty (org.neo4j.storageengine.api.StorageProperty)4 Node (org.neo4j.graphdb.Node)3 Relationship (org.neo4j.graphdb.Relationship)3 Statement (org.neo4j.kernel.api.Statement)3