Search in sources :

Example 1 with RelationshipGroupRecord

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

the class RelationshipGroupRecordFormatTest method shouldReadUnsignedRelationshipTypeId.

@Test
public void shouldReadUnsignedRelationshipTypeId() throws Exception {
    // GIVEN
    try (PageCursor cursor = new StubPageCursor(1, recordSize * 10)) {
        int offset = 10;
        cursor.next();
        RelationshipGroupRecord group = new RelationshipGroupRecord(2).initialize(true, Short.MAX_VALUE + offset, 1, 2, 3, 4, 5);
        cursor.setOffset(offset);
        format.write(group, cursor, recordSize);
        // WHEN
        RelationshipGroupRecord read = new RelationshipGroupRecord(group.getId());
        cursor.setOffset(offset);
        format.read(read, cursor, NORMAL, recordSize);
        // THEN
        assertEquals(group, read);
    }
}
Also used : RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) StubPageCursor(org.neo4j.io.pagecache.StubPageCursor) PageCursor(org.neo4j.io.pagecache.PageCursor) StubPageCursor(org.neo4j.io.pagecache.StubPageCursor) Test(org.junit.Test)

Example 2 with RelationshipGroupRecord

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

the class Commands method createRelationshipGroup.

public static RelationshipGroupCommand createRelationshipGroup(long id, int type) {
    RelationshipGroupRecord before = new RelationshipGroupRecord(id);
    RelationshipGroupRecord after = new RelationshipGroupRecord(id, type);
    after.setInUse(true);
    after.setCreated();
    return new RelationshipGroupCommand(before, after);
}
Also used : RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) RelationshipGroupCommand(org.neo4j.kernel.impl.transaction.command.Command.RelationshipGroupCommand)

Example 3 with RelationshipGroupRecord

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

the class InconsistencyReportReaderTest method shouldReadBasicEntities.

@Test
public void shouldReadBasicEntities() throws Exception {
    // GIVEN
    ByteArrayOutputStream out = new ByteArrayOutputStream(1_000);
    FormattedLog log = FormattedLog.toOutputStream(out);
    InconsistencyMessageLogger logger = new InconsistencyMessageLogger(log);
    long nodeId = 5;
    long relationshipGroupId = 10;
    long relationshipId = 15;
    long propertyId = 20;
    logger.error(RecordType.NODE, new NodeRecord(nodeId), "Some error", "something");
    logger.error(RecordType.RELATIONSHIP, new RelationshipRecord(relationshipId), "Some error", "something");
    logger.error(RecordType.RELATIONSHIP_GROUP, new RelationshipGroupRecord(relationshipGroupId), "Some error", "something");
    logger.error(RecordType.PROPERTY, new PropertyRecord(propertyId), "Some error", "something");
    String text = out.toString();
    PrimitiveLongSet nodes = Primitive.longSet();
    PrimitiveLongSet relationships = Primitive.longSet();
    PrimitiveLongSet relationshipGroups = Primitive.longSet();
    PrimitiveLongSet properties = Primitive.longSet();
    // WHEN
    InconsistencyReportReader reader = new InconsistencyReportReader(new Inconsistencies() {

        @Override
        public void relationshipGroup(long id) {
            relationshipGroups.add(id);
        }

        @Override
        public void relationship(long id) {
            relationships.add(id);
        }

        @Override
        public void property(long id) {
            properties.add(id);
        }

        @Override
        public void node(long id) {
            nodes.add(id);
        }
    });
    reader.read(new StringReader(text));
    // THEN
    assertEquals(asSet(iterator(nodeId)), nodes);
    assertEquals(asSet(iterator(relationshipId)), relationships);
    assertEquals(asSet(iterator(relationshipGroupId)), relationshipGroups);
    assertEquals(asSet(iterator(propertyId)), properties);
}
Also used : FormattedLog(org.neo4j.logging.FormattedLog) RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) Inconsistencies(org.neo4j.tools.dump.InconsistencyReportReader.Inconsistencies) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) ByteArrayOutputStream(java.io.ByteArrayOutputStream) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) PrimitiveLongSet(org.neo4j.collection.primitive.PrimitiveLongSet) StringReader(java.io.StringReader) InconsistencyMessageLogger(org.neo4j.consistency.report.InconsistencyMessageLogger) Test(org.junit.Test)

Example 4 with RelationshipGroupRecord

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

the class RelationshipGroupCheckTypeTest method notInUseRecordEquality.

@Test
public void notInUseRecordEquality() {
    RelationshipGroupRecord record1 = new RelationshipGroupRecord(1);
    record1.initialize(false, 1, 2, 3, 4, 5, 6);
    record1.setSecondaryUnitId(42);
    RelationshipGroupRecord record2 = new RelationshipGroupRecord(1);
    record1.initialize(false, 11, 22, 33, 44, 55, 66);
    record2.setSecondaryUnitId(24);
    RelationshipGroupCheckType check = new RelationshipGroupCheckType();
    assertTrue(check.equal(record1, record2));
}
Also used : RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord) Test(org.junit.Test)

Example 5 with RelationshipGroupRecord

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

the class TransactionWriter method create.

public void create(RelationshipGroupRecord group) {
    group.setCreated();
    update(new RelationshipGroupRecord(group.getId(), group.getType()), group);
}
Also used : RelationshipGroupRecord(org.neo4j.kernel.impl.store.record.RelationshipGroupRecord)

Aggregations

RelationshipGroupRecord (org.neo4j.kernel.impl.store.record.RelationshipGroupRecord)153 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)39 Test (org.junit.jupiter.api.Test)31 Test (org.junit.Test)27 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)20 InMemoryClosableChannel (org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel)16 StorageCommand (org.neo4j.storageengine.api.StorageCommand)9 RelationshipGroupStore (org.neo4j.kernel.impl.store.RelationshipGroupStore)8 CommandReader (org.neo4j.storageengine.api.CommandReader)8 RepeatedTest (org.junit.jupiter.api.RepeatedTest)7 NodeStore (org.neo4j.kernel.impl.store.NodeStore)6 ArrayList (java.util.ArrayList)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 CursorContext (org.neo4j.io.pagecache.context.CursorContext)5 RelationshipStore (org.neo4j.kernel.impl.store.RelationshipStore)5 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)5 Command (org.neo4j.kernel.impl.transaction.command.Command)5 IOException (java.io.IOException)4 PageCursor (org.neo4j.io.pagecache.PageCursor)4 NeoStores (org.neo4j.kernel.impl.store.NeoStores)4