use of org.neo4j.io.pagecache.randomharness.Record in project neo4j by neo4j.
the class PageCacheTest method mustReadZerosFromBeyondEndOfFile.
@Test(timeout = SEMI_LONG_TIMEOUT_MILLIS)
public void mustReadZerosFromBeyondEndOfFile() throws Exception {
StandardRecordFormat recordFormat = new StandardRecordFormat();
File[] files = { file("1"), file("2"), file("3"), file("4"), file("5"), file("6"), file("7"), file("8"), file("9"), file("0"), file("A"), file("B") };
for (int fileId = 0; fileId < files.length; fileId++) {
File file = files[fileId];
StoreChannel channel = fs.open(file, "rw");
for (int recordId = 0; recordId < fileId + 1; recordId++) {
Record record = recordFormat.createRecord(file, recordId);
recordFormat.writeRecord(record, channel);
}
channel.close();
}
int pageSize = nextPowerOf2(recordFormat.getRecordSize() * (files.length + 1));
getPageCache(fs, 2, pageSize, PageCacheTracer.NULL, PageCursorTracerSupplier.NULL);
int fileId = files.length;
while (fileId-- > 0) {
File file = files[fileId];
try (PagedFile pf = pageCache.map(file, pageSize);
PageCursor cursor = pf.io(0, PF_SHARED_READ_LOCK)) {
int pageCount = 0;
while (cursor.next()) {
pageCount++;
recordFormat.assertRecordsWrittenCorrectly(cursor);
}
assertThat("pages in file " + file, pageCount, greaterThan(0));
}
}
}
Aggregations