use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.
the class PhysicalLogCommandReaderV3_0_2 method readRelationshipTypeTokenRecord.
private RelationshipTypeTokenRecord readRelationshipTypeTokenRecord(int id, ReadableChannel channel) throws IOException {
// in_use(byte)+type_blockId(int)+nr_type_records(int)
byte inUseFlag = channel.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);
}
RelationshipTypeTokenRecord record = new RelationshipTypeTokenRecord(id);
record.setInUse(inUse);
record.setNameId(channel.getInt());
int nrTypeRecords = channel.getInt();
for (int i = 0; i < nrTypeRecords; i++) {
DynamicRecord dr = readDynamicRecord(channel);
if (dr == null) {
return null;
}
record.addNameRecord(dr);
}
return record;
}
use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.
the class PhysicalLogCommandReaderV2_2 method readDynamicRecords.
private <T> int readDynamicRecords(ReadableChannel channel, T target, DynamicRecordAdder<T> adder) throws IOException {
int numberOfRecords = channel.getInt();
assert numberOfRecords >= 0;
while (numberOfRecords > 0) {
DynamicRecord read = readDynamicRecord(channel);
if (read == null) {
return -1;
}
adder.add(target, read);
numberOfRecords--;
}
return numberOfRecords;
}
use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.
the class PhysicalLogCommandReaderV2_2_10 method readDynamicRecord.
private DynamicRecord readDynamicRecord(ReadableChannel channel) throws IOException {
// id+type+in_use(byte)+nr_of_bytes(int)+next_block(long)
long id = channel.getLong();
assert id >= 0 && id <= (1L << 36) - 1 : id + " is not a valid dynamic record id";
int type = channel.getInt();
byte inUseFlag = channel.get();
boolean inUse = (inUseFlag & Record.IN_USE.byteValue()) != 0;
DynamicRecord record = new DynamicRecord(id);
record.setInUse(inUse, type);
if (inUse) {
record.setStartRecord((inUseFlag & Record.FIRST_IN_CHAIN.byteValue()) != 0);
int nrOfBytes = channel.getInt();
assert nrOfBytes >= 0 && nrOfBytes < ((1 << 24) - 1) : nrOfBytes + " is not valid for a number of bytes field of " + "a dynamic record";
long nextBlock = channel.getLong();
assert (nextBlock >= 0 && nextBlock <= (1L << 36 - 1)) || (nextBlock == Record.NO_NEXT_BLOCK.intValue()) : nextBlock + " is not valid for a next record field of " + "a dynamic record";
record.setNextBlock(nextBlock);
byte[] data = new byte[nrOfBytes];
channel.get(data, nrOfBytes);
record.setData(data);
}
return record;
}
use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.
the class PhysicalLogCommandReaderV2_2_10 method readPropertyRecord.
private PropertyRecord readPropertyRecord(long id, ReadableChannel channel) throws IOException {
// in_use(byte)+type(int)+key_indexId(int)+prop_blockId(long)+
// prev_prop_id(long)+next_prop_id(long)
PropertyRecord record = new PropertyRecord(id);
// 1
byte inUseFlag = channel.get();
// 8
long nextProp = channel.getLong();
// 8
long prevProp = channel.getLong();
record.setNextProp(nextProp);
record.setPrevProp(prevProp);
boolean inUse = false;
if ((inUseFlag & Record.IN_USE.byteValue()) == Record.IN_USE.byteValue()) {
inUse = true;
}
boolean nodeProperty = true;
if ((inUseFlag & Record.REL_PROPERTY.byteValue()) == Record.REL_PROPERTY.byteValue()) {
nodeProperty = false;
}
// 8
long primitiveId = channel.getLong();
if (primitiveId != -1 && nodeProperty) {
record.setNodeId(primitiveId);
} else if (primitiveId != -1) {
record.setRelId(primitiveId);
}
int nrPropBlocks = channel.get();
assert nrPropBlocks >= 0;
if (nrPropBlocks > 0) {
record.setInUse(true);
}
while (nrPropBlocks-- > 0) {
PropertyBlock block = readPropertyBlock(channel);
if (block == null) {
return null;
}
record.addPropertyBlock(block);
}
int deletedRecords = readDynamicRecords(channel, record, PROPERTY_DELETED_DYNAMIC_RECORD_ADDER);
if (deletedRecords == -1) {
return null;
}
assert deletedRecords >= 0;
while (deletedRecords-- > 0) {
DynamicRecord read = readDynamicRecord(channel);
if (read == null) {
return null;
}
record.addDeletedRecord(read);
}
if ((inUse && !record.inUse()) || (!inUse && record.inUse())) {
throw new IllegalStateException("Weird, inUse was read in as " + inUse + " but the record is " + record);
}
return record;
}
use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.
the class PhysicalLogCommandReaderV2_2_10 method readDynamicRecords.
private <T> int readDynamicRecords(ReadableChannel channel, T target, DynamicRecordAdder<T> adder) throws IOException {
int numberOfRecords = channel.getInt();
assert numberOfRecords >= 0;
while (numberOfRecords > 0) {
DynamicRecord read = readDynamicRecord(channel);
if (read == null) {
return -1;
}
adder.add(target, read);
numberOfRecords--;
}
return numberOfRecords;
}
Aggregations