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