use of org.neo4j.kernel.impl.nioneo.store.PropertyData in project graphdb by neo4j-attic.
the class Primitive method getProperty.
public Object getProperty(NodeManager nodeManager, String key, Object defaultValue) {
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) {
return defaultValue;
}
if (addMap != null) {
PropertyData property = addMap.get(index.getKeyId());
if (property != null) {
return getPropertyValue(nodeManager, property);
}
}
PropertyData property = propertyMap.get(index.getKeyId());
if (property != null) {
return getPropertyValue(nodeManager, property);
}
}
PropertyData property = getSlowProperty(nodeManager, addMap, skipMap, key);
if (property != null) {
return getPropertyValue(nodeManager, property);
}
return defaultValue;
}
use of org.neo4j.kernel.impl.nioneo.store.PropertyData 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.nioneo.store.PropertyData 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.nioneo.store.PropertyData in project graphdb by neo4j-attic.
the class Primitive method getPropertyValues.
public Iterable<Object> getPropertyValues(NodeManager nodeManager) {
ArrayMap<Integer, PropertyData> skipMap = nodeManager.getCowPropertyRemoveMap(this);
ArrayMap<Integer, PropertyData> addMap = nodeManager.getCowPropertyAddMap(this);
ensureFullProperties(nodeManager);
List<Object> values = new ArrayList<Object>();
for (Integer index : propertyMap.keySet()) {
if (skipMap != null && skipMap.get(index) != null) {
continue;
}
if (addMap != null && addMap.get(index) != null) {
continue;
}
values.add(propertyMap.get(index).getValue());
}
if (addMap != null) {
for (PropertyData property : addMap.values()) {
values.add(property.getValue());
}
}
return values;
}
use of org.neo4j.kernel.impl.nioneo.store.PropertyData in project graphdb by neo4j-attic.
the class Primitive method hasProperty.
public boolean hasProperty(NodeManager nodeManager, String key) {
if (key == null) {
return false;
}
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) {
return false;
}
if (addMap != null) {
PropertyData property = addMap.get(index.getKeyId());
if (property != null) {
return true;
}
}
PropertyData property = propertyMap.get(index.getKeyId());
if (property != null) {
return true;
}
}
PropertyData property = getSlowProperty(nodeManager, addMap, skipMap, key);
if (property != null) {
return true;
}
return false;
}
Aggregations