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);
}
}
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();
}
}
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);
}
}
Aggregations