use of org.neo4j.io.pagecache.PageCursor in project neo4j by neo4j.
the class AbstractRecordFormatTest method writeRecord.
private <R extends AbstractBaseRecord> void writeRecord(R record, RecordFormat<R> format, PagedFile storeFile, int recordSize, BatchingIdSequence idSequence) throws IOException {
try (PageCursor cursor = storeFile.io(0, PagedFile.PF_SHARED_WRITE_LOCK)) {
assertedNext(cursor);
if (record.inUse()) {
format.prepare(record, recordSize, idSequence);
}
int offset = Math.toIntExact(record.getId() * recordSize);
cursor.setOffset(offset);
format.write(record, cursor, recordSize);
assertWithinBounds(record, cursor, "writing");
}
}
use of org.neo4j.io.pagecache.PageCursor 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);
}
}
use of org.neo4j.io.pagecache.PageCursor in project neo4j by neo4j.
the class CompositePageCursorTest method putLongOffsettedBeforeFirstPageMustRaiseBoundsFlag.
@Test
public void putLongOffsettedBeforeFirstPageMustRaiseBoundsFlag() throws Exception {
PageCursor pageCursor = CompositePageCursor.compose(first, PAGE_SIZE, second, PAGE_SIZE);
pageCursor.putLong(-1, (long) 1);
assertTrue(pageCursor.checkAndClearBoundsFlag());
assertFalse(pageCursor.checkAndClearBoundsFlag());
}
use of org.neo4j.io.pagecache.PageCursor in project neo4j by neo4j.
the class CompositePageCursorTest method putByteOffsettedBeyondEndOfViewMustRaiseBoundsFlag.
@Test
public void putByteOffsettedBeyondEndOfViewMustRaiseBoundsFlag() throws Exception {
PageCursor pageCursor = CompositePageCursor.compose(first, PAGE_SIZE, second, PAGE_SIZE);
for (int i = 0; i < 3 * PAGE_SIZE; i++) {
pageCursor.putByte(i, (byte) 1);
}
assertTrue(pageCursor.checkAndClearBoundsFlag());
assertFalse(pageCursor.checkAndClearBoundsFlag());
}
use of org.neo4j.io.pagecache.PageCursor in project neo4j by neo4j.
the class CompositePageCursorTest method getIntOffsettedBeforeFirstPageMustRaiseBoundsFlag.
@Test
public void getIntOffsettedBeforeFirstPageMustRaiseBoundsFlag() throws Exception {
PageCursor pageCursor = CompositePageCursor.compose(first, PAGE_SIZE, second, PAGE_SIZE);
pageCursor.getInt(-1);
assertTrue(pageCursor.checkAndClearBoundsFlag());
assertFalse(pageCursor.checkAndClearBoundsFlag());
}
Aggregations