use of org.neo4j.kernel.impl.util.ArrayMap 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.ArrayMap 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.ArrayMap in project graphdb by neo4j-attic.
the class WriteTransaction method nodeGetProperties.
ArrayMap<Integer, PropertyData> nodeGetProperties(long nodeId, boolean light) {
ArrayMap<Integer, PropertyData> propertyMap = new ArrayMap<Integer, PropertyData>(9, false, true);
NodeRecord nodeRecord = getNodeRecord(nodeId);
if (nodeRecord != null && nodeRecord.isCreated()) {
return propertyMap;
}
if (nodeRecord != null) {
if (!nodeRecord.inUse() && !light) {
throw new IllegalStateException("Node[" + nodeId + "] has been deleted in this tx");
}
}
nodeRecord = getNodeStore().getRecord(nodeId);
if (!nodeRecord.inUse()) {
throw new InvalidRecordException("Node[" + nodeId + "] not in use");
}
long nextProp = nodeRecord.getNextProp();
while (nextProp != Record.NO_NEXT_PROPERTY.intValue()) {
PropertyRecord propRecord = getPropertyStore().getLightRecord(nextProp);
propertyMap.put(propRecord.getKeyIndexId(), new PropertyData(propRecord.getId(), propertyGetValueOrNull(propRecord)));
nextProp = propRecord.getNextProp();
}
return propertyMap;
}
use of org.neo4j.kernel.impl.util.ArrayMap in project graphdb by neo4j-attic.
the class WriteTransaction method relDelete.
ArrayMap<Integer, PropertyData> relDelete(long id) {
RelationshipRecord record = getRelationshipRecord(id);
if (record == null) {
record = getRelationshipStore().getRecord(id);
addRelationshipRecord(record);
}
if (!record.inUse()) {
throw new IllegalStateException("Unable to delete relationship[" + id + "] since it is already deleted.");
}
ArrayMap<Integer, PropertyData> propertyMap = new ArrayMap<Integer, PropertyData>(9, false, true);
long nextProp = record.getNextProp();
while (nextProp != Record.NO_NEXT_PROPERTY.intValue()) {
PropertyRecord propRecord = getPropertyRecord(nextProp);
if (propRecord == null) {
propRecord = getPropertyStore().getRecord(nextProp);
addPropertyRecord(propRecord);
}
if (propRecord.isLight()) {
getPropertyStore().makeHeavy(propRecord);
}
if (!propRecord.isCreated()) {
if (!propRecord.isChanged()) {
propertyMap.put(propRecord.getKeyIndexId(), new PropertyData(propRecord.getId(), propertyGetValueOrNull(propRecord)));
} else {
// we have to re-read committed value since property has
// changed and old value is erased in memory
PropertyRecord diskValue = getPropertyStore().getRecord(propRecord.getId());
getPropertyStore().makeHeavy(diskValue);
propertyMap.put(diskValue.getKeyIndexId(), new PropertyData(diskValue.getId(), propertyGetValueOrNull(diskValue)));
}
}
nextProp = propRecord.getNextProp();
propRecord.setInUse(false);
// TODO: update count on property index record
for (DynamicRecord valueRecord : propRecord.getValueRecords()) {
valueRecord.setInUse(false);
}
}
disconnectRelationship(record);
updateNodes(record);
record.setInUse(false);
return propertyMap;
}
use of org.neo4j.kernel.impl.util.ArrayMap in project graphdb by neo4j-attic.
the class NodeImpl method getMoreRelationships.
boolean getMoreRelationships(NodeManager nodeManager) {
// ArrayMap<String, IntArray> tmpRelMap = relationshipMap;
Pair<ArrayMap<String, RelIdArray>, Map<Long, RelationshipImpl>> pair;
synchronized (this) {
if (!relChainPosition.hasMore()) {
return false;
}
pair = nodeManager.getMoreRelationships(this);
ArrayMap<String, RelIdArray> addMap = pair.first();
if (addMap.size() == 0) {
return false;
}
for (String type : addMap.keySet()) {
RelIdArray addRels = addMap.get(type);
// IntArray srcRels = tmpRelMap.get( type );
RelIdArray srcRels = relationshipMap.get(type);
if (srcRels == null) {
relationshipMap.put(type, addRels);
} else {
srcRels.addAll(addRels);
}
}
}
nodeManager.putAllInRelCache(pair.other());
return true;
}
Aggregations