Search in sources :

Example 21 with PropertyRecord

use of org.neo4j.kernel.impl.nioneo.store.PropertyRecord in project neo4j-mobile-android by neo4j-contrib.

the class ReadTransaction method getPropertyRecordChain.

static List<PropertyRecord> getPropertyRecordChain(PropertyStore propertyStore, long nextProp) {
    List<PropertyRecord> toReturn = new LinkedList<PropertyRecord>();
    if (nextProp == Record.NO_NEXT_PROPERTY.intValue()) {
        return null;
    }
    while (nextProp != Record.NO_NEXT_PROPERTY.intValue()) {
        PropertyRecord propRecord = propertyStore.getLightRecord(nextProp);
        toReturn.add(propRecord);
        nextProp = propRecord.getNextProp();
    }
    return toReturn;
}
Also used : PropertyRecord(org.neo4j.kernel.impl.nioneo.store.PropertyRecord) LinkedList(java.util.LinkedList)

Example 22 with PropertyRecord

use of org.neo4j.kernel.impl.nioneo.store.PropertyRecord in project neo4j-mobile-android by neo4j-contrib.

the class ReadTransaction method loadPropertyValue.

@Override
public Object loadPropertyValue(PropertyData property) {
    PropertyRecord propertyRecord = getPropertyStore().getRecord(property.getId());
    PropertyBlock propertyBlock = propertyRecord.getPropertyBlock(property.getIndex());
    if (propertyBlock.isLight()) {
        getPropertyStore().makeHeavy(propertyBlock);
    }
    return propertyBlock.getType().getValue(propertyBlock, getPropertyStore());
}
Also used : PropertyRecord(org.neo4j.kernel.impl.nioneo.store.PropertyRecord) PropertyBlock(org.neo4j.kernel.impl.nioneo.store.PropertyBlock)

Example 23 with PropertyRecord

use of org.neo4j.kernel.impl.nioneo.store.PropertyRecord in project neo4j-mobile-android by neo4j-contrib.

the class WriteTransaction method getAndDeletePropertyChain.

private ArrayMap<Integer, PropertyData> getAndDeletePropertyChain(long startingAt) {
    ArrayMap<Integer, PropertyData> result = new ArrayMap<Integer, PropertyData>(9, false, true);
    long nextProp = startingAt;
    while (nextProp != Record.NO_NEXT_PROPERTY.intValue()) {
        PropertyRecord propRecord = getPropertyRecord(nextProp, false, true);
        if (!propRecord.isCreated() && propRecord.isChanged()) {
            // Being here means a new value could be on disk. Re-read
            propRecord = getPropertyStore().getRecord(propRecord.getId());
        }
        for (PropertyBlock block : propRecord.getPropertyBlocks()) {
            if (block.isLight()) {
                getPropertyStore().makeHeavy(block);
            }
            if (!block.isCreated() && !propRecord.isChanged()) {
                result.put(block.getKeyIndexId(), block.newPropertyData(propRecord, propertyGetValueOrNull(block)));
            }
            // TODO: update count on property index record
            for (DynamicRecord valueRecord : block.getValueRecords()) {
                assert valueRecord.inUse();
                valueRecord.setInUse(false);
                propRecord.addDeletedRecord(valueRecord);
            }
        }
        nextProp = propRecord.getNextProp();
        propRecord.setInUse(false);
        propRecord.setChanged();
        // We do not remove them individually, but all together here
        propRecord.getPropertyBlocks().clear();
    }
    return result;
}
Also used : DynamicRecord(org.neo4j.kernel.impl.nioneo.store.DynamicRecord) PropertyData(org.neo4j.kernel.impl.nioneo.store.PropertyData) PropertyRecord(org.neo4j.kernel.impl.nioneo.store.PropertyRecord) PropertyBlock(org.neo4j.kernel.impl.nioneo.store.PropertyBlock) ArrayMap(org.neo4j.kernel.impl.util.ArrayMap)

Example 24 with PropertyRecord

use of org.neo4j.kernel.impl.nioneo.store.PropertyRecord in project neo4j-mobile-android by neo4j-contrib.

the class WriteTransaction method nodeRemoveProperty.

