use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class DuplicatePropertyRemoverTest method removeProperty.
private void removeProperty(NodeRecord nodeRecord, int propertyKeyId) {
long nextProp = nodeRecord.getNextProp();
assertTrue(nextProp != Record.NO_NEXT_PROPERTY.intValue());
boolean found = false;
PropertyRecord propertyRecord = propertyStore.newRecord();
while (nextProp != Record.NO_NEXT_PROPERTY.intValue() && !found) {
propertyStore.getRecord(nextProp, propertyRecord, NORMAL);
PropertyBlock propertyBlock = propertyRecord.removePropertyBlock(propertyKeyId);
if (propertyBlock != null) {
found = true;
propertyStore.updateRecord(propertyRecord);
if (!propertyRecord.iterator().hasNext()) {
remover.fixUpPropertyLinksAroundUnusedRecord(nodeRecord, propertyRecord);
}
}
nextProp = propertyRecord.getNextProp();
}
assertTrue(found);
}
use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class DuplicatePropertyRemoverTest method assertPropertyRemoved.
private void assertPropertyRemoved(NodeRecord nodeRecord, int prevProBlockCount, int propertyKeyId) {
long nextPropId = nodeRecord.getNextProp();
int propBlockCount = 0;
while (nextPropId != Record.NO_NEXT_PROPERTY.intValue()) {
PropertyRecord propRecord = getRecord(propertyStore, nextPropId);
PropertyBlock propertyBlock = propRecord.getPropertyBlock(propertyKeyId);
assertNull(propertyBlock);
nextPropId = propRecord.getNextProp();
propBlockCount += Iterables.count((Iterable<PropertyBlock>) propRecord);
}
assertEquals(prevProBlockCount - 1, propBlockCount);
}
use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class Commands method createProperty.
public static PropertyCommand createProperty(long id, PropertyType type, int key, long... valueRecordIds) {
PropertyRecord record = new PropertyRecord(id);
record.setInUse(true);
record.setCreated();
PropertyBlock block = new PropertyBlock();
if (valueRecordIds.length == 0) {
PropertyStore.encodeValue(block, key, 123, /*value*/
null, null);
} else {
PropertyStore.setSingleBlockValue(block, key, type, valueRecordIds[0]);
block.setValueRecords(dynamicRecords(valueRecordIds));
}
record.addPropertyBlock(block);
return new PropertyCommand(new PropertyRecord(id), record);
}
use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class PropertyLoaderTest method newSingleIntPropertyBlock.
private static PropertyBlock newSingleIntPropertyBlock(int value) {
PropertyBlock block = new PropertyBlock();
PropertyStore.encodeValue(block, PROP_KEY_ID, value, null, null);
block.setKeyIndexId(PROP_KEY_ID);
return block;
}
use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class TransactionRecordStateTest method shouldWriteProperPropertyRecordsWhenOnlyChangingLinkage.
@Test
public void shouldWriteProperPropertyRecordsWhenOnlyChangingLinkage() throws Exception {
/* There was an issue where GIVEN:
*
* Legend: () = node, [] = property record
*
* ()-->[0:block{size:1}]
*
* WHEN adding a new property record in front of if, not changing any data in that record i.e:
*
* ()-->[1:block{size:4}]-->[0:block{size:1}]
*
* The state of property record 0 would be that it had loaded value records for that block,
* but those value records weren't heavy, so writing that record to the log would fail
* w/ an assertion data != null.
*/
// GIVEN
NeoStores neoStores = neoStoresRule.open();
TransactionRecordState recordState = newTransactionRecordState(neoStores);
int nodeId = 0;
recordState.nodeCreate(nodeId);
int index = 0;
// will require a block of size 1
recordState.nodeAddProperty(nodeId, index, string(70));
apply(neoStores, recordState);
// WHEN
recordState = newTransactionRecordState(neoStores);
int index2 = 1;
// will require a block of size 4
recordState.nodeAddProperty(nodeId, index2, string(40));
// THEN
PhysicalTransactionRepresentation representation = transactionRepresentationOf(recordState);
representation.accept(command -> ((Command) command).handle(new CommandVisitor.Adapter() {
@Override
public boolean visitPropertyCommand(PropertyCommand command) throws IOException {
verifyPropertyRecord(command.getBefore());
verifyPropertyRecord(command.getAfter());
return false;
}
private void verifyPropertyRecord(PropertyRecord record) {
if (record.getPrevProp() != Record.NO_NEXT_PROPERTY.intValue()) {
for (PropertyBlock block : record) {
assertTrue(block.isLight());
}
}
}
}));
}
Aggregations