use of org.neo4j.kernel.impl.store.record.PropertyRecord in project neo4j by neo4j.
the class DeleteDuplicateNodesStepTest method createNode.
private Ids createNode(DataImporter.Monitor monitor, NeoStores neoStores, int propertyCount, int labelCount) {
PropertyStore propertyStore = neoStores.getPropertyStore();
NodeStore nodeStore = neoStores.getNodeStore();
NodeRecord nodeRecord = nodeStore.newRecord();
nodeRecord.setId(nodeStore.nextId(NULL));
nodeRecord.setInUse(true);
NodeLabelsField.parseLabelsField(nodeRecord).put(labelIds(labelCount), nodeStore, nodeStore.getDynamicLabelStore(), NULL, INSTANCE);
PropertyRecord[] propertyRecords = createPropertyChain(nodeRecord, propertyCount, propertyStore);
if (propertyRecords.length > 0) {
nodeRecord.setNextProp(propertyRecords[0].getId());
}
nodeStore.updateRecord(nodeRecord, NULL);
monitor.nodesImported(1);
monitor.propertiesImported(propertyCount);
return new Ids(nodeRecord, propertyRecords);
}
use of org.neo4j.kernel.impl.store.record.PropertyRecord in project neo4j by neo4j.
the class RecordPropertyCursorTest method shouldAbortChainTraversalOnLikelyCycle.
@Test
void shouldAbortChainTraversalOnLikelyCycle() {
// given
// many enough to create multiple records in the chain
Value[] values = createValues(20, 20);
long firstProp = storeValuesAsPropertyChain(creator, owner, values);
// and a cycle on the second record
PropertyStore store = neoStores.getPropertyStore();
PropertyRecord firstRecord = store.getRecord(firstProp, store.newRecord(), RecordLoad.NORMAL, NULL);
long secondProp = firstRecord.getNextProp();
PropertyRecord secondRecord = store.getRecord(secondProp, store.newRecord(), RecordLoad.NORMAL, NULL);
secondRecord.setNextProp(firstProp);
store.updateRecord(secondRecord, NULL);
owner.setId(99);
// when
RecordPropertyCursor cursor = createCursor();
cursor.initNodeProperties(firstProp, owner.getId());
InconsistentDataReadException e = assertThrows(InconsistentDataReadException.class, () -> {
while (cursor.next()) {
// just keep going, it should eventually hit the cycle detection threshold
}
});
// then
assertEquals(format("Aborting property reading due to detected chain cycle, starting at property record id:%d from owner NODE:%d", firstProp, owner.getId()), e.getMessage());
}
use of org.neo4j.kernel.impl.store.record.PropertyRecord in project neo4j by neo4j.
the class PropertyDeleterTest method shouldHandlePropertyChainDeletionOnUnusedRecord.
@ValueSource(booleans = { true, false })
@ParameterizedTest
void shouldHandlePropertyChainDeletionOnUnusedRecord(boolean log) {
// given
startStore(log);
NodeStore nodeStore = neoStores.getNodeStore();
NodeRecord node = nodeStore.newRecord();
node.setId(nodeStore.nextId(NULL));
List<PropertyBlock> properties = new ArrayList<>();
for (int i = 0; i < 20; i++) {
properties.add(encodedValue(i, random.nextValue()));
}
DirectRecordAccessSet initialChanges = new DirectRecordAccessSet(neoStores, idGeneratorFactory, NULL);
long firstPropId = propertyCreator.createPropertyChain(node, properties.iterator(), initialChanges.getPropertyRecords());
node.setNextProp(firstPropId);
// should update all the changed records directly into the store
initialChanges.commit();
// create a cycle in the property chain A -> B
// ^---v
List<Value> valuesInTheFirstTwoRecords = new ArrayList<>();
PropertyRecord firstPropRecord = propertyStore.getRecord(firstPropId, propertyStore.newRecord(), RecordLoad.NORMAL, NULL);
readValuesFromPropertyRecord(firstPropRecord, valuesInTheFirstTwoRecords);
long secondPropId = firstPropRecord.getNextProp();
PropertyRecord secondPropRecord = propertyStore.getRecord(secondPropId, propertyStore.newRecord(), RecordLoad.NORMAL, NULL);
readValuesFromPropertyRecord(secondPropRecord, valuesInTheFirstTwoRecords);
long thirdPropId = secondPropRecord.getNextProp();
PropertyRecord thirdPropRecord = propertyStore.getRecord(thirdPropId, propertyStore.newRecord(), RecordLoad.NORMAL, NULL);
thirdPropRecord.setInUse(false);
propertyStore.updateRecord(thirdPropRecord, NULL);
// when
DirectRecordAccessSet changes = new DirectRecordAccessSet(neoStores, idGeneratorFactory, NULL);
deleter.deletePropertyChain(node, changes.getPropertyRecords());
changes.commit();
// then
assertEquals(Record.NO_NEXT_PROPERTY.longValue(), node.getNextProp());
assertFalse(propertyStore.getRecord(firstPropId, propertyStore.newRecord(), RecordLoad.CHECK, NULL).inUse());
assertFalse(propertyStore.getRecord(secondPropId, propertyStore.newRecord(), RecordLoad.CHECK, NULL).inUse());
assertLogContains("Deleted inconsistent property chain with unused record", log);
}
use of org.neo4j.kernel.impl.store.record.PropertyRecord in project neo4j by neo4j.
the class PropertyPhysicalToLogicalConverterTest method shouldConvertInlinedChangedProperty.
@Test
void shouldConvertInlinedChangedProperty() {
// GIVEN
int key = 10;
Value valueBefore = Values.of(12341);
Value valueAfter = Values.of(738);
PropertyRecord before = propertyRecord(property(key, valueBefore));
PropertyRecord after = propertyRecord(property(key, valueAfter));
// WHEN
EntityUpdates update = convert(none, none, change(before, after));
// THEN
EntityUpdates expected = EntityUpdates.forEntity(0, false).changed(key, valueBefore, valueAfter).build();
assertEquals(expected, update);
}
use of org.neo4j.kernel.impl.store.record.PropertyRecord in project neo4j by neo4j.
the class PropertyPhysicalToLogicalConverterTest method shouldConvertInlinedAddedProperty.
@Test
void shouldConvertInlinedAddedProperty() {
// GIVEN
int key = 10;
Value value = Values.of(12345);
PropertyRecord before = propertyRecord();
PropertyRecord after = propertyRecord(property(key, value));
// WHEN
assertThat(convert(none, none, change(before, after))).isEqualTo(EntityUpdates.forEntity(0, false).added(key, value).build());
}
Aggregations