use of org.neo4j.io.pagecache.context.CursorContext in project neo4j by neo4j.
the class PageCacheByteArray method setByte.
@Override
public void setByte(long index, int offset, byte 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.putByte(offset, value);
checkBounds(cursor);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
use of org.neo4j.io.pagecache.context.CursorContext in project neo4j by neo4j.
the class PageCacheByteArray method set6ByteLong.
@Override
public void set6ByteLong(long index, int offset, long 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.putInt(offset, (int) value);
cursor.putShort(offset + Integer.BYTES, (short) (value >>> Integer.SIZE));
checkBounds(cursor);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
use of org.neo4j.io.pagecache.context.CursorContext in project neo4j by neo4j.
the class PageCacheByteArray method getByte.
@Override
public byte getByte(long index, int offset) {
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_READ_LOCK, cursorContext)) {
cursor.next();
byte result;
do {
result = cursor.getByte(offset);
} while (cursor.shouldRetry());
checkBounds(cursor);
return result;
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
use of org.neo4j.io.pagecache.context.CursorContext in project neo4j by neo4j.
the class PageCacheByteArray method get6ByteLong.
@Override
public long get6ByteLong(long index, int offset) {
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_READ_LOCK, cursorContext)) {
cursor.next();
long result;
do {
long low4b = cursor.getInt(offset) & 0xFFFFFFFFL;
long high2b = cursor.getShort(offset + Integer.BYTES) & 0xFFFF;
result = low4b | (high2b << Integer.SIZE);
} while (cursor.shouldRetry());
checkBounds(cursor);
return result == 0xFFFFFFFFFFFFL ? -1 : result;
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
use of org.neo4j.io.pagecache.context.CursorContext in project neo4j by neo4j.
the class PageCacheByteArray method swap.
@Override
public void swap(long fromIndex, long toIndex) {
long fromPageId = pageId(fromIndex);
int fromOffset = offset(fromIndex);
long toPageId = pageId(toIndex);
int toOffset = offset(toIndex);
try (CursorContext cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer(PAGE_CACHE_BYTE_ARRAY_WORKER_TAG));
PageCursor fromCursor = pagedFile.io(fromPageId, PF_SHARED_WRITE_LOCK, cursorContext);
PageCursor toCursor = pagedFile.io(toPageId, PF_SHARED_WRITE_LOCK, cursorContext)) {
fromCursor.next();
toCursor.next();
for (int i = 0; i < entrySize; i++, fromOffset++, toOffset++) {
byte intermediary = fromCursor.getByte(fromOffset);
fromCursor.putByte(fromOffset, toCursor.getByte(toOffset));
toCursor.putByte(toOffset, intermediary);
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
Aggregations