@Override
public void nodeRemoveProperty(long nodeId, PropertyData propertyData) {
    long propertyId = propertyData.getId();
    NodeRecord nodeRecord = getNodeRecord(nodeId);
    if (nodeRecord == null) {
        nodeRecord = getNodeStore().getRecord(nodeId);
        addNodeRecord(nodeRecord);
    }
    if (!nodeRecord.inUse()) {
        throw new IllegalStateException("Property remove on node[" + nodeId + "] illegal since it has been deleted.");
    }
    assert assertPropertyChain(nodeRecord);
    PropertyRecord propRecord = getPropertyRecord(propertyId, false, true);
    if (!propRecord.inUse()) {
        throw new IllegalStateException("Unable to delete property[" + propertyId + "] since it is already deleted.");
    }
    propRecord.setNodeId(nodeId);
    PropertyBlock block = propRecord.removePropertyBlock(propertyData.getIndex());
    if (block == null) {
        throw new IllegalStateException("Property with index[" + propertyData.getIndex() + "] is not present in property[" + propertyId + "]");
    }
    if (block.isLight()) {
        getPropertyStore().makeHeavy(block);
    }
    for (DynamicRecord valueRecord : block.getValueRecords()) {
        assert valueRecord.inUse();
        valueRecord.setInUse(false, block.getType().intValue());
        propRecord.addDeletedRecord(valueRecord);
    }
    // propRecord.removeBlock( propertyData.getIndex() );
    if (propRecord.size() > 0) {
        /*
             * There are remaining blocks in the record. We do not unlink yet.
             */
        propRecord.setChanged();
        assert assertPropertyChain(nodeRecord);
        return;
    } else {
        if (unlinkPropertyRecord(propRecord, nodeRecord)) {
            addNodeRecord(nodeRecord);
        }
    }
}
Also used : DynamicRecord(org.neo4j.kernel.impl.nioneo.store.DynamicRecord) NodeRecord(org.neo4j.kernel.impl.nioneo.store.NodeRecord) PropertyRecord(org.neo4j.kernel.impl.nioneo.store.PropertyRecord) PropertyBlock(org.neo4j.kernel.impl.nioneo.store.PropertyBlock)

Example 25 with PropertyRecord

use of org.neo4j.kernel.impl.nioneo.store.PropertyRecord in project graphdb by neo4j-attic.

the class BatchInserterImpl method deletePropertyChain.

private void deletePropertyChain(long propertyId) {
    PropertyStore propStore = getPropertyStore();
    PropertyRecord propertyRecord = propStore.getRecord(propertyId);
    propertyRecord.setInUse(false);
    for (DynamicRecord record : propertyRecord.getValueRecords()) {
        record.setInUse(false);
    }
    propStore.updateRecord(propertyRecord);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.nioneo.store.DynamicRecord) PropertyRecord(org.neo4j.kernel.impl.nioneo.store.PropertyRecord) PropertyStore(org.neo4j.kernel.impl.nioneo.store.PropertyStore)

Aggregations

PropertyRecord (org.neo4j.kernel.impl.nioneo.store.PropertyRecord)36 DynamicRecord (org.neo4j.kernel.impl.nioneo.store.DynamicRecord)15 PropertyBlock (org.neo4j.kernel.impl.nioneo.store.PropertyBlock)13 NodeRecord (org.neo4j.kernel.impl.nioneo.store.NodeRecord)12 RelationshipRecord (org.neo4j.kernel.impl.nioneo.store.RelationshipRecord)12 PropertyData (org.neo4j.kernel.impl.nioneo.store.PropertyData)8 InvalidRecordException (org.neo4j.kernel.impl.nioneo.store.InvalidRecordException)7 ArrayMap (org.neo4j.kernel.impl.util.ArrayMap)7 PropertyStore (org.neo4j.kernel.impl.nioneo.store.PropertyStore)6 XAException (javax.transaction.xa.XAException)4 PropertyIndexRecord (org.neo4j.kernel.impl.nioneo.store.PropertyIndexRecord)4 RelationshipTypeRecord (org.neo4j.kernel.impl.nioneo.store.RelationshipTypeRecord)4 ArrayList (java.util.ArrayList)3 XaCommand (org.neo4j.kernel.impl.transaction.xaframework.XaCommand)3 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 PropertyStore.encodeString (org.neo4j.kernel.impl.nioneo.store.PropertyStore.encodeString)2 PropertyCommand (org.neo4j.kernel.impl.nioneo.xa.Command.PropertyCommand)2 PropertyType (org.neo4j.kernel.impl.nioneo.store.PropertyType)1