use of org.neo4j.kernel.impl.nioneo.store.DynamicRecord 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.DynamicRecord 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.DynamicRecord in project graphdb by neo4j-attic.
the class DumpLogicalLog method readPropertyIndexCommand.
static XaCommand readPropertyIndexCommand(ReadableByteChannel byteChannel, ByteBuffer buffer) throws IOException {
// id+in_use(byte)+count(int)+key_blockId(int)+nr_key_records(int)
buffer.clear();
buffer.limit(17);
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);
}
PropertyIndexRecord record = new PropertyIndexRecord(id);
record.setInUse(inUse);
record.setPropertyCount(buffer.getInt());
record.setKeyBlockId(buffer.getInt());
int nrKeyRecords = buffer.getInt();
for (int i = 0; i < nrKeyRecords; i++) {
DynamicRecord dr = readDynamicRecord(byteChannel, buffer);
if (dr == null) {
return null;
}
record.addKeyRecord(dr);
}
return new Command(record);
}
use of org.neo4j.kernel.impl.nioneo.store.DynamicRecord in project graphdb by neo4j-attic.
the class Command method readDynamicRecord.
static DynamicRecord readDynamicRecord(ReadableByteChannel byteChannel, ByteBuffer buffer) throws IOException {
// id+type+in_use(byte)+prev_block(long)+nr_of_bytes(int)+next_block(long)
buffer.clear();
buffer.limit(13);
if (byteChannel.read(buffer) != buffer.limit()) {
return null;
}
buffer.flip();
long id = buffer.getLong();
int type = buffer.getInt();
byte inUseFlag = buffer.get();
boolean inUse = false;
if (inUseFlag == Record.IN_USE.byteValue()) {
inUse = true;
buffer.clear();
buffer.limit(20);
if (byteChannel.read(buffer) != buffer.limit()) {
return null;
}
buffer.flip();
} else if (inUseFlag != Record.NOT_IN_USE.byteValue()) {
throw new IOException("Illegal in use flag: " + inUseFlag);
}
DynamicRecord record = new DynamicRecord(id);
record.setInUse(inUse, type);
if (inUse) {
record.setPrevBlock(buffer.getLong());
int nrOfBytes = buffer.getInt();
record.setNextBlock(buffer.getLong());
buffer.clear();
buffer.limit(nrOfBytes);
if (byteChannel.read(buffer) != buffer.limit()) {
return null;
}
buffer.flip();
byte[] data = new byte[nrOfBytes];
buffer.get(data);
record.setData(data);
}
return record;
}
use of org.neo4j.kernel.impl.nioneo.store.DynamicRecord in project graphdb by neo4j-attic.
the class WriteTransaction method relChangeProperty.
void relChangeProperty(long relId, long propertyId, Object value) {
RelationshipRecord relRecord = getRelationshipRecord(relId);
if (relRecord == null) {
relRecord = getRelationshipStore().getRecord(relId);
}
if (!relRecord.inUse()) {
throw new IllegalStateException("Property change on relationship[" + relId + "] illegal since it has been deleted.");
}
PropertyRecord propertyRecord = getPropertyRecord(propertyId);
if (propertyRecord == null) {
propertyRecord = getPropertyStore().getRecord(propertyId);
addPropertyRecord(propertyRecord);
}
if (!propertyRecord.inUse()) {
throw new IllegalStateException("Unable to change property[" + propertyId + "] since it is deleted.");
}
propertyRecord.setRelId(relId);
if (propertyRecord.isLight()) {
getPropertyStore().makeHeavy(propertyRecord);
}
propertyRecord.setChanged();
if (propertyRecord.getType() == PropertyType.STRING) {
for (DynamicRecord record : propertyRecord.getValueRecords()) {
if (record.inUse()) {
record.setInUse(false, PropertyType.STRING.intValue());
}
}
} else if (propertyRecord.getType() == PropertyType.ARRAY) {
for (DynamicRecord record : propertyRecord.getValueRecords()) {
if (record.inUse()) {
record.setInUse(false, PropertyType.ARRAY.intValue());
}
}
}
getPropertyStore().encodeValue(propertyRecord, value);
addPropertyRecord(propertyRecord);
}
Aggregations