Search in sources :

Example 1 with RelIdIterator

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

the class LockReleaser method populateCreatedNodes.

private void populateCreatedNodes(PrimitiveElement element, TransactionDataImpl result) {
    RelIdArray createdNodes = nodeManager.getCreatedNodes();
    for (RelIdIterator iterator = createdNodes.iterator(); 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.RelIdArray.RelIdIterator)

Example 2 with RelIdIterator

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

the class TestRelIdArray method testBasic.

@Test
public void testBasic() throws Exception {
    RelIdArray array = new RelIdArray();
    array.add(1);
    array.add(2);
    array.add(3);
    RelIdIterator itr = array.iterator();
    assertTrue(itr.hasNext());
    assertTrue(itr.hasNext());
    assertEquals(1L, itr.next());
    assertTrue(itr.hasNext());
    assertEquals(2L, itr.next());
    assertTrue(itr.hasNext());
    assertEquals(3L, itr.next());
    assertFalse(itr.hasNext());
    assertFalse(itr.hasNext());
}
Also used : RelIdArray(org.neo4j.kernel.impl.util.RelIdArray) RelIdIterator(org.neo4j.kernel.impl.util.RelIdArray.RelIdIterator) Test(org.junit.Test)

Example 3 with RelIdIterator

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

the class LockReleaser method populateNodeRelEvent.

private void populateNodeRelEvent(PrimitiveElement element, TransactionDataImpl result) {
    for (long nodeId : element.nodes.keySet()) {
        CowNodeElement nodeElement = element.nodes.get(nodeId);
        NodeProxy node = new NodeProxy(nodeId, nodeManager);
        NodeImpl nodeImpl = nodeManager.getNodeForProxy(nodeId);
        if (nodeElement.deleted) {
            if (nodeManager.nodeCreated(nodeId)) {
                continue;
            }
            result.deleted(node);
        }
        if (nodeElement.relationshipAddMap != null && !nodeElement.deleted) {
            for (String type : nodeElement.relationshipAddMap.keySet()) {
                RelIdArray createdRels = nodeElement.relationshipAddMap.get(type);
                for (RelIdIterator iterator = createdRels.iterator(); 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));
                    }
                }
            }
        }
        if (nodeElement.relationshipRemoveMap != null) {
            for (String type : nodeElement.relationshipRemoveMap.keySet()) {
                RelIdArray deletedRels = nodeElement.relationshipRemoveMap.get(type);
                for (RelIdIterator iterator = deletedRels.iterator(); iterator.hasNext(); ) {
                    long relId = iterator.next();
                    if (nodeManager.relCreated(relId)) {
                        continue;
                    }
                    RelationshipProxy rel = new RelationshipProxy(relId, nodeManager);
                    if (rel.getStartNode().getId() == nodeId) {
                        result.deleted(new RelationshipProxy(relId, nodeManager));
                    }
                }
            }
        }
        if (nodeElement.propertyAddMap != null && !nodeElement.deleted) {
            for (PropertyData data : nodeElement.propertyAddMap.values()) {
                String key = nodeManager.getKeyForProperty(data.getId());
                Object oldValue = nodeImpl.getCommittedPropertyValue(nodeManager, key);
                Object newValue = data.getValue();
                result.assignedProperty(node, key, newValue, oldValue);
            }
        }
        if (nodeElement.propertyRemoveMap != null) {
            for (PropertyData data : nodeElement.propertyRemoveMap.values()) {
                String key = nodeManager.getKeyForProperty(data.getId());
                Object oldValue = data.getValue();
                if (oldValue == null && !nodeElement.deleted) {
                    nodeImpl.getCommittedPropertyValue(nodeManager, key);
                }
                result.removedProperty(node, key, oldValue);
            }
        }
    }
}
Also used : PropertyData(org.neo4j.kernel.impl.nioneo.store.PropertyData) RelIdArray(org.neo4j.kernel.impl.util.RelIdArray) RelIdIterator(org.neo4j.kernel.impl.util.RelIdArray.RelIdIterator)

Aggregations

RelIdArray (org.neo4j.kernel.impl.util.RelIdArray)3 RelIdIterator (org.neo4j.kernel.impl.util.RelIdArray.RelIdIterator)3 Test (org.junit.Test)1 PropertyData (org.neo4j.kernel.impl.nioneo.store.PropertyData)1