Search in sources :

Example 6 with RelationshipData

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

the class NodeManager method getRelationshipById.

public Relationship getRelationshipById(long relId) throws NotFoundException {
    RelationshipImpl relationship = relCache.get(relId);
    if (relationship != null) {
        return new RelationshipProxy(relId, this);
    }
    ReentrantLock loadLock = lockId(relId);
    try {
        relationship = relCache.get(relId);
        if (relationship != null) {
            return new RelationshipProxy(relId, this);
        }
        RelationshipData data = persistenceManager.loadLightRelationship(relId);
        if (data == null) {
            throw new NotFoundException("Relationship[" + relId + "]");
        }
        int typeId = data.relationshipType();
        RelationshipType type = getRelationshipTypeById(typeId);
        if (type == null) {
            throw new NotFoundException("Relationship[" + data.getId() + "] exist but relationship type[" + typeId + "] not found.");
        }
        final long startNodeId = data.firstNode();
        final long endNodeId = data.secondNode();
        relationship = new RelationshipImpl(relId, startNodeId, endNodeId, type, false);
        relCache.put(relId, relationship);
        return new RelationshipProxy(relId, this);
    } finally {
        loadLock.unlock();
    }
}
Also used : ReentrantLock(java.util.concurrent.locks.ReentrantLock) RelationshipData(org.neo4j.kernel.impl.nioneo.store.RelationshipData) RelationshipType(org.neo4j.graphdb.RelationshipType) NotFoundException(org.neo4j.graphdb.NotFoundException)

Aggregations

RelationshipData (org.neo4j.kernel.impl.nioneo.store.RelationshipData)6 RelationshipType (org.neo4j.graphdb.RelationshipType)3 RelationshipRecord (org.neo4j.kernel.impl.nioneo.store.RelationshipRecord)3 ArrayList (java.util.ArrayList)2 ReentrantLock (java.util.concurrent.locks.ReentrantLock)2 NotFoundException (org.neo4j.graphdb.NotFoundException)2 InvalidRecordException (org.neo4j.kernel.impl.nioneo.store.InvalidRecordException)2 HashMap (java.util.HashMap)1 RelationshipChainPosition (org.neo4j.kernel.impl.nioneo.store.RelationshipChainPosition)1 ArrayMap (org.neo4j.kernel.impl.util.ArrayMap)1 RelIdArray (org.neo4j.kernel.impl.util.RelIdArray)1