use of org.neo4j.io.pagecache.PageCursor in project neo4j by neo4j.
the class CrashGenerationCleanerTest method initializeFile.
private void initializeFile(PagedFile pagedFile, Page... pages) throws IOException {
try (PageCursor cursor = pagedFile.io(0, PagedFile.PF_SHARED_WRITE_LOCK)) {
for (Page page : pages) {
cursor.next();
page.write(cursor, corruptableTreeNode, stableGeneration, unstableGeneration, crashGeneration);
}
}
}
use of org.neo4j.io.pagecache.PageCursor in project neo4j by neo4j.
the class GBPTreeTest method setFormatVersion.
private void setFormatVersion(int pageSize, int formatVersion) throws IOException {
try (PagedFile pagedFile = pageCache.map(indexFile, pageSize);
PageCursor cursor = pagedFile.io(IdSpace.META_PAGE_ID, PagedFile.PF_SHARED_WRITE_LOCK)) {
assertTrue(cursor.next());
cursor.putInt(formatVersion);
}
}
use of org.neo4j.io.pagecache.PageCursor in project neo4j by neo4j.
the class PageAwareByteArrayCursor method openLinkedCursor.
@Override
public PageCursor openLinkedCursor(long pageId) {
PageCursor toReturn = new PageAwareByteArrayCursor(pages, pageSize, pageId);
if (linkedCursor != null) {
linkedCursor.close();
}
linkedCursor = toReturn;
return toReturn;
}
use of org.neo4j.io.pagecache.PageCursor in project neo4j by neo4j.
the class PageCursorUtilTest method shouldFailOnInvalidValues.
@Test
public void shouldFailOnInvalidValues() throws Exception {
// GIVEN
PageCursor cursor = ByteArrayPageCursor.wrap(10);
// WHEN
for (int i = 0; i < 1_000; ) {
long expected = random.nextLong();
if ((expected & ~_6B_MASK) != 0) {
// OK here we have an invalid value
cursor.setOffset(0);
try {
PageCursorUtil.put6BLong(cursor, expected);
fail("Should have failed");
} catch (IllegalArgumentException e) {
// THEN good
}
i++;
}
}
}
use of org.neo4j.io.pagecache.PageCursor in project neo4j by neo4j.
the class FreeListIdProvider method releaseId.
@Override
public void releaseId(long stableGeneration, long unstableGeneration, long id) throws IOException {
try (PageCursor cursor = pagedFile.io(writePageId, PagedFile.PF_SHARED_WRITE_LOCK)) {
PageCursorUtil.goTo(cursor, "free-list write page", writePageId);
freelistNode.write(cursor, unstableGeneration, id, writePos);
writePos++;
}
if (writePos >= freelistNode.maxEntries()) {
// Current free-list write page is full, allocate a new one.
long nextFreelistPage = acquireNewId(stableGeneration, unstableGeneration, false);
try (PageCursor cursor = pagedFile.io(writePageId, PagedFile.PF_SHARED_WRITE_LOCK)) {
PageCursorUtil.goTo(cursor, "free-list write page", writePageId);
FreelistNode.initialize(cursor);
// Link previous --> new writer page
FreelistNode.setNext(cursor, nextFreelistPage);
}
writePageId = nextFreelistPage;
writePos = 0;
monitor.acquiredFreelistPageId(nextFreelistPage);
}
}
Aggregations