use of org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory in project ignite by apache.
the class GridH2KeyValueRowOffheap method getOffheapValue.
/** {@inheritDoc} */
@SuppressWarnings("LockAcquiredButNotSafelyReleased")
@Override
protected Value getOffheapValue(int col) {
GridUnsafeMemory mem = desc.memory();
long p = ptr;
assert p > 0 : p;
byte[] bytes = null;
if (col == KEY_COL) {
int size = mem.readInt(p + OFFSET_KEY_SIZE);
assert size > 0 : size;
bytes = mem.readBytes(p + OFFSET_KEY, size);
} else if (col == VAL_COL) {
Lock l = lock(p);
desc.guard().begin();
try {
long valPtr = mem.readLongVolatile(p + OFFSET_VALUE_REF);
if (// Value was evicted.
valPtr == 0)
return null;
int size = mem.readInt(valPtr);
assert size > 0 : size;
bytes = mem.readBytes(valPtr + OFFSET_VALUE, size);
} finally {
desc.guard().end();
l.unlock();
}
} else
throw new IllegalStateException("Column: " + col);
Data data = Data.create(null, bytes);
return data.readValue();
}
Aggregations