use of org.neo4j.kernel.impl.nioneo.store.PropertyIndexRecord in project graphdb by neo4j-attic.
the class BatchInserterImpl method createNewPropertyIndex.
private int createNewPropertyIndex(String stringKey) {
PropertyIndexStore idxStore = getPropertyIndexStore();
int keyId = (int) idxStore.nextId();
PropertyIndexRecord record = new PropertyIndexRecord(keyId);
record.setInUse(true);
record.setCreated();
int keyBlockId = idxStore.nextKeyBlockId();
record.setKeyBlockId(keyBlockId);
int length = stringKey.length();
char[] chars = new char[length];
stringKey.getChars(0, length, chars, 0);
Collection<DynamicRecord> keyRecords = idxStore.allocateKeyRecords(keyBlockId, chars);
for (DynamicRecord keyRecord : keyRecords) {
record.addKeyRecord(keyRecord);
}
idxStore.updateRecord(record);
indexHolder.addPropertyIndex(stringKey, keyId);
return keyId;
}
use of org.neo4j.kernel.impl.nioneo.store.PropertyIndexRecord in project graphdb by neo4j-attic.
the class ReadTransaction method getPropertyIndex.
String getPropertyIndex(int id) {
PropertyIndexStore indexStore = getPropertyStore().getIndexStore();
PropertyIndexRecord index = indexStore.getRecord(id);
if (index.isLight()) {
indexStore.makeHeavy(index);
}
return indexStore.getStringFor(index);
}
use of org.neo4j.kernel.impl.nioneo.store.PropertyIndexRecord in project graphdb by neo4j-attic.
the class WriteTransaction method doPrepare.
@Override
protected void doPrepare() throws XAException {
if (committed) {
throw new XAException("Cannot prepare committed transaction[" + getIdentifier() + "]");
}
if (prepared) {
throw new XAException("Cannot prepare prepared transaction[" + getIdentifier() + "]");
}
// generate records then write to logical log via addCommand method
prepared = true;
for (RelationshipTypeRecord record : relTypeRecords.values()) {
Command.RelationshipTypeCommand command = new Command.RelationshipTypeCommand(neoStore.getRelationshipTypeStore(), record);
relTypeCommands.add(command);
addCommand(command);
}
for (NodeRecord record : nodeRecords.values()) {
if (!record.inUse() && record.getNextRel() != Record.NO_NEXT_RELATIONSHIP.intValue()) {
throw new InvalidRecordException("Node record " + record + " still has relationships");
}
Command.NodeCommand command = new Command.NodeCommand(neoStore.getNodeStore(), record);
nodeCommands.add(command);
if (!record.inUse()) {
removeNodeFromCache(record.getId());
}
addCommand(command);
}
for (RelationshipRecord record : relRecords.values()) {
Command.RelationshipCommand command = new Command.RelationshipCommand(neoStore.getRelationshipStore(), record);
relCommands.add(command);
if (!record.inUse()) {
removeRelationshipFromCache(record.getId());
}
addCommand(command);
}
for (PropertyIndexRecord record : propIndexRecords.values()) {
Command.PropertyIndexCommand command = new Command.PropertyIndexCommand(neoStore.getPropertyStore().getIndexStore(), record);
propIndexCommands.add(command);
addCommand(command);
}
for (PropertyRecord record : propertyRecords.values()) {
Command.PropertyCommand command = new Command.PropertyCommand(neoStore.getPropertyStore(), record);
propCommands.add(command);
addCommand(command);
}
}
use of org.neo4j.kernel.impl.nioneo.store.PropertyIndexRecord in project graphdb by neo4j-attic.
the class WriteTransaction method doRollback.
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 (DynamicRecord dynamicRecord : record.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();
if (!isRecovered()) {
lockReleaser.rollback();
}
}
}
Aggregations