use of org.neo4j.kernel.impl.nioneo.store.PropertyBlock in project neo4j-mobile-android by neo4j-contrib.
the class WriteTransaction method doRollback.
@Override
public void doRollback() throws XAException {
if (committed) {
throw new XAException("Cannot rollback partialy commited " + "transaction[" + getIdentifier() + "]. Recover and " + "commit");
}
try {
for (RelationshipTypeRecord record : relTypeRecords.values()) {
if (record.isCreated()) {
getRelationshipTypeStore().freeId(record.getId());
for (DynamicRecord dynamicRecord : record.getTypeRecords()) {
if (dynamicRecord.isCreated()) {
getRelationshipTypeStore().freeBlockId((int) dynamicRecord.getId());
}
}
}
removeRelationshipTypeFromCache(record.getId());
}
for (NodeRecord record : nodeRecords.values()) {
if (record.isCreated()) {
getNodeStore().freeId(record.getId());
}
removeNodeFromCache(record.getId());
}
for (RelationshipRecord record : relRecords.values()) {
if (record.isCreated()) {
getRelationshipStore().freeId(record.getId());
}
removeRelationshipFromCache(record.getId());
}
for (PropertyIndexRecord record : propIndexRecords.values()) {
if (record.isCreated()) {
getPropertyStore().getIndexStore().freeId(record.getId());
for (DynamicRecord dynamicRecord : record.getKeyRecords()) {
if (dynamicRecord.isCreated()) {
getPropertyStore().getIndexStore().freeBlockId((int) dynamicRecord.getId());
}
}
}
}
for (PropertyRecord record : propertyRecords.values()) {
if (record.getNodeId() != -1) {
removeNodeFromCache(record.getNodeId());
} else if (record.getRelId() != -1) {
removeRelationshipFromCache(record.getRelId());
}
if (record.isCreated()) {
getPropertyStore().freeId(record.getId());
for (PropertyBlock block : record.getPropertyBlocks()) {
for (DynamicRecord dynamicRecord : block.getValueRecords()) {
if (dynamicRecord.isCreated()) {
if (dynamicRecord.getType() == PropertyType.STRING.intValue()) {
getPropertyStore().freeStringBlockId(dynamicRecord.getId());
} else if (dynamicRecord.getType() == PropertyType.ARRAY.intValue()) {
getPropertyStore().freeArrayBlockId(dynamicRecord.getId());
} else {
throw new InvalidRecordException("Unknown type on " + dynamicRecord);
}
}
}
}
}
}
} finally {
nodeRecords.clear();
propertyRecords.clear();
relRecords.clear();
relTypeRecords.clear();
propIndexRecords.clear();
nodeCommands.clear();
propCommands.clear();
propIndexCommands.clear();
relCommands.clear();
relTypeCommands.clear();
}
}
use of org.neo4j.kernel.impl.nioneo.store.PropertyBlock in project neo4j-mobile-android by neo4j-contrib.
the class ReadTransaction method loadPropertyValue.
@Override
public Object loadPropertyValue(PropertyData property) {
PropertyRecord propertyRecord = getPropertyStore().getRecord(property.getId());
PropertyBlock propertyBlock = propertyRecord.getPropertyBlock(property.getIndex());
if (propertyBlock.isLight()) {
getPropertyStore().makeHeavy(propertyBlock);
}
return propertyBlock.getType().getValue(propertyBlock, getPropertyStore());
}
use of org.neo4j.kernel.impl.nioneo.store.PropertyBlock in project neo4j-mobile-android by neo4j-contrib.
the class WriteTransaction method getAndDeletePropertyChain.
private ArrayMap<Integer, PropertyData> getAndDeletePropertyChain(long startingAt) {
ArrayMap<Integer, PropertyData> result = new ArrayMap<Integer, PropertyData>(9, false, true);
long nextProp = startingAt;
while (nextProp != Record.NO_NEXT_PROPERTY.intValue()) {
PropertyRecord propRecord = getPropertyRecord(nextProp, false, true);
if (!propRecord.isCreated() && propRecord.isChanged()) {
// Being here means a new value could be on disk. Re-read
propRecord = getPropertyStore().getRecord(propRecord.getId());
}
for (PropertyBlock block : propRecord.getPropertyBlocks()) {
if (block.isLight()) {
getPropertyStore().makeHeavy(block);
}
if (!block.isCreated() && !propRecord.isChanged()) {
result.put(block.getKeyIndexId(), block.newPropertyData(propRecord, propertyGetValueOrNull(block)));
}
// TODO: update count on property index record
for (DynamicRecord valueRecord : block.getValueRecords()) {
assert valueRecord.inUse();
valueRecord.setInUse(false);
propRecord.addDeletedRecord(valueRecord);
}
}
nextProp = propRecord.getNextProp();
propRecord.setInUse(false);
propRecord.setChanged();
// We do not remove them individually, but all together here
propRecord.getPropertyBlocks().clear();
}
return result;
}
use of org.neo4j.kernel.impl.nioneo.store.PropertyBlock 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);
}
}
}
Aggregations