Search in sources :

Example 1 with PropertyKeyValue

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

the class NeoStoresTest method nodeAddProperty.

private StorageProperty nodeAddProperty(long nodeId, int key, Object value) {
    StorageProperty property = new PropertyKeyValue(key, Values.of(value));
    StorageProperty oldProperty = null;
    try (StorageNodeCursor nodeCursor = storageReader.allocateNodeCursor(NULL)) {
        nodeCursor.single(nodeId);
        if (nodeCursor.next()) {
            StorageProperty fetched = getProperty(key, nodeCursor.propertiesReference());
            if (fetched != null) {
                oldProperty = fetched;
            }
        }
    }
    if (oldProperty == null) {
        transactionState.nodeDoAddProperty(nodeId, key, property.value());
    } else {
        transactionState.nodeDoChangeProperty(nodeId, key, property.value());
    }
    return property;
}
Also used : PropertyKeyValue(org.neo4j.storageengine.api.PropertyKeyValue) StorageProperty(org.neo4j.storageengine.api.StorageProperty) StorageNodeCursor(org.neo4j.storageengine.api.StorageNodeCursor)

Example 2 with PropertyKeyValue

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

the class SchemaStore method schemaRecordToMap.

private static Map<String, Value> schemaRecordToMap(SchemaRecord record, PropertyStore propertyStore, TokenHolders tokenHolders, CursorContext cursorContext) throws MalformedSchemaRuleException {
    Map<String, Value> props = new HashMap<>();
    PropertyRecord propRecord = propertyStore.newRecord();
    long nextProp = record.getNextProp();
    while (nextProp != NO_NEXT_PROPERTY.longValue()) {
        try {
            propertyStore.getRecord(nextProp, propRecord, RecordLoad.NORMAL, cursorContext);
        } catch (InvalidRecordException e) {
            throw new MalformedSchemaRuleException("Cannot read schema rule because it is referencing a property record (id " + nextProp + ") that is invalid: " + propRecord, e);
        }
        for (PropertyBlock propertyBlock : propRecord) {
            PropertyKeyValue propertyKeyValue = propertyBlock.newPropertyKeyValue(propertyStore, cursorContext);
            insertPropertyIntoMap(propertyKeyValue, props, tokenHolders);
        }
        nextProp = propRecord.getNextProp();
    }
    if (props.isEmpty()) {
        IndexDescriptor descriptor = IndexDescriptor.NLI_PROTOTYPE.materialise(record.getId());
        props.putAll(mapifySchemaRule(descriptor));
    }
    return props;
}
Also used : PropertyKeyValue(org.neo4j.storageengine.api.PropertyKeyValue) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) MalformedSchemaRuleException(org.neo4j.internal.kernel.api.exceptions.schema.MalformedSchemaRuleException) IntObjectHashMap(org.eclipse.collections.impl.map.mutable.primitive.IntObjectHashMap) HashMap(java.util.HashMap) Value(org.neo4j.values.storable.Value) PropertyKeyValue(org.neo4j.storageengine.api.PropertyKeyValue) TextValue(org.neo4j.values.storable.TextValue) LongValue(org.neo4j.values.storable.LongValue) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor)

Example 3 with PropertyKeyValue

use of org.neo4j.storageengine.api.PropertyKeyValue 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)

Aggregations

PropertyKeyValue (org.neo4j.storageengine.api.PropertyKeyValue)3 StorageProperty (org.neo4j.storageengine.api.StorageProperty)2 Value (org.neo4j.values.storable.Value)2 HashMap (java.util.HashMap)1 IntObjectHashMap (org.eclipse.collections.impl.map.mutable.primitive.IntObjectHashMap)1 Test (org.junit.jupiter.api.Test)1 MalformedSchemaRuleException (org.neo4j.internal.kernel.api.exceptions.schema.MalformedSchemaRuleException)1 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)1 PropertyBlock (org.neo4j.kernel.impl.store.record.PropertyBlock)1 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)1 StorageNodeCursor (org.neo4j.storageengine.api.StorageNodeCursor)1 LongValue (org.neo4j.values.storable.LongValue)1 TextValue (org.neo4j.values.storable.TextValue)1