use of org.neo4j.kernel.impl.store.record.PropertyRecord 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.PropertyRecord 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.PropertyRecord in project neo4j by neo4j.
the class PropertyDeleter method unlinkPropertyRecord.
private <P extends PrimitiveRecord> void unlinkPropertyRecord(PropertyRecord propRecord, RecordAccess<Long, PropertyRecord, PrimitiveRecord> propertyRecords, RecordProxy<Long, P, Void> primitiveRecordChange) {
P primitive = primitiveRecordChange.forReadingLinkage();
assert traverser.assertPropertyChain(primitive, propertyRecords);
assert propRecord.size() == 0;
long prevProp = propRecord.getPrevProp();
long nextProp = propRecord.getNextProp();
if (primitive.getNextProp() == propRecord.getId()) {
assert propRecord.getPrevProp() == Record.NO_PREVIOUS_PROPERTY.intValue() : propRecord + " for " + primitive;
primitiveRecordChange.forChangingLinkage().setNextProp(nextProp);
}
if (prevProp != Record.NO_PREVIOUS_PROPERTY.intValue()) {
PropertyRecord prevPropRecord = propertyRecords.getOrLoad(prevProp, primitive).forChangingLinkage();
assert prevPropRecord.inUse() : prevPropRecord + "->" + propRecord + " for " + primitive;
prevPropRecord.setNextProp(nextProp);
prevPropRecord.setChanged(primitive);
}
if (nextProp != Record.NO_NEXT_PROPERTY.intValue()) {
PropertyRecord nextPropRecord = propertyRecords.getOrLoad(nextProp, primitive).forChangingLinkage();
assert nextPropRecord.inUse() : propRecord + "->" + nextPropRecord + " for " + primitive;
nextPropRecord.setPrevProp(prevProp);
nextPropRecord.setChanged(primitive);
}
propRecord.setInUse(false);
/*
* The following two are not needed - the above line does all the work (PropertyStore
* does not write out the prev/next for !inUse records). It is nice to set this
* however to check for consistency when assertPropertyChain().
*/
propRecord.setPrevProp(Record.NO_PREVIOUS_PROPERTY.intValue());
propRecord.setNextProp(Record.NO_NEXT_PROPERTY.intValue());
propRecord.setChanged(primitive);
assert traverser.assertPropertyChain(primitive, propertyRecords);
}
use of org.neo4j.kernel.impl.store.record.PropertyRecord in project neo4j by neo4j.
the class PropertyTraverser method getPropertyChain.
public void getPropertyChain(long nextProp, RecordAccess<Long, PropertyRecord, PrimitiveRecord> propertyRecords, Listener<PropertyBlock> collector) {
while (nextProp != Record.NO_NEXT_PROPERTY.intValue()) {
PropertyRecord propRecord = propertyRecords.getOrLoad(nextProp, null).forReadingData();
for (PropertyBlock propBlock : propRecord) {
collector.receive(propBlock);
}
nextProp = propRecord.getNextProp();
}
}
use of org.neo4j.kernel.impl.store.record.PropertyRecord 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;
}
Aggregations