Search in sources :

Example 1 with SingleCursor

use of org.apache.ignite.internal.cache.query.index.SingleCursor in project ignite by apache.

the class InlineIndexImpl method findLast.

/**
 * {@inheritDoc}
 */
@Override
public GridCursor<IndexRow> findLast(int segment, IndexQueryContext qryCtx) throws IgniteCheckedException {
    InlineTreeFilterClosure closure = filterClosure(qryCtx);
    IndexRow found = segments[segment].findLast(closure);
    if (found == null || isExpired(found))
        return IndexValueCursor.EMPTY;
    return new SingleCursor<>(found);
}
Also used : SingleCursor(org.apache.ignite.internal.cache.query.index.SingleCursor) IndexRow(org.apache.ignite.internal.cache.query.index.sorted.IndexRow)

Example 2 with SingleCursor

use of org.apache.ignite.internal.cache.query.index.SingleCursor in project ignite by apache.

the class InlineIndexImpl method findFirst.

/**
 * {@inheritDoc}
 */
@Override
public GridCursor<IndexRow> findFirst(int segment, IndexQueryContext qryCtx) throws IgniteCheckedException {
    InlineTreeFilterClosure closure = filterClosure(qryCtx);
    IndexRow found = segments[segment].findFirst(closure);
    if (found == null || isExpired(found))
        return IndexValueCursor.EMPTY;
    return new SingleCursor<>(found);
}
Also used : SingleCursor(org.apache.ignite.internal.cache.query.index.SingleCursor) IndexRow(org.apache.ignite.internal.cache.query.index.sorted.IndexRow)

Example 3 with SingleCursor

use of org.apache.ignite.internal.cache.query.index.SingleCursor in project ignite by apache.

the class GeoSpatialIndexImpl method findFirstOrLast.

/**
 * {@inheritDoc}
 */
@Override
public GridCursor<IndexRow> findFirstOrLast(int seg, 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 MVRTreeMap<Long> segment = segments[seg];
        GridCursor<IndexRow> iter = rowIterator(segment.keySet().iterator(), null);
        return new SingleCursor<>(iter.next() ? iter.get() : null);
    } catch (IgniteCheckedException e) {
        throw DbException.convert(e);
    } finally {
        l.unlock();
    }
}
Also used : SingleCursor(org.apache.ignite.internal.cache.query.index.SingleCursor) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IndexRow(org.apache.ignite.internal.cache.query.index.sorted.IndexRow) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) ReadWriteLock(java.util.concurrent.locks.ReadWriteLock) Lock(java.util.concurrent.locks.Lock)

Aggregations

SingleCursor (org.apache.ignite.internal.cache.query.index.SingleCursor)3 IndexRow (org.apache.ignite.internal.cache.query.index.sorted.IndexRow)3 Lock (java.util.concurrent.locks.Lock)1 ReadWriteLock (java.util.concurrent.locks.ReadWriteLock)1 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1