use of org.neo4j.kernel.impl.nioneo.store.PropertyData 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);
}
}
}
}
use of org.neo4j.kernel.impl.nioneo.store.PropertyData 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.nioneo.store.PropertyData 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.nioneo.store.PropertyData 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.nioneo.store.PropertyData in project graphdb by neo4j-attic.
the class WriteTransaction method relGetProperties.
public ArrayMap<Integer, PropertyData> relGetProperties(long relId, boolean light) {
ArrayMap<Integer, PropertyData> propertyMap = new ArrayMap<Integer, PropertyData>(9, false, true);
RelationshipRecord relRecord = getRelationshipRecord(relId);
if (relRecord != null && relRecord.isCreated()) {
return propertyMap;
}
if (relRecord != null) {
if (!relRecord.inUse() && !light) {
throw new IllegalStateException("Relationship[" + relId + "] has been deleted in this tx");
}
}
relRecord = getRelationshipStore().getRecord(relId);
if (!relRecord.inUse()) {
throw new InvalidRecordException("Relationship[" + relId + "] not in use");
}
long nextProp = relRecord.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;
}
Aggregations