Search in sources :

Example 11 with GridUnsafeMemory

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();
}
Also used : Data(org.h2.store.Data) GridUnsafeMemory(org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory) GridStripedLock(org.apache.ignite.internal.util.GridStripedLock) Lock(java.util.concurrent.locks.Lock)

Aggregations

GridUnsafeMemory (org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory)11 Random (java.util.Random)5 IntWritable (org.apache.hadoop.io.IntWritable)5 HadoopTaskContext (org.apache.ignite.internal.processors.hadoop.HadoopTaskContext)5 HadoopJobInfo (org.apache.ignite.internal.processors.hadoop.HadoopJobInfo)4 GridRandom (org.apache.ignite.internal.util.GridRandom)4 HadoopMultimap (org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopMultimap)3 IOException (java.io.IOException)2 Collection (java.util.Collection)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)2 HadoopTaskInput (org.apache.ignite.internal.processors.hadoop.HadoopTaskInput)2 HadoopConcurrentHashMultimap (org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopConcurrentHashMultimap)2 HadoopSkipList (org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopSkipList)2 HadoopDataInStream (org.apache.ignite.internal.processors.hadoop.shuffle.streams.HadoopDataInStream)2 HadoopDataOutStream (org.apache.ignite.internal.processors.hadoop.shuffle.streams.HadoopDataOutStream)2 Data (org.h2.store.Data)2 Lock (java.util.concurrent.locks.Lock)1 HadoopHashMultimap (org.apache.ignite.internal.processors.hadoop.shuffle.collections.HadoopHashMultimap)1 GridStripedLock (org.apache.ignite.internal.util.GridStripedLock)1