Search in sources :

Example 1 with SingleRowCursor

use of org.h2.index.SingleRowCursor in project ignite by apache.

the class H2TreeIndex method findFirstOrLast.

/** {@inheritDoc} */
@Override
public Cursor findFirstOrLast(Session session, boolean b) {
    try {
        int seg = threadLocalSegment();
        H2Tree tree = treeForRead(seg);
        GridH2Row row = b ? tree.findFirst() : tree.findLast();
        return new SingleRowCursor(row);
    } catch (IgniteCheckedException e) {
        throw DbException.convert(e);
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridH2Row(org.apache.ignite.internal.processors.query.h2.opt.GridH2Row) SingleRowCursor(org.h2.index.SingleRowCursor)

Example 2 with SingleRowCursor

use of org.h2.index.SingleRowCursor in project ignite by apache.

the class GridH2SpatialIndex method findFirstOrLast.

/** {@inheritDoc} */
@Override
public Cursor findFirstOrLast(Session ses, boolean first) {
    Lock l = lock.readLock();
    l.lock();
    try {
        checkClosed();
        if (!first)
            throw DbException.throwInternalError("Spatial Index can only be fetch by ascending order");
        final int seg = threadLocalSegment();
        final MVRTreeMap<Long> segment = segments[seg];
        GridCursor<GridH2Row> iter = rowIterator(segment.keySet().iterator(), null);
        return new SingleRowCursor(iter.next() ? iter.get() : null);
    } catch (IgniteCheckedException e) {
        throw DbException.convert(e);
    } finally {
        l.unlock();
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) SingleRowCursor(org.h2.index.SingleRowCursor) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) ReadWriteLock(java.util.concurrent.locks.ReadWriteLock) Lock(java.util.concurrent.locks.Lock)

Example 3 with SingleRowCursor

use of org.h2.index.SingleRowCursor in project ignite by apache.

the class GridH2TreeIndex method findFirstOrLast.

/** {@inheritDoc} */
@Override
public Cursor findFirstOrLast(Session ses, boolean first) {
    try {
        int seg = threadLocalSegment();
        IgniteTree t = treeForRead(seg);
        GridH2Row row = (GridH2Row) (first ? t.findFirst() : t.findLast());
        return new SingleRowCursor(row);
    } catch (IgniteCheckedException e) {
        throw DbException.convert(e);
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteTree(org.apache.ignite.internal.util.IgniteTree) SingleRowCursor(org.h2.index.SingleRowCursor)

Aggregations

IgniteCheckedException (org.apache.ignite.IgniteCheckedException)3 SingleRowCursor (org.h2.index.SingleRowCursor)3 Lock (java.util.concurrent.locks.Lock)1 ReadWriteLock (java.util.concurrent.locks.ReadWriteLock)1 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)1 GridH2Row (org.apache.ignite.internal.processors.query.h2.opt.GridH2Row)1 IgniteTree (org.apache.ignite.internal.util.IgniteTree)1