use of org.neo4j.kernel.impl.nioneo.store.NodeRecord in project neo4j-mobile-android by neo4j-contrib.
the class WriteTransaction method nodeRemoveProperty.
@Override
public void nodeRemoveProperty(long nodeId, PropertyData propertyData) {
long propertyId = propertyData.getId();
NodeRecord nodeRecord = getNodeRecord(nodeId);
if (nodeRecord == null) {
nodeRecord = getNodeStore().getRecord(nodeId);
addNodeRecord(nodeRecord);
}
if (!nodeRecord.inUse()) {
throw new IllegalStateException("Property remove on node[" + nodeId + "] illegal since it has been deleted.");
}
assert assertPropertyChain(nodeRecord);
PropertyRecord propRecord = getPropertyRecord(propertyId, false, true);
if (!propRecord.inUse()) {
throw new IllegalStateException("Unable to delete property[" + propertyId + "] since it is already deleted.");
}
propRecord.setNodeId(nodeId);
PropertyBlock block = propRecord.removePropertyBlock(propertyData.getIndex());
if (block == null) {
throw new IllegalStateException("Property with index[" + propertyData.getIndex() + "] is not present in property[" + propertyId + "]");
}
if (block.isLight()) {
getPropertyStore().makeHeavy(block);
}
for (DynamicRecord valueRecord : block.getValueRecords()) {
assert valueRecord.inUse();
valueRecord.setInUse(false, block.getType().intValue());
propRecord.addDeletedRecord(valueRecord);
}
// propRecord.removeBlock( propertyData.getIndex() );
if (propRecord.size() > 0) {
/*
* There are remaining blocks in the record. We do not unlink yet.
*/
propRecord.setChanged();
assert assertPropertyChain(nodeRecord);
return;
} else {
if (unlinkPropertyRecord(propRecord, nodeRecord)) {
addNodeRecord(nodeRecord);
}
}
}
use of org.neo4j.kernel.impl.nioneo.store.NodeRecord in project graphdb by neo4j-attic.
the class BatchInserterImpl method createNode.
public long createNode(Map<String, Object> properties) {
long nodeId = getNodeStore().nextId();
NodeRecord nodeRecord = new NodeRecord(nodeId);
nodeRecord.setInUse(true);
nodeRecord.setCreated();
nodeRecord.setNextProp(createPropertyChain(properties));
getNodeStore().updateRecord(nodeRecord);
return nodeId;
}
use of org.neo4j.kernel.impl.nioneo.store.NodeRecord 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.NodeRecord in project graphdb by neo4j-attic.
the class ReadTransaction method getRelationshipChainPosition.
public RelationshipChainPosition getRelationshipChainPosition(long nodeId) {
NodeRecord nodeRecord = getNodeStore().getRecord(nodeId);
long nextRel = nodeRecord.getNextRel();
return new RelationshipChainPosition(nextRel);
}
use of org.neo4j.kernel.impl.nioneo.store.NodeRecord 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;
}
Aggregations