Search in sources :

Example 16 with RelIdArray

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

the class NodeImpl method getAllRelationships.

List<RelIdIterator> getAllRelationships(NodeManager nodeManager, DirectionWrapper direction) {
    ensureRelationshipMapNotNull(nodeManager);
    List<RelIdIterator> relTypeList = new LinkedList<RelIdIterator>();
    boolean hasModifications = nodeManager.getLockReleaser().hasRelationshipModifications(this);
    ArrayMap<String, RelIdArray> addMap = null;
    if (hasModifications) {
        addMap = nodeManager.getCowRelationshipAddMap(this);
    }
    for (RelIdArray src : relationships) {
        String type = src.getType();
        Collection<Long> remove = null;
        RelIdArray add = null;
        RelIdIterator iterator = null;
        if (hasModifications) {
            remove = nodeManager.getCowRelationshipRemoveMap(this, type);
            if (addMap != null) {
                add = addMap.get(type);
            }
            iterator = new CombinedRelIdIterator(type, direction, src, add, remove);
        } else {
            iterator = src.iterator(direction);
        }
        relTypeList.add(iterator);
    }
    if (addMap != null) {
        for (String type : addMap.keySet()) {
            if (getRelIdArray(type) == null) {
                Collection<Long> remove = nodeManager.getCowRelationshipRemoveMap(this, type);
                RelIdArray add = addMap.get(type);
                relTypeList.add(new CombinedRelIdIterator(type, direction, null, add, remove));
            }
        }
    }
    return relTypeList;
}
Also used : RelIdArray(org.neo4j.kernel.impl.util.RelIdArray) LinkedList(java.util.LinkedList) CombinedRelIdIterator(org.neo4j.kernel.impl.util.CombinedRelIdIterator) RelIdIterator(org.neo4j.kernel.impl.util.RelIdIterator) CombinedRelIdIterator(org.neo4j.kernel.impl.util.CombinedRelIdIterator)

Example 17 with RelIdArray

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

the class NodeImpl method toRelIdArray.

private RelIdArray[] toRelIdArray(ArrayMap<String, RelIdArray> tmpRelMap) {
    if (tmpRelMap == null || tmpRelMap.size() == 0) {
        return NO_RELATIONSHIPS;
    }
    RelIdArray[] result = new RelIdArray[tmpRelMap.size()];
    int i = 0;
    for (RelIdArray array : tmpRelMap.values()) {
        result[i++] = array;
    }
    return result;
}
Also used : RelIdArray(org.neo4j.kernel.impl.util.RelIdArray)

Example 18 with RelIdArray

use of org.neo4j.kernel.impl.util.RelIdArray in project graphdb by neo4j-attic.

the class NodeImpl method addRelationship.

// caller is responsible for acquiring lock
// this method is only called when a relationship is created or
// a relationship delete is undone or when the full node is loaded
void addRelationship(NodeManager nodeManager, RelationshipType type, long relId) {
    RelIdArray relationshipSet = nodeManager.getCowRelationshipAddMap(this, type.name(), true);
    relationshipSet.add(relId);
}
Also used : RelIdArray(org.neo4j.kernel.impl.util.RelIdArray)

Example 19 with RelIdArray

use of org.neo4j.kernel.impl.util.RelIdArray in project graphdb by neo4j-attic.

the class NodeImpl method removeRelationship.

// caller is responsible for acquiring lock
// this method is only called when a undo create relationship or
// a relationship delete is invoked.
void removeRelationship(NodeManager nodeManager, RelationshipType type, long relId) {
    RelIdArray relationshipSet = nodeManager.getCowRelationshipRemoveMap(this, type.name(), true);
    relationshipSet.add(relId);
}
Also used : RelIdArray(org.neo4j.kernel.impl.util.RelIdArray)

Example 20 with RelIdArray

use of org.neo4j.kernel.impl.util.RelIdArray in project graphdb by neo4j-attic.

the class NodeImpl method getMoreRelationships.

private Map<Long, RelationshipImpl> getMoreRelationships(NodeManager nodeManager, ArrayMap<String, RelIdArray> tmpRelMap) {
    if (!relChainPosition.hasMore()) {
        return null;
    }
    Pair<ArrayMap<String, RelIdArray>, Map<Long, RelationshipImpl>> pair = nodeManager.getMoreRelationships(this);
    ArrayMap<String, RelIdArray> addMap = pair.first();
    if (addMap.size() == 0) {
        return null;
    }
    for (String type : addMap.keySet()) {
        RelIdArray addRels = addMap.get(type);
        RelIdArray srcRels = tmpRelMap.get(type);
        if (srcRels == null) {
            tmpRelMap.put(type, addRels);
        } else {
            srcRels.addAll(addRels);
        }
    }
    return pair.other();
// nodeManager.putAllInRelCache( pair.other() );
}
Also used : ArrayMap(org.neo4j.kernel.impl.util.ArrayMap) RelIdArray(org.neo4j.kernel.impl.util.RelIdArray) Map(java.util.Map) ArrayMap(org.neo4j.kernel.impl.util.ArrayMap)

Aggregations

RelIdArray (org.neo4j.kernel.impl.util.RelIdArray)26 ArrayMap (org.neo4j.kernel.impl.util.ArrayMap)5 LinkedList (java.util.LinkedList)4 Map (java.util.Map)4 RelationshipType (org.neo4j.graphdb.RelationshipType)4 Test (org.junit.Test)3 RelIdIterator (org.neo4j.kernel.impl.util.RelIdArray.RelIdIterator)3 RelIdIterator (org.neo4j.kernel.impl.util.RelIdIterator)3 PropertyData (org.neo4j.kernel.impl.nioneo.store.PropertyData)2 CombinedRelIdIterator (org.neo4j.kernel.impl.util.CombinedRelIdIterator)2 RelIdArrayWithLoops (org.neo4j.kernel.impl.util.RelIdArrayWithLoops)2 HashMap (java.util.HashMap)1 RelationshipChainPosition (org.neo4j.kernel.impl.nioneo.store.RelationshipChainPosition)1 RelationshipData (org.neo4j.kernel.impl.nioneo.store.RelationshipData)1 RelationshipRecord (org.neo4j.kernel.impl.nioneo.store.RelationshipRecord)1