use of org.neo4j.io.pagecache.context.CursorContext in project neo4j by neo4j.
the class MuninnPageCacheTest method doNotMarkCursorContextAsDirtyWhenReadingDataFromOlderTransactions.
@Test
void doNotMarkCursorContextAsDirtyWhenReadingDataFromOlderTransactions() throws IOException {
TestVersionContext versionContext = new TestVersionContext(() -> 23);
try (MuninnPageCache pageCache = createPageCache(fs, 2, PageCacheTracer.NULL);
PagedFile pagedFile = map(pageCache, file("a"), 8);
CursorContext cursorContext = new CursorContext(PageCursorTracer.NULL, versionContext)) {
versionContext.initWrite(17);
try (PageCursor cursor = pagedFile.io(0, PF_SHARED_WRITE_LOCK, cursorContext)) {
assertTrue(cursor.next());
cursor.putLong(3);
}
versionContext.initRead();
assertFalse(versionContext.isDirty());
try (PageCursor cursor = pagedFile.io(0, PF_SHARED_READ_LOCK, cursorContext)) {
assertTrue(cursor.next());
assertEquals(3, cursor.getLong());
assertFalse(versionContext.isDirty());
}
}
}
use of org.neo4j.io.pagecache.context.CursorContext in project neo4j by neo4j.
the class ReadOnlyTransactionIdStoreIT method testPageCacheAccessOnTransactionIdStoreConstruction.
@Test
void testPageCacheAccessOnTransactionIdStoreConstruction() throws IOException {
var pageCacheTracer = new DefaultPageCacheTracer();
var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("testPageCacheAccessOnTransactionIdStoreConstruction"));
new ReadOnlyTransactionIdStore(fs, pageCache, databaseLayout, cursorContext);
PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
assertThat(cursorTracer.pins()).isEqualTo(4);
assertThat(cursorTracer.unpins()).isEqualTo(4);
assertThat(cursorTracer.hits()).isEqualTo(4);
}
use of org.neo4j.io.pagecache.context.CursorContext in project neo4j by neo4j.
the class PageCachePrefetchingTest method setUp.
@BeforeEach
void setUp() {
file = dir.createFile("file");
cursorContext = new CursorContext(new DefaultPageCursorTracer(new DefaultPageCacheTracer(), "test"));
}
use of org.neo4j.io.pagecache.context.CursorContext in project neo4j by neo4j.
the class CountsComputerTest method tracePageCacheAccessOnInitialization.
@Test
void tracePageCacheAccessOnInitialization() throws IOException {
DatabaseManagementService managementService = dbBuilder.build();
try {
GraphDatabaseAPI db = (GraphDatabaseAPI) managementService.database(DEFAULT_DATABASE_NAME);
var countsStore = db.getDependencyResolver().resolveDependency(GBPTreeCountsStore.class);
var pageCacheTracer = new DefaultPageCacheTracer();
var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer("tracePageCacheAccessOnInitialization"));
countsStore.start(cursorContext, INSTANCE);
PageCursorTracer cursorTracer = cursorContext.getCursorTracer();
softly.assertThat(cursorTracer.pins()).as("Pins").isEqualTo(1);
softly.assertThat(cursorTracer.unpins()).as("Unpins").isEqualTo(1);
softly.assertThat(cursorTracer.hits()).as("hits").isEqualTo(1);
} finally {
managementService.shutdown();
}
}
use of org.neo4j.io.pagecache.context.CursorContext in project neo4j by neo4j.
the class PageCacheByteArray method setShort.
@Override
public void setShort(long index, int offset, short value) {
long pageId = pageId(index);
offset += offset(index);
try (CursorContext cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer(PAGE_CACHE_BYTE_ARRAY_WORKER_TAG));
PageCursor cursor = pagedFile.io(pageId, PF_SHARED_WRITE_LOCK | PF_NO_GROW, cursorContext)) {
cursor.next();
cursor.putShort(offset, value);
checkBounds(cursor);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
Aggregations