use of org.neo4j.kernel.impl.nioneo.store.PropertyData in project neo4j-mobile-android by neo4j-contrib.
the class WriteTransaction method nodeDelete.
@Override
public 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);
long nextProp = nodeRecord.getNextProp();
ArrayMap<Integer, PropertyData> propertyMap = getAndDeletePropertyChain(nextProp);
return propertyMap;
}
use of org.neo4j.kernel.impl.nioneo.store.PropertyData in project neo4j-mobile-android by neo4j-contrib.
the class Primitive method getProperty.
public Object getProperty(NodeManager nodeManager, String key) throws NotFoundException {
if (key == null) {
throw new IllegalArgumentException("null key");
}
ArrayMap<Integer, PropertyData> skipMap = nodeManager.getCowPropertyRemoveMap(this);
ArrayMap<Integer, PropertyData> addMap = nodeManager.getCowPropertyAddMap(this);
ensureFullProperties(nodeManager);
for (PropertyIndex index : nodeManager.index(key)) {
if (skipMap != null && skipMap.get(index.getKeyId()) != null) {
throw newPropertyNotFoundException(key);
}
if (addMap != null) {
PropertyData property = addMap.get(index.getKeyId());
if (property != null) {
return getPropertyValue(nodeManager, property);
}
}
PropertyData property = getPropertyForIndex(index.getKeyId());
if (property != null) {
return getPropertyValue(nodeManager, property);
}
}
PropertyData property = getSlowProperty(nodeManager, addMap, skipMap, key);
if (property != null) {
return getPropertyValue(nodeManager, property);
}
throw newPropertyNotFoundException(key);
}
use of org.neo4j.kernel.impl.nioneo.store.PropertyData in project neo4j-mobile-android by neo4j-contrib.
the class Primitive method toPropertyArray.
private PropertyData[] toPropertyArray(ArrayMap<Integer, PropertyData> loadedProperties) {
if (loadedProperties == null || loadedProperties.size() == 0) {
return NO_PROPERTIES;
}
PropertyData[] result = new PropertyData[loadedProperties.size()];
int i = 0;
for (PropertyData property : loadedProperties.values()) {
result[i++] = property;
}
return result;
}
use of org.neo4j.kernel.impl.nioneo.store.PropertyData in project neo4j-mobile-android by neo4j-contrib.
the class RelationshipImpl method delete.
public void delete(NodeManager nodeManager) {
NodeImpl startNode = null;
NodeImpl endNode = null;
boolean startNodeLocked = false;
boolean endNodeLocked = false;
boolean thisLocked = false;
boolean success = false;
try {
startNode = nodeManager.getLightNode(getStartNodeId());
if (startNode != null) {
nodeManager.acquireLock(startNode, LockType.WRITE);
startNodeLocked = true;
}
endNode = nodeManager.getLightNode(getEndNodeId());
if (endNode != null) {
nodeManager.acquireLock(endNode, LockType.WRITE);
endNodeLocked = true;
}
nodeManager.acquireLock(this, LockType.WRITE);
thisLocked = true;
// no need to load full relationship, all properties will be
// deleted when relationship is deleted
ArrayMap<Integer, PropertyData> skipMap = nodeManager.getCowPropertyRemoveMap(this, true);
ArrayMap<Integer, PropertyData> removedProps = nodeManager.deleteRelationship(this);
if (removedProps.size() > 0) {
for (int index : removedProps.keySet()) {
skipMap.put(index, removedProps.get(index));
}
}
success = true;
RelationshipType type = getType(nodeManager);
long id = getId();
if (startNode != null) {
startNode.removeRelationship(nodeManager, type, id);
}
if (endNode != null) {
endNode.removeRelationship(nodeManager, type, id);
}
success = true;
} finally {
boolean releaseFailed = false;
try {
if (thisLocked) {
nodeManager.releaseLock(this, LockType.WRITE);
}
} catch (Exception e) {
releaseFailed = true;
e.printStackTrace();
}
try {
if (startNodeLocked) {
nodeManager.releaseLock(startNode, LockType.WRITE);
}
} catch (Exception e) {
releaseFailed = true;
e.printStackTrace();
}
try {
if (endNodeLocked) {
nodeManager.releaseLock(endNode, LockType.WRITE);
}
} catch (Exception e) {
releaseFailed = true;
e.printStackTrace();
}
if (!success) {
nodeManager.setRollbackOnly();
}
if (releaseFailed) {
throw new LockException("Unable to release locks [" + startNode + "," + endNode + "] in relationship delete->" + this);
}
}
}
use of org.neo4j.kernel.impl.nioneo.store.PropertyData in project neo4j-mobile-android by neo4j-contrib.
the class BatchInserterImpl method getPropertyChain.
private Map<String, Object> getPropertyChain(long nextProp) {
PropertyStore propStore = getPropertyStore();
Map<String, Object> properties = new HashMap<String, Object>();
while (nextProp != Record.NO_NEXT_PROPERTY.intValue()) {
PropertyRecord propRecord = propStore.getRecord(nextProp);
for (PropertyBlock propBlock : propRecord.getPropertyBlocks()) {
String key = indexHolder.getStringKey(propBlock.getKeyIndexId());
PropertyData propertyData = propBlock.newPropertyData(propRecord);
Object value = propertyData.getValue() != null ? propertyData.getValue() : propBlock.getType().getValue(propBlock, getPropertyStore());
properties.put(key, value);
}
nextProp = propRecord.getNextProp();
}
return properties;
}
Aggregations