Search in sources :

Example 91 with CursorContext

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());
        }
    }
}
Also used : PagedFile(org.neo4j.io.pagecache.PagedFile) CursorContext(org.neo4j.io.pagecache.context.CursorContext) PageCursor(org.neo4j.io.pagecache.PageCursor) PageCacheTest(org.neo4j.io.pagecache.PageCacheTest) Test(org.junit.jupiter.api.Test)

Example 92 with CursorContext

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);
}
Also used : PageCursorTracer(org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer) CursorContext(org.neo4j.io.pagecache.context.CursorContext) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) Test(org.junit.jupiter.api.Test)

Example 93 with CursorContext

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"));
}
Also used : DefaultPageCursorTracer(org.neo4j.io.pagecache.tracing.cursor.DefaultPageCursorTracer) CursorContext(org.neo4j.io.pagecache.context.CursorContext) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 94 with CursorContext

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();
    }
}
Also used : PageCursorTracer(org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) CursorContext(org.neo4j.io.pagecache.context.CursorContext) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) DefaultPageCacheTracer(org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer) Test(org.junit.jupiter.api.Test)

Example 95 with CursorContext

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);
    }
}
Also used : UncheckedIOException(java.io.UncheckedIOException) CursorContext(org.neo4j.io.pagecache.context.CursorContext) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) PageCursor(org.neo4j.io.pagecache.PageCursor)

Aggregations

CursorContext (org.neo4j.io.pagecache.context.CursorContext)161 Test (org.junit.jupiter.api.Test)74 DefaultPageCacheTracer (org.neo4j.io.pagecache.tracing.DefaultPageCacheTracer)52 PageCursor (org.neo4j.io.pagecache.PageCursor)40 IOException (java.io.IOException)31 UncheckedIOException (java.io.UncheckedIOException)27 PageCursorTracer (org.neo4j.io.pagecache.tracing.cursor.PageCursorTracer)27 Path (java.nio.file.Path)17 PagedFile (org.neo4j.io.pagecache.PagedFile)17 ArrayList (java.util.ArrayList)16 PageCacheTest (org.neo4j.io.pagecache.PageCacheTest)15 MutableLong (org.apache.commons.lang3.mutable.MutableLong)13 MemoryTracker (org.neo4j.memory.MemoryTracker)12 PageCache (org.neo4j.io.pagecache.PageCache)11 ProgressListener (org.neo4j.internal.helpers.progress.ProgressListener)10 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)10 List (java.util.List)9 RepeatedTest (org.junit.jupiter.api.RepeatedTest)9 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)9 PageCacheTracer (org.neo4j.io.pagecache.tracing.PageCacheTracer)8