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()));
}
}
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);
}
}
}
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());
}
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);
}
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);
});
}
Aggregations