Search in sources :

Example 6 with StubPageCursor

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

the class RecordFormat method assertRecordsWrittenCorrectly.

public final void assertRecordsWrittenCorrectly(File file, StoreChannel channel) throws IOException {
    int recordSize = getRecordSize();
    long recordsInFile = channel.size() / recordSize;
    ByteBuffer buffer = ByteBuffer.allocateDirect(recordSize);
    StubPageCursor cursor = new StubPageCursor(0, buffer);
    for (int i = 0; i < recordsInFile; i++) {
        assertThat("reading record id " + i, channel.read(buffer), is(recordSize));
        buffer.flip();
        Record expectedRecord = createRecord(file, i);
        cursor.setOffset(0);
        Record actualRecord = readRecord(cursor);
        buffer.clear();
        assertThat(actualRecord, isOneOf(expectedRecord, zeroRecord()));
    }
}
Also used : StubPageCursor(org.neo4j.io.pagecache.StubPageCursor) ByteBuffer(java.nio.ByteBuffer)

Example 7 with StubPageCursor

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

the class RecordFormat method assertRecordsWrittenCorrectly.

public final void assertRecordsWrittenCorrectly(Path file, StoreChannel channel) throws IOException {
    int recordSize = getRecordSize();
    long recordsInFile = channel.size() / recordSize;
    ByteBuffer buffer = ByteBuffers.allocate(recordSize, INSTANCE);
    StubPageCursor cursor = new StubPageCursor(0, buffer);
    for (int i = 0; i < recordsInFile; i++) {
        assertThat(channel.read(buffer)).as("reading record id " + i).isEqualTo(recordSize);
        buffer.flip();
        Record expectedRecord = createRecord(file, i, (int) (channel.position() / PAGE_SIZE), 0);
        cursor.setOffset(0);
        Record actualRecord = readRecord(cursor);
        buffer.clear();
        try {
            assertThat(actualRecord).isIn(expectedRecord, zeroRecord());
        } catch (Throwable t) {
            throw new RuntimeException(t);
        }
    }
}
Also used : StubPageCursor(org.neo4j.io.pagecache.StubPageCursor) ByteBuffer(java.nio.ByteBuffer)

Example 8 with StubPageCursor

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

the class BaseHighLimitRecordFormatTest method mustNotCheckForOutOfBoundsWhenReadingSingleRecord.

@Test
public void mustNotCheckForOutOfBoundsWhenReadingSingleRecord() throws Exception {
    MyRecordFormat format = new MyRecordFormat();
    StubPageCursor cursor = new StubPageCursor(0, 3);
    format.read(new MyRecord(0), cursor, RecordLoad.NORMAL, 4);
    assertFalse(cursor.checkAndClearBoundsFlag());
}
Also used : StubPageCursor(org.neo4j.io.pagecache.StubPageCursor) Test(org.junit.Test)

Example 9 with StubPageCursor

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

the class RecordFormat method writeRecord.

public final void writeRecord(Record record, StoreChannel channel) throws IOException {
    ByteBuffer buffer = ByteBuffers.allocate(getRecordSize(), INSTANCE);
    StubPageCursor cursor = new StubPageCursor(0, buffer);
    write(record, cursor);
    channel.writeAll(buffer);
}
Also used : StubPageCursor(org.neo4j.io.pagecache.StubPageCursor) ByteBuffer(java.nio.ByteBuffer)

Example 10 with StubPageCursor

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

the class CompositePageCursorTest method compositeCursorDoesNotSupportCopyTo.

@Test
void compositeCursorDoesNotSupportCopyTo() {
    assertThrows(UnsupportedOperationException.class, () -> {
        PageCursor pageCursor = CompositePageCursor.compose(first, PAGE_SIZE, second, PAGE_SIZE);
        pageCursor.copyTo(0, new StubPageCursor(0, 7), 89, 6);
    });
}
Also used : 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