Search in sources :

Example 1 with RelIdArrayWithLoops

use of org.neo4j.kernel.impl.util.RelIdArrayWithLoops in project neo4j-mobile-android by neo4j-contrib.

the class NodeManager method receiveRelationships.

private void receiveRelationships(Iterable<RelationshipRecord> rels, ArrayMap<String, RelIdArray> newRelationshipMap, Map<Long, RelationshipImpl> relsMap, DirectionWrapper dir, boolean hasLoops) {
    for (RelationshipRecord rel : rels) {
        long relId = rel.getId();
        RelationshipImpl relImpl = relCache.get(relId);
        RelationshipType type = null;
        if (relImpl == null) {
            type = getRelationshipTypeById(rel.getType());
            assert type != null;
            relImpl = newRelationshipImpl(relId, rel.getFirstNode(), rel.getSecondNode(), type, rel.getType(), false);
            relsMap.put(relId, relImpl);
        // relCache.put( relId, relImpl );
        } else {
            type = relImpl.getType(this);
        }
        RelIdArray relationshipSet = newRelationshipMap.get(type.name());
        if (relationshipSet == null) {
            relationshipSet = hasLoops ? new RelIdArrayWithLoops(type.name()) : new RelIdArray(type.name());
            newRelationshipMap.put(type.name(), relationshipSet);
        }
        relationshipSet.add(relId, dir);
    }
}
Also used : RelIdArrayWithLoops(org.neo4j.kernel.impl.util.RelIdArrayWithLoops) RelationshipType(org.neo4j.graphdb.RelationshipType) RelationshipRecord(org.neo4j.kernel.impl.nioneo.store.RelationshipRecord) RelIdArray(org.neo4j.kernel.impl.util.RelIdArray)

Example 2 with RelIdArrayWithLoops

use of org.neo4j.kernel.impl.util.RelIdArrayWithLoops in project neo4j-mobile-android by neo4j-contrib.

the class LockReleaser method getCowRelationshipAddMap.

public RelIdArray getCowRelationshipAddMap(NodeImpl node, String type, boolean create) {
    PrimitiveElement primitiveElement = getAndSetupPrimitiveElement();
    ArrayMap<Long, CowNodeElement> cowElements = primitiveElement.nodes;
    CowNodeElement element = cowElements.get(node.getId());
    if (element == null) {
        element = new CowNodeElement();
        cowElements.put(node.getId(), element);
    }
    if (element.relationshipAddMap == null) {
        element.relationshipAddMap = new ArrayMap<String, RelIdArray>();
    }
    RelIdArray set = element.relationshipAddMap.get(type);
    if (set == null) {
        set = new RelIdArrayWithLoops(type);
        element.relationshipAddMap.put(type, set);
    }
    return set;
}
Also used : RelIdArrayWithLoops(org.neo4j.kernel.impl.util.RelIdArrayWithLoops) RelIdArray(org.neo4j.kernel.impl.util.RelIdArray)

Aggregations

RelIdArray (org.neo4j.kernel.impl.util.RelIdArray)2 RelIdArrayWithLoops (org.neo4j.kernel.impl.util.RelIdArrayWithLoops)2 RelationshipType (org.neo4j.graphdb.RelationshipType)1 RelationshipRecord (org.neo4j.kernel.impl.nioneo.store.RelationshipRecord)1