Search in sources :

Example 76 with RelationshipRecord

use of org.neo4j.kernel.impl.store.record.RelationshipRecord in project neo4j by neo4j.

the class FullCheckIntegrationTest method shouldHandleNegativeRelationshipNodePointers.

@Test
void shouldHandleNegativeRelationshipNodePointers() throws Exception {
    // given
    fixture.apply(new GraphStoreFixture.Transaction() {

        @Override
        protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
            RelationshipRecord relationship = new RelationshipRecord(next.relationship());
            relationship.setLinks(-2, -3, C);
            tx.create(relationship);
            tx.incrementRelationshipCount(ANY_LABEL, ANY_RELATIONSHIP_TYPE, ANY_LABEL, 1);
            tx.incrementRelationshipCount(ANY_LABEL, C, ANY_LABEL, 1);
        }
    });
    // when
    ConsistencySummaryStatistics stats = check();
    // then
    on(stats).verify(RecordType.RELATIONSHIP, 2).andThatsAllFolks();
}
Also used : TransactionDataBuilder(org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder) IdGenerator(org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) GraphStoreFixture(org.neo4j.consistency.checking.GraphStoreFixture) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 77 with RelationshipRecord

use of org.neo4j.kernel.impl.store.record.RelationshipRecord in project neo4j by neo4j.

the class FullCheckIntegrationTest method shouldReportCircularRelationshipPropertyRecordChain.

@Test
void shouldReportCircularRelationshipPropertyRecordChain() throws Exception {
    int relType = createRelType();
    shouldReportCircularPropertyRecordChain(RecordType.RELATIONSHIP, (tx, next, propertyRecordId) -> {
        long node = next.node();
        long relationship = next.relationship();
        tx.create(new NodeRecord(node).initialize(true, -1, false, relationship, Record.NO_LABELS_FIELD.longValue()));
        RelationshipRecord relationshipRecord = new RelationshipRecord(relationship);
        relationshipRecord.setFirstNode(node);
        relationshipRecord.setSecondNode(node);
        relationshipRecord.setType(relType);
        relationshipRecord.setNextProp(propertyRecordId);
        tx.create(relationshipRecord);
    });
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 78 with RelationshipRecord

use of org.neo4j.kernel.impl.store.record.RelationshipRecord in project neo4j by neo4j.

the class FullCheckIntegrationTest method shouldManageUnusedRecordsWithWeirdDataIn.

@Test
void shouldManageUnusedRecordsWithWeirdDataIn() throws Exception {
    // Given
    final AtomicLong id = new AtomicLong();
    fixture.apply(new GraphStoreFixture.Transaction() {

        @Override
        protected void transactionData(TransactionDataBuilder tx, IdGenerator next) {
            id.set(next.relationship());
            RelationshipRecord relationship = new RelationshipRecord(id.get());
            relationship.setFirstNode(-1);
            relationship.setSecondNode(-1);
            relationship.setInUse(true);
            tx.create(relationship);
        }
    });
    fixture.apply(new GraphStoreFixture.Transaction() {

        @Override
        protected void transactionData(TransactionDataBuilder tx, IdGenerator next) {
            RelationshipRecord relationship = new RelationshipRecord(id.get());
            tx.delete(relationship);
        }
    });
    // When
    ConsistencySummaryStatistics stats = check();
    // Then
    assertTrue(stats.isConsistent());
}
Also used : TransactionDataBuilder(org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder) AtomicLong(java.util.concurrent.atomic.AtomicLong) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) IdGenerator(org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator) GraphStoreFixture(org.neo4j.consistency.checking.GraphStoreFixture) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 79 with RelationshipRecord

use of org.neo4j.kernel.impl.store.record.RelationshipRecord in project neo4j by neo4j.

the class FullCheckIntegrationTest method shouldReportRelationshipOtherNodeInconsistencies.

@Test
void shouldReportRelationshipOtherNodeInconsistencies() throws Exception {
    // given
    fixture.apply(new GraphStoreFixture.Transaction() {

        @Override
        protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
            long node1 = next.node();
            long node2 = next.node();
            long rel = next.relationship();
            RelationshipRecord relationship = new RelationshipRecord(rel);
            relationship.setLinks(node1, node2, 0);
            tx.create(inUse(relationship));
            tx.create(inUse(new NodeRecord(node1).initialize(false, -1, false, rel + 1, 0)));
            tx.create(inUse(new NodeRecord(node2).initialize(false, -1, false, rel + 2, 0)));
        }
    });
    // when
    ConsistencySummaryStatistics stats = check();
    // then
    on(stats).verify(RecordType.RELATIONSHIP, 2).verify(RecordType.NODE, 2).verify(RecordType.COUNTS, 2).andThatsAllFolks();
}
Also used : NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) TransactionDataBuilder(org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder) IdGenerator(org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) GraphStoreFixture(org.neo4j.consistency.checking.GraphStoreFixture) ConsistencySummaryStatistics(org.neo4j.consistency.report.ConsistencySummaryStatistics) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Example 80 with RelationshipRecord

use of org.neo4j.kernel.impl.store.record.RelationshipRecord in project neo4j by neo4j.

the class CalculateDenseNodesStepTest method shouldNotProcessLoopsTwice.

@Test
void shouldNotProcessLoopsTwice() throws Exception {
    // GIVEN
    NodeRelationshipCache cache = mock(NodeRelationshipCache.class);
    try (CalculateDenseNodesStep step = new CalculateDenseNodesStep(mock(StageControl.class), Configuration.DEFAULT, cache)) {
        step.processors(4);
        step.start(0);
        // WHEN
        long id = 0;
        RelationshipRecord[] batch = batch(relationship(id++, 1, 5), relationship(id++, 3, 10), // <-- the loop
        relationship(id++, 2, 2), relationship(id, 4, 1));
        step.receive(0, batch);
        step.endOfUpstream();
        step.awaitCompleted();
        // THEN
        verify(cache, times(2)).incrementCount(eq(1L));
        verify(cache).incrementCount(eq(2L));
        verify(cache).incrementCount(eq(3L));
        verify(cache).incrementCount(eq(4L));
        verify(cache).incrementCount(eq(5L));
        verify(cache).incrementCount(eq(10L));
    }
}
Also used : NodeRelationshipCache(org.neo4j.internal.batchimport.cache.NodeRelationshipCache) StageControl(org.neo4j.internal.batchimport.staging.StageControl) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) Test(org.junit.jupiter.api.Test)

Aggregations

RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)207 Test (org.junit.Test)73 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)69 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)43 Test (org.junit.jupiter.api.Test)34 RelationshipTypeTokenRecord (org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord)30 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)19 RelationshipGroupRecord (org.neo4j.kernel.impl.store.record.RelationshipGroupRecord)19 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)15 RelationshipStore (org.neo4j.kernel.impl.store.RelationshipStore)14 GraphStoreFixture (org.neo4j.consistency.checking.GraphStoreFixture)12 IdGenerator (org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator)12 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)12 TransactionDataBuilder (org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder)11 InMemoryClosableChannel (org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel)11 RecordAccessStub (org.neo4j.consistency.store.RecordAccessStub)9 InputRelationship (org.neo4j.unsafe.impl.batchimport.input.InputRelationship)8 RepeatedTest (org.junit.jupiter.api.RepeatedTest)7 IOException (java.io.IOException)6 CursorContext (org.neo4j.io.pagecache.context.CursorContext)6