Search in sources :

Example 1 with RelIdIterator

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

the class NodeImpl method getAllRelationshipsOfType.

List<RelIdIterator> getAllRelationshipsOfType(NodeManager nodeManager, DirectionWrapper direction, RelationshipType... types) {
    ensureRelationshipMapNotNull(nodeManager);
    List<RelIdIterator> relTypeList = new LinkedList<RelIdIterator>();
    boolean hasModifications = nodeManager.getLockReleaser().hasRelationshipModifications(this);
    for (RelationshipType type : types) {
        String typeName = type.name();
        RelIdArray src = getRelIdArray(typeName);
        Collection<Long> remove = null;
        RelIdArray add = null;
        RelIdIterator iterator = null;
        if (hasModifications) {
            remove = nodeManager.getCowRelationshipRemoveMap(this, typeName);
            add = nodeManager.getCowRelationshipAddMap(this, typeName);
            iterator = new CombinedRelIdIterator(typeName, direction, src, add, remove);
        } else {
            iterator = src != null ? src.iterator(direction) : empty(typeName).iterator(direction);
        }
        relTypeList.add(iterator);
    }
    return relTypeList;
}
Also used : RelationshipType(org.neo4j.graphdb.RelationshipType) 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 2 with RelIdIterator

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

the class LockReleaser method populateCreatedNodes.

private void populateCreatedNodes(PrimitiveElement element, TransactionDataImpl result) {
    RelIdArray createdNodes = nodeManager.getCreatedNodes();
    for (RelIdIterator iterator = createdNodes.iterator(DirectionWrapper.BOTH); iterator.hasNext(); ) {
        long nodeId = iterator.next();
        if (element != null && element.nodes != null) {
            CowNodeElement nodeElement = element.nodes.get(nodeId);
            if (nodeElement != null && nodeElement.deleted) {
                continue;
            }
        }
        result.created(new NodeProxy(nodeId, nodeManager));
    }
}
Also used : RelIdArray(org.neo4j.kernel.impl.util.RelIdArray) RelIdIterator(org.neo4j.kernel.impl.util.RelIdIterator)

Example 3 with RelIdIterator

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

the class LockReleaser method populateNodeRelEvent.

private void populateNodeRelEvent(PrimitiveElement element, TransactionDataImpl result, long nodeId, RelIdArray createdRels) {
    for (RelIdIterator iterator = createdRels.iterator(DirectionWrapper.BOTH); iterator.hasNext(); ) {
        long relId = iterator.next();
        CowRelElement relElement = element.relationships.get(relId);
        if (relElement != null && relElement.deleted) {
            continue;
        }
        RelationshipProxy rel = new RelationshipProxy(relId, nodeManager);
        if (rel.getStartNode().getId() == nodeId) {
            result.created(new RelationshipProxy(relId, nodeManager));
        }
    }
}
Also used : RelIdIterator(org.neo4j.kernel.impl.util.RelIdIterator)

Example 4 with RelIdIterator

use of org.neo4j.kernel.impl.util.RelIdIterator 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)

Aggregations

RelIdIterator (org.neo4j.kernel.impl.util.RelIdIterator)4 RelIdArray (org.neo4j.kernel.impl.util.RelIdArray)3 LinkedList (java.util.LinkedList)2 CombinedRelIdIterator (org.neo4j.kernel.impl.util.CombinedRelIdIterator)2 RelationshipType (org.neo4j.graphdb.RelationshipType)1