Search in sources :

Example 16 with IndexRow

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

the class H2TreeIndex method findForSegment.

/**
 * Find rows for the segments (distributed joins).
 *
 * @param bounds Bounds.
 * @param segment Segment.
 * @param qryCtx Index query context.
 * @return Iterator.
 */
public Iterator<H2Row> findForSegment(GridH2RowRangeBounds bounds, int segment, IndexQueryContext qryCtx) {
    SearchRow lower = toSearchRow(bounds.first());
    SearchRow upper = toSearchRow(bounds.last());
    T2<IndexRow, IndexRow> key = prepareIndexKeys(lower, upper);
    try {
        GridCursor<IndexRow> range = queryIndex.find(key.get1(), key.get2(), true, true, segment, qryCtx);
        if (range == null)
            range = IndexValueCursor.EMPTY;
        GridCursor<H2Row> h2cursor = new IndexValueCursor<>(range, this::mapIndexRow);
        H2Cursor cur = new H2Cursor(h2cursor);
        return new CursorIteratorWrapper(cur);
    } catch (IgniteCheckedException e) {
        throw DbException.convert(e);
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IndexRow(org.apache.ignite.internal.cache.query.index.sorted.IndexRow) H2Cursor(org.apache.ignite.internal.processors.query.h2.H2Cursor) CursorIteratorWrapper(org.apache.ignite.internal.processors.query.h2.opt.join.CursorIteratorWrapper) SearchRow(org.h2.result.SearchRow) H2Row(org.apache.ignite.internal.processors.query.h2.opt.H2Row) IndexValueCursor(org.apache.ignite.internal.cache.query.index.sorted.IndexValueCursor)

Example 17 with IndexRow

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

the class H2TreeIndex method find.

/**
 * {@inheritDoc}
 */
@Override
public Cursor find(Session ses, SearchRow lower, SearchRow upper) {
    assert lower == null || lower instanceof H2Row : lower;
    assert upper == null || upper instanceof H2Row : upper;
    try {
        T2<IndexRow, IndexRow> key = prepareIndexKeys(lower, upper);
        QueryContext qctx = ses != null ? H2Utils.context(ses) : null;
        GridCursor<IndexRow> cursor = queryIndex.find(key.get1(), key.get2(), true, true, segment(qctx), idxQryContext(qctx));
        GridCursor<H2Row> h2cursor = new IndexValueCursor<>(cursor, this::mapIndexRow);
        return new H2Cursor(h2cursor);
    } catch (IgniteCheckedException e) {
        throw DbException.convert(e);
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IndexRow(org.apache.ignite.internal.cache.query.index.sorted.IndexRow) H2Cursor(org.apache.ignite.internal.processors.query.h2.H2Cursor) IndexQueryContext(org.apache.ignite.internal.cache.query.index.sorted.inline.IndexQueryContext) QueryContext(org.apache.ignite.internal.processors.query.h2.opt.QueryContext) H2Row(org.apache.ignite.internal.processors.query.h2.opt.H2Row) IndexValueCursor(org.apache.ignite.internal.cache.query.index.sorted.IndexValueCursor)

Aggregations

IndexRow (org.apache.ignite.internal.cache.query.index.sorted.IndexRow)17 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)6 H2Cursor (org.apache.ignite.internal.processors.query.h2.H2Cursor)4 SingleCursor (org.apache.ignite.internal.cache.query.index.SingleCursor)3 IndexKeyDefinition (org.apache.ignite.internal.cache.query.index.sorted.IndexKeyDefinition)3 IndexValueCursor (org.apache.ignite.internal.cache.query.index.sorted.IndexValueCursor)3 SortedIndexDefinition (org.apache.ignite.internal.cache.query.index.sorted.SortedIndexDefinition)3 IndexQueryContext (org.apache.ignite.internal.cache.query.index.sorted.inline.IndexQueryContext)3 FailureContext (org.apache.ignite.failure.FailureContext)2 CacheDataRow (org.apache.ignite.internal.processors.cache.persistence.CacheDataRow)2 H2Row (org.apache.ignite.internal.processors.query.h2.opt.H2Row)2 QueryContext (org.apache.ignite.internal.processors.query.h2.opt.QueryContext)2 ArrayList (java.util.ArrayList)1 NoSuchElementException (java.util.NoSuchElementException)1 Lock (java.util.concurrent.locks.Lock)1 ReadWriteLock (java.util.concurrent.locks.ReadWriteLock)1 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)1 IgniteException (org.apache.ignite.IgniteException)1 IndexKeyTypeSettings (org.apache.ignite.internal.cache.query.index.sorted.IndexKeyTypeSettings)1 IndexRowImpl (org.apache.ignite.internal.cache.query.index.sorted.IndexRowImpl)1