use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.
the class PropertyCreator method removeProperty.
private void removeProperty(PrimitiveRecord primitive, PropertyRecord host, PropertyBlock block) {
host.removePropertyBlock(block.getKeyIndexId());
host.setChanged(primitive);
for (DynamicRecord record : block.getValueRecords()) {
assert record.inUse();
record.setInUse(false, block.getType().intValue());
host.addDeletedRecord(record);
}
}
use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.
the class PropertyDeleter method removeProperty.
public <P extends PrimitiveRecord> void removeProperty(RecordProxy<Long, P, Void> primitiveProxy, int propertyKey, RecordAccess<Long, PropertyRecord, PrimitiveRecord> propertyRecords) {
PrimitiveRecord primitive = primitiveProxy.forReadingData();
// propertyData.getId();
long propertyId = traverser.findPropertyRecordContaining(primitive, propertyKey, propertyRecords, true);
RecordProxy<Long, PropertyRecord, PrimitiveRecord> recordChange = propertyRecords.getOrLoad(propertyId, primitive);
PropertyRecord propRecord = recordChange.forChangingData();
if (!propRecord.inUse()) {
throw new IllegalStateException("Unable to delete property[" + propertyId + "] since it is already deleted.");
}
PropertyBlock block = propRecord.removePropertyBlock(propertyKey);
if (block == null) {
throw new IllegalStateException("Property with index[" + propertyKey + "] is not present in property[" + propertyId + "]");
}
for (DynamicRecord valueRecord : block.getValueRecords()) {
assert valueRecord.inUse();
valueRecord.setInUse(false, block.getType().intValue());
propRecord.addDeletedRecord(valueRecord);
}
if (propRecord.size() > 0) {
/*
* There are remaining blocks in the record. We do not unlink yet.
*/
propRecord.setChanged(primitive);
assert traverser.assertPropertyChain(primitive, propertyRecords);
} else {
unlinkPropertyRecord(propRecord, propertyRecords, primitiveProxy);
}
}
use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.
the class PropertyDeleter method deletePropertyChain.
public void deletePropertyChain(PrimitiveRecord primitive, RecordAccess<Long, PropertyRecord, PrimitiveRecord> propertyRecords) {
long nextProp = primitive.getNextProp();
while (nextProp != Record.NO_NEXT_PROPERTY.intValue()) {
RecordProxy<Long, PropertyRecord, PrimitiveRecord> propertyChange = propertyRecords.getOrLoad(nextProp, primitive);
// TODO forChanging/forReading piggy-backing
PropertyRecord propRecord = propertyChange.forChangingData();
for (PropertyBlock block : propRecord) {
for (DynamicRecord valueRecord : block.getValueRecords()) {
assert valueRecord.inUse();
valueRecord.setInUse(false);
propRecord.addDeletedRecord(valueRecord);
}
}
nextProp = propRecord.getNextProp();
propRecord.setInUse(false);
propRecord.setChanged(primitive);
// We do not remove them individually, but all together here
propRecord.clearPropertyBlocks();
}
primitive.setNextProp(Record.NO_NEXT_PROPERTY.intValue());
}
use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.
the class PhysicalLogCommandReaderV3_0 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 PhysicalLogCommandReaderV3_0_2 method visitSchemaRuleCommand.
private Command visitSchemaRuleCommand(ReadableChannel channel) throws IOException {
Collection<DynamicRecord> recordsBefore = new ArrayList<>();
readDynamicRecords(channel, recordsBefore, COLLECTION_DYNAMIC_RECORD_ADDER);
Collection<DynamicRecord> recordsAfter = new ArrayList<>();
readDynamicRecords(channel, recordsAfter, COLLECTION_DYNAMIC_RECORD_ADDER);
byte isCreated = channel.get();
if (1 == isCreated) {
for (DynamicRecord record : recordsAfter) {
record.setCreated();
}
}
SchemaRule rule = Iterables.first(recordsAfter).inUse() ? readSchemaRule(recordsAfter) : readSchemaRule(recordsBefore);
return new Command.SchemaRuleCommand(recordsBefore, recordsAfter, rule);
}
Aggregations