use of org.neo4j.kernel.impl.nioneo.store.PropertyData in project graphdb by neo4j-attic.
the class Primitive method removeProperty.
public Object removeProperty(NodeManager nodeManager, String key) {
if (key == null) {
throw new IllegalArgumentException("Null parameter.");
}
nodeManager.acquireLock(this, LockType.WRITE);
boolean success = false;
try {
ensureFullProperties(nodeManager);
PropertyData property = null;
ArrayMap<Integer, PropertyData> addMap = nodeManager.getCowPropertyAddMap(this);
ArrayMap<Integer, PropertyData> removeMap = nodeManager.getCowPropertyRemoveMap(this, true);
for (PropertyIndex cachedIndex : nodeManager.index(key)) {
if (addMap != null) {
property = addMap.remove(cachedIndex.getKeyId());
if (property != null) {
removeMap.put(cachedIndex.getKeyId(), property);
break;
}
}
if (removeMap.get(cachedIndex.getKeyId()) != null) {
success = true;
return null;
}
property = propertyMap.get(cachedIndex.getKeyId());
if (property != null) {
removeMap.put(cachedIndex.getKeyId(), property);
break;
}
}
if (property == null && !nodeManager.hasAllPropertyIndexes()) {
if (addMap != null) {
for (int keyId : addMap.keySet()) {
if (!nodeManager.hasIndexFor(keyId)) {
PropertyIndex indexToCheck = nodeManager.getIndexFor(keyId);
if (indexToCheck.getKey().equals(key)) {
property = addMap.remove(indexToCheck.getKeyId());
if (property != null) {
removeMap.put(indexToCheck.getKeyId(), property);
break;
}
}
}
}
if (property == null) {
for (int keyId : propertyMap.keySet()) {
if (!nodeManager.hasIndexFor(keyId)) {
PropertyIndex indexToCheck = nodeManager.getIndexFor(keyId);
if (indexToCheck.getKey().equals(key)) {
property = propertyMap.get(indexToCheck.getKeyId());
if (property != null) {
removeMap.put(indexToCheck.getKeyId(), property);
break;
}
}
}
}
}
}
}
if (property == null) {
success = true;
return null;
}
removeProperty(nodeManager, property.getId());
success = true;
return getPropertyValue(nodeManager, property);
} finally {
nodeManager.releaseLock(this, LockType.WRITE);
if (!success) {
nodeManager.setRollbackOnly();
}
}
}
Aggregations