Search in sources :

Example 31 with CursorContext

use of org.neo4j.io.pagecache.context.CursorContext in project neo4j by neo4j.

the class PageCacheByteArray method set3ByteInt.

@Override
public void set3ByteInt(long index, int offset, int 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, (short) value);
        cursor.putByte(offset + Short.BYTES, (byte) (value >>> Short.SIZE));
        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)

Example 32 with CursorContext

use of org.neo4j.io.pagecache.context.CursorContext in project neo4j by neo4j.

the class PageCacheNumberArray method setDefaultValue.

protected void setDefaultValue(long defaultValue) throws IOException {
    try (CursorContext cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer(PAGE_CACHE_WORKER_TAG));
        PageCursor writeCursor = pagedFile.io(0, PF_SHARED_WRITE_LOCK | PF_NO_GROW, cursorContext)) {
        writeCursor.next();
        int pageSize = pagedFile.pageSize();
        fillPageWithDefaultValue(writeCursor, defaultValue, pageSize);
        if (pageId(length - 1) > 0) {
            try (PageCursor cursor = pagedFile.io(1, PF_NO_GROW | PF_SHARED_WRITE_LOCK, cursorContext)) {
                while (cursor.next()) {
                    writeCursor.copyTo(0, cursor, 0, pageSize);
                    checkBounds(writeCursor);
                }
            }
        }
    }
}
Also used : CursorContext(org.neo4j.io.pagecache.context.CursorContext) PageCursor(org.neo4j.io.pagecache.PageCursor)

Example 33 with CursorContext

use of org.neo4j.io.pagecache.context.CursorContext in project neo4j by neo4j.

the class PageCacheIntArray method set.

@Override
public void set(long index, int value) {
    long pageId = pageId(index);
    int offset = offset(index);
    try (CursorContext cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer(PAGE_CACHE_INT_ARRAY_WORKER_TAG));
        PageCursor cursor = pagedFile.io(pageId, PF_SHARED_WRITE_LOCK | PF_NO_GROW, cursorContext)) {
        cursor.next();
        cursor.putInt(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)

Example 34 with CursorContext

use of org.neo4j.io.pagecache.context.CursorContext in project neo4j by neo4j.

the class PageCacheIntArray method get.

@Override
public int get(long index) {
    long pageId = pageId(index);
    int offset = offset(index);
    try (CursorContext cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer(PAGE_CACHE_INT_ARRAY_WORKER_TAG));
        PageCursor cursor = pagedFile.io(pageId, PF_SHARED_READ_LOCK, cursorContext)) {
        cursor.next();
        int result;
        do {
            result = cursor.getInt(offset);
        } while (cursor.shouldRetry());
        checkBounds(cursor);
        return result;
    } 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)

Example 35 with CursorContext

use of org.neo4j.io.pagecache.context.CursorContext in project neo4j by neo4j.

the class LogFilesBuilder method readOnlyLogVersionRepository.

private LogVersionRepository readOnlyLogVersionRepository() throws IOException {
    StorageEngineFactory storageEngineFactory = StorageEngineFactory.defaultStorageEngine();
    var pageCacheTracer = databaseTracers.getPageCacheTracer();
    try (var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer(READ_ONLY_LOG_VERSION_READER_TAG))) {
        return storageEngineFactory.readOnlyLogVersionRepository(databaseLayout, pageCache, cursorContext);
    }
}
Also used : StorageEngineFactory(org.neo4j.storageengine.api.StorageEngineFactory) CursorContext(org.neo4j.io.pagecache.context.CursorContext)

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