use of org.neo4j.kernel.impl.nioneo.store.RelationshipTypeRecord in project graphdb by neo4j-attic.
the class BatchInserterImpl method createNewRelationshipType.
private int createNewRelationshipType(String name) {
RelationshipTypeStore typeStore = getRelationshipTypeStore();
int id = (int) typeStore.nextId();
RelationshipTypeRecord record = new RelationshipTypeRecord(id);
record.setInUse(true);
record.setCreated();
int typeBlockId = (int) typeStore.nextBlockId();
record.setTypeBlock(typeBlockId);
int length = name.length();
char[] chars = new char[length];
name.getChars(0, length, chars, 0);
Collection<DynamicRecord> typeRecords = typeStore.allocateTypeNameRecords(typeBlockId, chars);
for (DynamicRecord typeRecord : typeRecords) {
record.addTypeRecord(typeRecord);
}
typeStore.updateRecord(record);
typeHolder.addRelationshipType(name, id);
return id;
}
use of org.neo4j.kernel.impl.nioneo.store.RelationshipTypeRecord in project neo4j-mobile-android by neo4j-contrib.
the class BatchInserterImpl method createNewRelationshipType.
private int createNewRelationshipType(String name) {
RelationshipTypeStore typeStore = getRelationshipTypeStore();
int id = (int) typeStore.nextId();
RelationshipTypeRecord record = new RelationshipTypeRecord(id);
record.setInUse(true);
record.setCreated();
int typeBlockId = (int) typeStore.nextBlockId();
record.setTypeBlock(typeBlockId);
Collection<DynamicRecord> typeRecords = typeStore.allocateTypeNameRecords(typeBlockId, encodeString(name));
for (DynamicRecord typeRecord : typeRecords) {
record.addTypeRecord(typeRecord);
}
typeStore.updateRecord(record);
typeHolder.addRelationshipType(name, id);
return id;
}
use of org.neo4j.kernel.impl.nioneo.store.RelationshipTypeRecord in project neo4j-mobile-android by neo4j-contrib.
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.RelationshipTypeRecord in project neo4j-mobile-android by neo4j-contrib.
the class LegacyRelationshipTypeStoreReader method readRelationshipTypes.
public Iterable<RelationshipTypeRecord> readRelationshipTypes() throws IOException {
FileChannel fileChannel = new RandomAccessFile(fileName, "r").getChannel();
int recordLength = 5;
int endHeaderSize = UTF8.encode(FROM_VERSION).length;
long recordCount = (fileChannel.size() - endHeaderSize) / recordLength;
LinkedList<RelationshipTypeRecord> records = new LinkedList<RelationshipTypeRecord>();
ByteBuffer buffer = ByteBuffer.allocateDirect(recordLength);
for (int id = 0; id <= recordCount; id++) {
buffer.position(0);
fileChannel.read(buffer);
buffer.flip();
long inUseByte = buffer.get();
boolean inUse = inUseByte == Record.IN_USE.byteValue();
if (inUse) {
RelationshipTypeRecord record = new RelationshipTypeRecord(id);
record.setInUse(inUse);
record.setTypeBlock(buffer.getInt());
records.add(record);
}
}
fileChannel.close();
return records;
}
use of org.neo4j.kernel.impl.nioneo.store.RelationshipTypeRecord in project graphdb by neo4j-attic.
the class DumpLogicalLog method readRelationshipTypeCommand.
static XaCommand readRelationshipTypeCommand(ReadableByteChannel byteChannel, ByteBuffer buffer) throws IOException {
// id+in_use(byte)+type_blockId(int)+nr_type_records(int)
buffer.clear();
buffer.limit(13);
if (byteChannel.read(buffer) != buffer.limit()) {
return null;
}
buffer.flip();
int id = buffer.getInt();
byte inUseFlag = buffer.get();
boolean inUse = false;
if ((inUseFlag & Record.IN_USE.byteValue()) == Record.IN_USE.byteValue()) {
inUse = true;
} else if (inUseFlag != Record.NOT_IN_USE.byteValue()) {
throw new IOException("Illegal in use flag: " + inUseFlag);
}
RelationshipTypeRecord record = new RelationshipTypeRecord(id);
record.setInUse(inUse);
record.setTypeBlock(buffer.getInt());
int nrTypeRecords = buffer.getInt();
for (int i = 0; i < nrTypeRecords; i++) {
DynamicRecord dr = readDynamicRecord(byteChannel, buffer);
if (dr == null) {
return null;
}
record.addTypeRecord(dr);
}
return new Command(record);
}
Aggregations