use of org.neo4j.kernel.impl.util.ArrayMap in project graphdb by neo4j-attic.
the class ReadTransaction method nodeGetProperties.
ArrayMap<Integer, PropertyData> nodeGetProperties(long nodeId) {
NodeRecord nodeRecord = getNodeStore().getRecord(nodeId);
long nextProp = nodeRecord.getNextProp();
ArrayMap<Integer, PropertyData> propertyMap = new ArrayMap<Integer, PropertyData>(9, false, true);
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 ReadTransaction method relGetProperties.
public ArrayMap<Integer, PropertyData> relGetProperties(long relId) {
RelationshipRecord relRecord = getRelationshipStore().getRecord(relId);
if (!relRecord.inUse()) {
throw new InvalidRecordException("Relationship[" + relId + "] not in use");
}
long nextProp = relRecord.getNextProp();
ArrayMap<Integer, PropertyData> propertyMap = new ArrayMap<Integer, PropertyData>(9, false, true);
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 nodeDelete.
ArrayMap<Integer, PropertyData> nodeDelete(long nodeId) {
NodeRecord nodeRecord = getNodeRecord(nodeId);
if (nodeRecord == null) {
nodeRecord = getNodeStore().getRecord(nodeId);
addNodeRecord(nodeRecord);
}
if (!nodeRecord.inUse()) {
throw new IllegalStateException("Unable to delete Node[" + nodeId + "] since it has already been deleted.");
}
nodeRecord.setInUse(false);
ArrayMap<Integer, PropertyData> propertyMap = new ArrayMap<Integer, PropertyData>(9, false, true);
long nextProp = nodeRecord.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);
}
}
return propertyMap;
}
use of org.neo4j.kernel.impl.util.ArrayMap in project graphdb by neo4j-attic.
the class NodeImpl method getMoreRelationships.
private Map<Long, RelationshipImpl> getMoreRelationships(NodeManager nodeManager, ArrayMap<String, RelIdArray> tmpRelMap) {
if (!relChainPosition.hasMore()) {
return null;
}
Pair<ArrayMap<String, RelIdArray>, Map<Long, RelationshipImpl>> pair = nodeManager.getMoreRelationships(this);
ArrayMap<String, RelIdArray> addMap = pair.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 {
srcRels.addAll(addRels);
}
}
return pair.other();
// nodeManager.putAllInRelCache( pair.other() );
}
use of org.neo4j.kernel.impl.util.ArrayMap in project graphdb by neo4j-attic.
the class NodeManager method getMoreRelationships.
Pair<ArrayMap<String, RelIdArray>, Map<Long, RelationshipImpl>> getMoreRelationships(NodeImpl node) {
long nodeId = node.getId();
RelationshipChainPosition position = node.getRelChainPosition();
Iterable<RelationshipData> rels = persistenceManager.getMoreRelationships(nodeId, position);
ArrayMap<String, RelIdArray> newRelationshipMap = new ArrayMap<String, RelIdArray>();
Map<Long, RelationshipImpl> relsMap = new HashMap<Long, RelationshipImpl>(150);
for (RelationshipData rel : rels) {
long relId = rel.getId();
RelationshipImpl relImpl = relCache.get(relId);
RelationshipType type = null;
if (relImpl == null) {
type = getRelationshipTypeById(rel.relationshipType());
assert type != null;
relImpl = new RelationshipImpl(relId, rel.firstNode(), rel.secondNode(), type, false);
relsMap.put(relId, relImpl);
// relCache.put( relId, relImpl );
} else {
type = relImpl.getType();
}
RelIdArray relationshipSet = newRelationshipMap.get(type.name());
if (relationshipSet == null) {
relationshipSet = new RelIdArray();
newRelationshipMap.put(type.name(), relationshipSet);
}
relationshipSet.add(relId);
}
// relCache.putAll( relsMap );
return Pair.of(newRelationshipMap, relsMap);
}
Aggregations