use of org.neo4j.kernel.impl.store.record.PropertyRecord in project neo4j by neo4j.
the class FullCheckIntegrationTest method shouldReportPropertyInconsistencies.
@Test
void shouldReportPropertyInconsistencies() throws Exception {
// given
fixture.apply(new GraphStoreFixture.Transaction() {
@Override
protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
NodeRecord node = new NodeRecord(next.node());
PropertyRecord property = new PropertyRecord(next.property());
node.setNextProp(property.getId());
// Mess up the prev/next pointers a bit
property.setNextProp(1_000);
PropertyBlock block = new PropertyBlock();
block.setSingleBlock(next.propertyKey() | (((long) PropertyType.INT.intValue()) << 24) | (666L << 28));
property.addPropertyBlock(block);
tx.create(node);
tx.create(property);
}
});
// when
ConsistencySummaryStatistics stats = check();
// then
on(stats).verify(RecordType.PROPERTY, 2).verify(RecordType.NODE, 1).andThatsAllFolks();
}
use of org.neo4j.kernel.impl.store.record.PropertyRecord in project neo4j by neo4j.
the class FullCheckIntegrationTest method shouldReportCircularPropertyRecordChain.
private void shouldReportCircularPropertyRecordChain(RecordType expectedInconsistentRecordType, EntityCreator entityCreator) throws Exception {
// Given
fixture.apply(new GraphStoreFixture.Transaction() {
@Override
protected void transactionData(TransactionDataBuilder tx, IdGenerator next) {
// Create property chain A --> B --> C --> D
// ↑ │
// └───────────┘
long a = next.property();
long b = next.property();
long c = next.property();
long d = next.property();
tx.create(propertyRecordWithSingleIntProperty(a, next.propertyKey(), -1, b));
tx.create(propertyRecordWithSingleIntProperty(b, next.propertyKey(), a, c));
tx.create(propertyRecordWithSingleIntProperty(c, next.propertyKey(), b, d));
tx.create(propertyRecordWithSingleIntProperty(d, next.propertyKey(), c, b));
entityCreator.create(tx, next, a);
}
private PropertyRecord propertyRecordWithSingleIntProperty(long id, int propertyKeyId, long prev, long next) {
PropertyRecord record = new PropertyRecord(id).initialize(true, prev, next);
PropertyBlock block = new PropertyBlock();
PropertyStore.encodeValue(block, propertyKeyId, Values.intValue(10), null, null, false, NULL, INSTANCE);
record.addPropertyBlock(block);
return record;
}
});
// When
ConsistencySummaryStatistics stats = check();
// Then report will be filed on Node inconsistent with the Property completing the circle
on(stats).verify(expectedInconsistentRecordType, 1);
}
use of org.neo4j.kernel.impl.store.record.PropertyRecord in project neo4j by neo4j.
the class FullCheckIntegrationTest method shouldDetectInvalidUseOfInternalPropertyKeyTokens.
@Test
void shouldDetectInvalidUseOfInternalPropertyKeyTokens() throws Exception {
// given
fixture.apply(new GraphStoreFixture.Transaction() {
@Override
protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
int propertyKey = next.propertyKey();
tx.propertyKey(propertyKey, "FOO", true);
long nextProp = next.property();
PropertyRecord property = new PropertyRecord(nextProp).initialize(true, NO_PREVIOUS_PROPERTY.longValue(), NO_NEXT_PROPERTY.longValue());
PropertyBlock block = new PropertyBlock();
block.setSingleBlock(propertyKey | (((long) PropertyType.INT.intValue()) << 24) | (666L << 28));
property.addPropertyBlock(block);
tx.create(property);
tx.create(new NodeRecord(next.node()).initialize(true, nextProp, false, NO_NEXT_RELATIONSHIP.longValue(), NO_LABELS_FIELD.longValue()));
}
});
// when
ConsistencySummaryStatistics stats = check();
// then
assertFalse(stats.isConsistent());
on(stats).verify(RecordType.PROPERTY, 1).andThatsAllFolks();
}
use of org.neo4j.kernel.impl.store.record.PropertyRecord in project neo4j by neo4j.
the class DeleteDuplicateNodesStepTest method shouldDeleteEverythingAboutTheDuplicatedNodes.
@RepeatedTest(10)
void shouldDeleteEverythingAboutTheDuplicatedNodes() throws Exception {
// given
Ids[] ids = new Ids[9];
DataImporter.Monitor monitor = new DataImporter.Monitor();
// node with many properties and many labels
ids[0] = createNode(monitor, neoStores, 10, 10);
// node with many properties and few labels
ids[1] = createNode(monitor, neoStores, 10, 1);
// node with many properties and no labels
ids[2] = createNode(monitor, neoStores, 10, 0);
// node with few properties and many labels
ids[3] = createNode(monitor, neoStores, 1, 10);
// node with few properties and few labels
ids[4] = createNode(monitor, neoStores, 1, 1);
// node with few properties and no labels
ids[5] = createNode(monitor, neoStores, 1, 0);
// node with no properties and many labels
ids[6] = createNode(monitor, neoStores, 0, 10);
// node with no properties and few labels
ids[7] = createNode(monitor, neoStores, 0, 1);
// node with no properties and no labels
ids[8] = createNode(monitor, neoStores, 0, 0);
// when
long[] duplicateNodeIds = randomNodes(ids);
SimpleStageControl control = new SimpleStageControl();
try (DeleteDuplicateNodesStep step = new DeleteDuplicateNodesStep(control, Configuration.DEFAULT, iterator(duplicateNodeIds), neoStores.getNodeStore(), neoStores.getPropertyStore(), monitor, PageCacheTracer.NULL)) {
control.steps(step);
startAndAwaitCompletionOf(step);
}
control.assertHealthy();
// then
int expectedNodes = 0;
int expectedProperties = 0;
for (Ids entity : ids) {
boolean expectedToBeInUse = !ArrayUtils.contains(duplicateNodeIds, entity.node.getId());
int stride = expectedToBeInUse ? 1 : 0;
expectedNodes += stride;
// Verify node record
assertEquals(expectedToBeInUse, neoStores.getNodeStore().isInUse(entity.node.getId(), NULL));
// Verify label records
for (DynamicRecord labelRecord : entity.node.getDynamicLabelRecords()) {
assertEquals(expectedToBeInUse, neoStores.getNodeStore().getDynamicLabelStore().isInUse(labelRecord.getId(), NULL));
}
// Verify property records
for (PropertyRecord propertyRecord : entity.properties) {
assertEquals(expectedToBeInUse, neoStores.getPropertyStore().isInUse(propertyRecord.getId(), NULL));
for (PropertyBlock property : propertyRecord) {
// Verify property dynamic value records
for (DynamicRecord valueRecord : property.getValueRecords()) {
AbstractDynamicStore valueStore;
switch(property.getType()) {
case STRING:
valueStore = neoStores.getPropertyStore().getStringStore();
break;
case ARRAY:
valueStore = neoStores.getPropertyStore().getArrayStore();
break;
default:
throw new IllegalArgumentException(propertyRecord + " " + property);
}
assertEquals(expectedToBeInUse, valueStore.isInUse(valueRecord.getId(), NULL));
}
expectedProperties += stride;
}
}
}
assertEquals(expectedNodes, monitor.nodesImported());
assertEquals(expectedProperties, monitor.propertiesImported());
}
use of org.neo4j.kernel.impl.store.record.PropertyRecord in project neo4j by neo4j.
the class DeleteDuplicateNodesStepTest method createPropertyChain.
// A slight duplication of PropertyCreator logic, please try and remove in favor of that utility later on
private PropertyRecord[] createPropertyChain(NodeRecord nodeRecord, int numberOfProperties, PropertyStore propertyStore) {
List<PropertyRecord> records = new ArrayList<>();
PropertyRecord current = null;
int space = PropertyType.getPayloadSizeLongs();
for (int i = 0; i < numberOfProperties; i++) {
PropertyBlock block = new PropertyBlock();
propertyStore.encodeValue(block, i, random.nextValue(), NULL, INSTANCE);
if (current == null || block.getValueBlocks().length > space) {
PropertyRecord next = propertyStore.newRecord();
nodeRecord.setIdTo(next);
next.setId(propertyStore.nextId(NULL));
if (current != null) {
next.setPrevProp(current.getId());
current.setNextProp(next.getId());
}
next.setInUse(true);
current = next;
space = PropertyType.getPayloadSizeLongs();
records.add(current);
}
current.addPropertyBlock(block);
space -= block.getValueBlocks().length;
}
records.forEach(record -> propertyStore.updateRecord(record, NULL));
return records.toArray(new PropertyRecord[0]);
}
Aggregations