use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.
the class PhysicalLogCommandReaderV3_0_2 method readLabelTokenRecord.
private LabelTokenRecord readLabelTokenRecord(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);
}
LabelTokenRecord record = new LabelTokenRecord(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 PhysicalLogCommandReaderV3_0_2 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 flags = channel.get();
boolean inUse = bitFlag(flags, Record.IN_USE.byteValue());
boolean nodeProperty = !bitFlag(flags, Record.REL_PROPERTY.byteValue());
boolean requireSecondaryUnit = bitFlag(flags, Record.REQUIRE_SECONDARY_UNIT);
boolean hasSecondaryUnit = bitFlag(flags, Record.HAS_SECONDARY_UNIT);
record.setRequiresSecondaryUnit(requireSecondaryUnit);
// 8
long nextProp = channel.getLong();
// 8
long prevProp = channel.getLong();
record.setNextProp(nextProp);
record.setPrevProp(prevProp);
// 8
long primitiveId = channel.getLong();
if (primitiveId != -1 && nodeProperty) {
record.setNodeId(primitiveId);
} else if (primitiveId != -1) {
record.setRelId(primitiveId);
}
if (hasSecondaryUnit) {
record.setSecondaryUnitId(channel.getLong());
}
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 PhysicalLogCommandReaderV3_0_2 method readNodeRecord.
private NodeRecord readNodeRecord(long id, ReadableChannel channel) throws IOException {
byte flags = channel.get();
boolean inUse = bitFlag(flags, Record.IN_USE.byteValue());
boolean requiresSecondaryUnit = bitFlag(flags, Record.REQUIRE_SECONDARY_UNIT);
boolean hasSecondaryUnit = bitFlag(flags, Record.HAS_SECONDARY_UNIT);
NodeRecord record;
Collection<DynamicRecord> dynamicLabelRecords = new ArrayList<>();
long labelField = Record.NO_LABELS_FIELD.intValue();
if (inUse) {
boolean dense = channel.get() == 1;
record = new NodeRecord(id, dense, channel.getLong(), channel.getLong());
// labels
labelField = channel.getLong();
record.setRequiresSecondaryUnit(requiresSecondaryUnit);
if (hasSecondaryUnit) {
record.setSecondaryUnitId(channel.getLong());
}
} else {
record = new NodeRecord(id);
}
readDynamicRecords(channel, dynamicLabelRecords, COLLECTION_DYNAMIC_RECORD_ADDER);
record.setLabelField(labelField, dynamicLabelRecords);
record.setInUse(inUse);
return record;
}
use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.
the class PhysicalLogCommandReaderV3_0_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 PhysicalLogCommandReaderV3_0_2 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;
}
Aggregations