use of org.neo4j.io.pagecache.StubPageCursor in project neo4j by neo4j.
the class RelationshipGroupRecordFormatTest method shouldReadUnsignedRelationshipTypeId.
@ParameterizedTest
@MethodSource("formats")
void shouldReadUnsignedRelationshipTypeId(RecordFormats formats) throws Exception {
// GIVEN
RecordFormat<RelationshipGroupRecord> format = formats.relationshipGroup();
int recordSize = format.getRecordSize(NO_STORE_HEADER);
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);
if (formats.hasCapability(RecordStorageCapability.GROUP_DEGREES_STORE)) {
group.setHasExternalDegreesOut(random.nextBoolean());
group.setHasExternalDegreesIn(random.nextBoolean());
group.setHasExternalDegreesLoop(random.nextBoolean());
}
cursor.setOffset(offset);
format.write(group, cursor, recordSize, cursor.getCurrentPageSize() / recordSize);
// WHEN
RelationshipGroupRecord read = new RelationshipGroupRecord(group.getId());
cursor.setOffset(offset);
format.read(read, cursor, NORMAL, recordSize, cursor.getCurrentPageSize() / recordSize);
// THEN
assertEquals(group, read);
}
}
use of org.neo4j.io.pagecache.StubPageCursor in project neo4j by neo4j.
the class BaseRecordFormatTest method shouldRecognizeDesignatedInUseBit.
@Test
void shouldRecognizeDesignatedInUseBit() {
// GIVEN
RecordFormat<DynamicRecord> format = new DynamicRecordFormat();
PageCursor cursor = new StubPageCursor(0, 1_000);
byte inUseByte = 0;
for (int i = 0; i < 8; i++) {
// WHEN
cursor.setOffset(68);
cursor.putByte(cursor.getOffset(), inUseByte);
// THEN
assertEquals(shouldBeInUse(inUseByte), format.isInUse(cursor));
inUseByte <<= 1;
inUseByte |= 1;
}
}
Aggregations