Search in sources :

Example 61 with PropertyBlock

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();
}
Also used : PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) ChainCheck(org.neo4j.consistency.checking.ChainCheck) RecordAccessStub(org.neo4j.consistency.store.RecordAccessStub) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 62 with PropertyBlock

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);
}
Also used : PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) ChainCheck(org.neo4j.consistency.checking.ChainCheck) RecordAccessStub(org.neo4j.consistency.store.RecordAccessStub) ConsistencyReport(org.neo4j.consistency.report.ConsistencyReport) Test(org.junit.Test)

Example 63 with PropertyBlock

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();
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) TransactionDataBuilder(org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder) IdGenerator(org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) GraphStoreFixture(org.neo4j.consistency.checking.GraphStoreFixture) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) Test(org.junit.Test)

Example 64 with PropertyBlock

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();
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) TransactionDataBuilder(org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder) IdGenerator(org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) GraphStoreFixture(org.neo4j.consistency.checking.GraphStoreFixture) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) Test(org.junit.Test)

Example 65 with PropertyBlock

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();
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) TransactionDataBuilder(org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder) IdGenerator(org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) GraphStoreFixture(org.neo4j.consistency.checking.GraphStoreFixture) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) Test(org.junit.Test)

Aggregations

PropertyBlock (org.neo4j.kernel.impl.store.record.PropertyBlock)90 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)57 Test (org.junit.Test)21 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)16 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)9 IOException (java.io.IOException)8 InterruptedIOException (java.io.InterruptedIOException)8 Pair (org.neo4j.helpers.collection.Pair)8 DefinedProperty (org.neo4j.kernel.api.properties.DefinedProperty)8 ArrayMap (org.neo4j.kernel.impl.util.ArrayMap)8 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)6 PropertyKeyTokenRecord (org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord)6 GraphStoreFixture (org.neo4j.consistency.checking.GraphStoreFixture)5 IdGenerator (org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator)5 TransactionDataBuilder (org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder)5 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)5 PrimitiveRecord (org.neo4j.kernel.impl.store.record.PrimitiveRecord)4 ChainCheck (org.neo4j.consistency.checking.ChainCheck)3 RecordAccessStub (org.neo4j.consistency.store.RecordAccessStub)3 DynamicRecordAllocator (org.neo4j.kernel.impl.store.DynamicRecordAllocator)3