use of org.neo4j.kernel.impl.util.RelIdArray in project neo4j-mobile-android by neo4j-contrib.
the class NodeImpl method getMoreRelationships.
boolean getMoreRelationships(NodeManager nodeManager) {
Triplet<ArrayMap<String, RelIdArray>, Map<Long, RelationshipImpl>, Long> rels;
if (!hasMoreRelationshipsToLoad()) {
return false;
}
synchronized (this) {
if (!hasMoreRelationshipsToLoad()) {
return false;
}
rels = nodeManager.getMoreRelationships(this);
ArrayMap<String, RelIdArray> addMap = rels.first();
if (addMap.size() == 0) {
return false;
}
for (String type : addMap.keySet()) {
RelIdArray addRels = addMap.get(type);
// IntArray srcRels = tmpRelMap.get( type );
RelIdArray srcRels = getRelIdArray(type);
if (srcRels == null) {
putRelIdArray(addRels);
} else {
RelIdArray newSrcRels = srcRels.addAll(addRels);
// This can happen if srcRels gets upgraded to a RelIdArrayWithLoops
if (newSrcRels != srcRels) {
putRelIdArray(newSrcRels);
}
}
}
setRelChainPosition(rels.third());
}
nodeManager.putAllInRelCache(rels.second());
return true;
}
use of org.neo4j.kernel.impl.util.RelIdArray in project neo4j-mobile-android by neo4j-contrib.
the class NodeImpl method getMoreRelationships.
private Triplet<ArrayMap<String, RelIdArray>, Map<Long, RelationshipImpl>, Long> getMoreRelationships(NodeManager nodeManager, ArrayMap<String, RelIdArray> tmpRelMap) {
if (!hasMoreRelationshipsToLoad()) {
return null;
}
Triplet<ArrayMap<String, RelIdArray>, Map<Long, RelationshipImpl>, Long> rels = nodeManager.getMoreRelationships(this);
ArrayMap<String, RelIdArray> addMap = rels.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 {
RelIdArray newSrcRels = srcRels.addAll(addRels);
// This can happen if srcRels gets upgraded to a RelIdArrayWithLoops
if (newSrcRels != srcRels) {
tmpRelMap.put(type, newSrcRels);
}
}
}
return rels;
// nodeManager.putAllInRelCache( pair.other() );
}
use of org.neo4j.kernel.impl.util.RelIdArray in project neo4j-mobile-android by neo4j-contrib.
the class NodeImpl method commitRelationshipMaps.
protected void commitRelationshipMaps(ArrayMap<String, RelIdArray> cowRelationshipAddMap, ArrayMap<String, Collection<Long>> cowRelationshipRemoveMap) {
if (relationships == null) {
// we will load full in some other tx
return;
}
synchronized (this) {
if (cowRelationshipAddMap != null) {
for (String type : cowRelationshipAddMap.keySet()) {
RelIdArray add = cowRelationshipAddMap.get(type);
Collection<Long> remove = null;
if (cowRelationshipRemoveMap != null) {
remove = cowRelationshipRemoveMap.get(type);
}
RelIdArray src = getRelIdArray(type);
putRelIdArray(RelIdArray.from(src, add, remove));
}
}
if (cowRelationshipRemoveMap != null) {
for (String type : cowRelationshipRemoveMap.keySet()) {
if (cowRelationshipAddMap != null && cowRelationshipAddMap.get(type) != null) {
continue;
}
RelIdArray src = getRelIdArray(type);
if (src != null) {
Collection<Long> remove = cowRelationshipRemoveMap.get(type);
putRelIdArray(RelIdArray.from(src, null, remove));
}
}
}
}
}
use of org.neo4j.kernel.impl.util.RelIdArray 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;
}
use of org.neo4j.kernel.impl.util.RelIdArray in project neo4j-mobile-android by neo4j-contrib.
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, DirectionWrapper dir) {
RelIdArray relationshipSet = nodeManager.getCowRelationshipAddMap(this, type.name(), true);
relationshipSet.add(relId, dir);
}
Aggregations