use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class DuplicatePropertyTest method shouldReportDuplicatePropertyIndexesAcrossRecordsInPropertyChainForNode.
@Test
public void shouldReportDuplicatePropertyIndexesAcrossRecordsInPropertyChainForNode() throws Exception {
// given
ChainCheck check = new ChainCheck();
RecordAccessStub records = new RecordAccessStub();
RelationshipRecord master = records.add(inUse(new RelationshipRecord(1, 2, 3, 4)));
master.setNextProp(1);
PropertyRecord firstRecord = inUse(new PropertyRecord(1));
firstRecord.setNextProp(12);
PropertyBlock firstBlock = new PropertyBlock();
firstBlock.setSingleBlock(1);
firstBlock.setKeyIndexId(1);
PropertyBlock secondBlock = new PropertyBlock();
secondBlock.setSingleBlock(1);
secondBlock.setKeyIndexId(2);
PropertyRecord secondRecord = inUse(new PropertyRecord(12));
secondRecord.setPrevProp(1);
PropertyBlock thirdBlock = new PropertyBlock();
thirdBlock.setSingleBlock(1);
thirdBlock.setKeyIndexId(4);
PropertyBlock fourthBlock = new PropertyBlock();
fourthBlock.setSingleBlock(1);
fourthBlock.setKeyIndexId(1);
firstRecord.addPropertyBlock(firstBlock);
firstRecord.addPropertyBlock(secondBlock);
secondRecord.addPropertyBlock(thirdBlock);
secondRecord.addPropertyBlock(fourthBlock);
records.add(firstRecord);
records.add(secondRecord);
// when
ConsistencyReport.RelationshipConsistencyReport report = mock(ConsistencyReport.RelationshipConsistencyReport.class);
CheckerEngine<RelationshipRecord, ConsistencyReport.RelationshipConsistencyReport> checkEngine = records.engine(master, report);
check.checkReference(master, firstRecord, checkEngine, records);
records.checkDeferred();
// then
verify(report).propertyKeyNotUniqueInChain();
}
use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class DuplicatePropertyTest method shouldNotReportAnythingForConsistentChains.
@Test
public void shouldNotReportAnythingForConsistentChains() throws Exception {
// given
ChainCheck check = new ChainCheck();
RecordAccessStub records = new RecordAccessStub();
RelationshipRecord master = records.add(inUse(new RelationshipRecord(1, 2, 3, 4)));
master.setNextProp(1);
PropertyRecord firstRecord = inUse(new PropertyRecord(1));
firstRecord.setNextProp(12);
PropertyBlock firstBlock = new PropertyBlock();
firstBlock.setSingleBlock(1);
firstBlock.setKeyIndexId(1);
PropertyBlock secondBlock = new PropertyBlock();
secondBlock.setSingleBlock(1);
secondBlock.setKeyIndexId(2);
PropertyRecord secondRecord = inUse(new PropertyRecord(12));
secondRecord.setPrevProp(1);
PropertyBlock thirdBlock = new PropertyBlock();
thirdBlock.setSingleBlock(1);
thirdBlock.setKeyIndexId(4);
PropertyBlock fourthBlock = new PropertyBlock();
fourthBlock.setSingleBlock(11);
fourthBlock.setKeyIndexId(11);
firstRecord.addPropertyBlock(firstBlock);
firstRecord.addPropertyBlock(secondBlock);
secondRecord.addPropertyBlock(thirdBlock);
secondRecord.addPropertyBlock(fourthBlock);
records.add(firstRecord);
records.add(secondRecord);
// when
ConsistencyReport.RelationshipConsistencyReport report = mock(ConsistencyReport.RelationshipConsistencyReport.class);
CheckerEngine<RelationshipRecord, ConsistencyReport.RelationshipConsistencyReport> checkEngine = records.engine(master, report);
check.checkReference(master, firstRecord, checkEngine, records);
records.checkDeferred();
// then
verifyZeroInteractions(report);
}
use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class FullCheckIntegrationTest method shouldReportMissingMandatoryNodeProperty.
@Test
public void shouldReportMissingMandatoryNodeProperty() throws Exception {
// given
fixture.apply(new GraphStoreFixture.Transaction() {
@Override
protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
// structurally correct, but does not have the 'mandatory' property with the 'draconian' label
NodeRecord node = new NodeRecord(next.node(), false, -1, next.property());
node.setInUse(true);
node.setLabelField(inlinedLabelsLongRepresentation(draconian), Collections.<DynamicRecord>emptySet());
PropertyRecord property = new PropertyRecord(node.getNextProp(), node);
property.setInUse(true);
PropertyBlock block = new PropertyBlock();
block.setSingleBlock(key | (((long) PropertyType.INT.intValue()) << 24) | (1337L << 28));
property.addPropertyBlock(block);
tx.create(node);
tx.create(property);
}
});
createNodePropertyExistenceConstraint(draconian, mandatory);
// when
ConsistencySummaryStatistics stats = check();
// then
on(stats).verify(RecordType.NODE, 1).andThatsAllFolks();
}
use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class FullCheckIntegrationTest method shouldReportArrayPropertyInconsistencies.
@Test
public void shouldReportArrayPropertyInconsistencies() throws Exception {
// given
fixture.apply(new GraphStoreFixture.Transaction() {
@Override
protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
DynamicRecord array = new DynamicRecord(next.arrayProperty());
array.setInUse(true);
array.setCreated();
array.setType(ARRAY.intValue());
array.setNextBlock(next.arrayProperty());
array.setData(UTF8.encode("hello world"));
PropertyBlock block = new PropertyBlock();
block.setSingleBlock((((long) ARRAY.intValue()) << 24) | (array.getId() << 28));
block.addValueRecord(array);
PropertyRecord property = new PropertyRecord(next.property());
property.addPropertyBlock(block);
tx.create(property);
}
});
// when
ConsistencySummaryStatistics stats = check();
// then
on(stats).verify(RecordType.ARRAY_PROPERTY, 1).andThatsAllFolks();
}
use of org.neo4j.kernel.impl.store.record.PropertyBlock in project neo4j by neo4j.
the class FullCheckIntegrationTest method shouldReportMissingMandatoryRelationshipProperty.
@Test
public void shouldReportMissingMandatoryRelationshipProperty() throws Exception {
// given
fixture.apply(new GraphStoreFixture.Transaction() {
@Override
protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
long nodeId1 = next.node();
long nodeId2 = next.node();
long relId = next.relationship();
long propId = next.property();
NodeRecord node1 = new NodeRecord(nodeId1, true, false, relId, NO_NEXT_PROPERTY.intValue(), NO_LABELS_FIELD.intValue());
NodeRecord node2 = new NodeRecord(nodeId2, true, false, relId, NO_NEXT_PROPERTY.intValue(), NO_LABELS_FIELD.intValue());
// structurally correct, but does not have the 'mandatory' property with the 'M' rel type
RelationshipRecord relationship = new RelationshipRecord(relId, true, nodeId1, nodeId2, M, NO_PREV_RELATIONSHIP.intValue(), NO_NEXT_RELATIONSHIP.intValue(), NO_PREV_RELATIONSHIP.intValue(), NO_NEXT_RELATIONSHIP.intValue(), true, true);
relationship.setNextProp(propId);
PropertyRecord property = new PropertyRecord(propId, relationship);
property.setInUse(true);
PropertyBlock block = new PropertyBlock();
block.setSingleBlock(key | (((long) PropertyType.INT.intValue()) << 24) | (1337L << 28));
property.addPropertyBlock(block);
tx.create(node1);
tx.create(node2);
tx.create(relationship);
tx.create(property);
tx.incrementRelationshipCount(ANY_LABEL, ANY_RELATIONSHIP_TYPE, ANY_LABEL, 1);
tx.incrementRelationshipCount(ANY_LABEL, M, ANY_LABEL, 1);
}
});
createRelationshipPropertyExistenceConstraint(M, mandatory);
// when
ConsistencySummaryStatistics stats = check();
// then
on(stats).verify(RecordType.RELATIONSHIP, 1).andThatsAllFolks();
}
Aggregations