use of org.neo4j.kernel.impl.util.RelIdArray 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));
}
}
use of org.neo4j.kernel.impl.util.RelIdArray in project graphdb by neo4j-attic.
the class LockReleaser method getCowRelationshipAddMap.
public RelIdArray getCowRelationshipAddMap(NodeImpl node, String type, boolean create) {
if (!create) {
return getCowRelationshipRemoveMap(node, type);
}
PrimitiveElement primitiveElement = getAndSetupPrimitiveElement();
ArrayMap<Long, CowNodeElement> cowElements = primitiveElement.nodes;
CowNodeElement element = cowElements.get(node.id);
if (element == null) {
element = new CowNodeElement();
cowElements.put(node.id, element);
}
if (element.relationshipAddMap == null) {
element.relationshipAddMap = new ArrayMap<String, RelIdArray>();
}
RelIdArray set = element.relationshipAddMap.get(type);
if (set == null) {
set = new RelIdArray();
element.relationshipAddMap.put(type, set);
}
return set;
}
use of org.neo4j.kernel.impl.util.RelIdArray 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;
}
use of org.neo4j.kernel.impl.util.RelIdArray 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);
}
}
use of org.neo4j.kernel.impl.util.RelIdArray in project neo4j-mobile-android by neo4j-contrib.
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);
populateNodeRelEvent(element, result, nodeId, createdRels);
}
}
if (nodeElement.relationshipRemoveMap != null) {
for (String type : nodeElement.relationshipRemoveMap.keySet()) {
Collection<Long> deletedRels = nodeElement.relationshipRemoveMap.get(type);
for (long relId : deletedRels) {
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);
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);
Object oldValue = data.getValue();
if (oldValue == null && !nodeElement.deleted) {
nodeImpl.getCommittedPropertyValue(nodeManager, key);
}
result.removedProperty(node, key, oldValue);
}
}
}
}
Aggregations