Search in sources :

Example 11 with StubPageCursor

use of org.neo4j.io.pagecache.StubPageCursor in project neo4j by neo4j.

the class RelationshipGroupRecordFormatTest method shouldReadUnsignedRelationshipTypeId.

@ParameterizedTest
@MethodSource("formats")
void shouldReadUnsignedRelationshipTypeId(RecordFormats formats) throws Exception {
    // GIVEN
    RecordFormat<RelationshipGroupRecord> format = formats.relationshipGroup();
    int recordSize = format.getRecordSize(NO_STORE_HEADER);
    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);
        if (formats.hasCapability(RecordStorageCapability.GROUP_DEGREES_STORE)) {
            group.setHasExternalDegreesOut(random.nextBoolean());
            group.setHasExternalDegreesIn(random.nextBoolean());
            group.setHasExternalDegreesLoop(random.nextBoolean());
        }
        cursor.setOffset(offset);
        format.write(group, cursor, recordSize, cursor.getCurrentPageSize() / recordSize);
        // WHEN
        RelationshipGroupRecord read = new RelationshipGroupRecord(group.getId());
        cursor.setOffset(offset);
        format.read(read, cursor, NORMAL, recordSize, cursor.getCurrentPageSize() / 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) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 12 with StubPageCursor

use of org.neo4j.io.pagecache.StubPageCursor in project neo4j by neo4j.

the class BaseRecordFormatTest method shouldRecognizeDesignatedInUseBit.

@Test
void shouldRecognizeDesignatedInUseBit() {
    // GIVEN
    RecordFormat<DynamicRecord> format = new DynamicRecordFormat();
    PageCursor cursor = new StubPageCursor(0, 1_000);
    byte inUseByte = 0;
    for (int i = 0; i < 8; i++) {
        // WHEN
        cursor.setOffset(68);
        cursor.putByte(cursor.getOffset(), inUseByte);
        // THEN
        assertEquals(shouldBeInUse(inUseByte), format.isInUse(cursor));
        inUseByte <<= 1;
        inUseByte |= 1;
    }
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) DynamicRecordFormat(org.neo4j.kernel.impl.store.format.standard.DynamicRecordFormat) StubPageCursor(org.neo4j.io.pagecache.StubPageCursor) PageCursor(org.neo4j.io.pagecache.PageCursor) StubPageCursor(org.neo4j.io.pagecache.StubPageCursor) Test(org.junit.jupiter.api.Test)

Aggregations

StubPageCursor (org.neo4j.io.pagecache.StubPageCursor)12 Test (org.junit.Test)5 PageCursor (org.neo4j.io.pagecache.PageCursor)4 ByteBuffer (java.nio.ByteBuffer)3 Test (org.junit.jupiter.api.Test)2 RelationshipGroupRecord (org.neo4j.kernel.impl.store.record.RelationshipGroupRecord)2 Before (org.junit.Before)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1 StubPagedFile (org.neo4j.io.pagecache.StubPagedFile)1 DynamicRecordFormat (org.neo4j.kernel.impl.store.format.standard.DynamicRecordFormat)1 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)1