Search in sources :

Example 1 with StubPageCursor

use of org.neo4j.io.pagecache.StubPageCursor 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 StubPageCursor

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

the class PropertyRecordFormatTest method setUp.

@Before
public void setUp() {
    recordFormat = new PropertyRecordFormat();
    pageCursor = new StubPageCursor(0, (int) ByteUnit.kibiBytes(8));
    idSequence = new ConstantIdSequence();
}
Also used : StubPageCursor(org.neo4j.io.pagecache.StubPageCursor) Before(org.junit.Before)

Example 3 with StubPageCursor

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

the class BaseHighLimitRecordFormatTest method mustCheckForOutOfBoundsWhenReadingDoubleRecord.

@Test
public void mustCheckForOutOfBoundsWhenReadingDoubleRecord() throws Exception {
    MyRecordFormat format = new MyRecordFormat();
    StubPageCursor cursor = new StubPageCursor(0, 4);
    cursor.putByte(0, (byte) (HEADER_BIT_RECORD_UNIT + HEADER_BIT_FIRST_RECORD_UNIT));
    StubPagedFile pagedFile = new StubPagedFile(3) {

        @Override
        protected void prepareCursor(StubPageCursor cursor) {
            cursor.putByte(0, (byte) HEADER_BIT_RECORD_UNIT);
        }
    };
    format.shortsPerRecord.add(2);
    format.read(new MyRecord(0), cursor, RecordLoad.NORMAL, 4);
    assertTrue(cursor.checkAndClearBoundsFlag());
}
Also used : StubPageCursor(org.neo4j.io.pagecache.StubPageCursor) StubPagedFile(org.neo4j.io.pagecache.StubPagedFile) Test(org.junit.Test)

Example 4 with StubPageCursor

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

the class BaseHighLimitRecordFormatTest method mustCheckForOutOfBoundsWhenWritingDoubleRecord.

@Test
public void mustCheckForOutOfBoundsWhenWritingDoubleRecord() throws Exception {
    MyRecordFormat format = new MyRecordFormat();
    StubPageCursor cursor = new StubPageCursor(0, 5);
    MyRecord record = new MyRecord(0);
    record.setRequiresSecondaryUnit(true);
    record.setSecondaryUnitId(42);
    record.setInUse(true);
    // make the write go out of bounds
    format.shortsPerRecord.add(3);
    format.write(record, cursor, 4);
    assertTrue(cursor.checkAndClearBoundsFlag());
}
Also used : StubPageCursor(org.neo4j.io.pagecache.StubPageCursor) Test(org.junit.Test)

Example 5 with StubPageCursor

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

the class BaseHighLimitRecordFormatTest method mustNotCheckForOutOfBoundsWhenWritingSingleRecord.

@Test
public void mustNotCheckForOutOfBoundsWhenWritingSingleRecord() throws Exception {
    MyRecordFormat format = new MyRecordFormat();
    StubPageCursor cursor = new StubPageCursor(0, 3);
    MyRecord record = new MyRecord(0);
    record.setInUse(true);
    format.write(record, cursor, 4);
    assertFalse(cursor.checkAndClearBoundsFlag());
}
Also used : StubPageCursor(org.neo4j.io.pagecache.StubPageCursor) Test(org.junit.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