Search in sources :

Example 1 with H2Cursor

use of org.apache.ignite.internal.processors.query.h2.H2Cursor in project ignite by apache.

the class GridH2SpatialIndex method find0.

/**
 * @param filter Table filter.
 * @return Cursor.
 */
private Cursor find0(TableFilter filter) {
    Lock l = lock.readLock();
    l.lock();
    try {
        checkClosed();
        final int seg = threadLocalSegment();
        final MVRTreeMap<Long> segment = segments[seg];
        return new H2Cursor(rowIterator(segment.keySet().iterator(), filter));
    } finally {
        l.unlock();
    }
}
Also used : H2Cursor(org.apache.ignite.internal.processors.query.h2.H2Cursor) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) ReadWriteLock(java.util.concurrent.locks.ReadWriteLock) Lock(java.util.concurrent.locks.Lock)

Example 2 with H2Cursor

use of org.apache.ignite.internal.processors.query.h2.H2Cursor in project ignite by apache.

the class H2TreeIndex method findFirstOrLast.

/**
 * {@inheritDoc}
 */
@Override
public Cursor findFirstOrLast(Session ses, boolean b) {
    try {
        QueryContext qctx = H2Utils.context(ses);
        IndexQueryContext qryCtx = idxQryContext(qctx);
        GridCursor<IndexRow> cursor = b ? queryIndex.findFirst(segment(qctx), qryCtx) : queryIndex.findLast(segment(qctx), qryCtx);
        return new H2Cursor(new IndexValueCursor<>(cursor, this::mapIndexRow));
    } catch (IgniteCheckedException e) {
        throw DbException.convert(e);
    }
}
Also used : IndexQueryContext(org.apache.ignite.internal.cache.query.index.sorted.inline.IndexQueryContext) 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)

Example 3 with H2Cursor

use of org.apache.ignite.internal.processors.query.h2.H2Cursor in project ignite by apache.

the class H2TreeIndex method doFind0.

/**
 * {@inheritDoc}
 */
@Override
protected H2Cursor doFind0(IgniteTree t, @Nullable SearchRow first, boolean includeFirst, @Nullable SearchRow last, IndexingQueryFilter filter) {
    try {
        IndexingQueryCacheFilter pf = partitionFilter(filter);
        GridCursor<GridH2Row> range = t.find(first, last, pf);
        if (range == null)
            range = GridH2IndexBase.EMPTY_CURSOR;
        return new H2Cursor(range);
    } catch (IgniteCheckedException e) {
        throw DbException.convert(e);
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) H2Cursor(org.apache.ignite.internal.processors.query.h2.H2Cursor) GridH2Row(org.apache.ignite.internal.processors.query.h2.opt.GridH2Row) IndexingQueryCacheFilter(org.apache.ignite.spi.indexing.IndexingQueryCacheFilter)

Example 4 with H2Cursor

use of org.apache.ignite.internal.processors.query.h2.H2Cursor in project ignite by apache.

the class GridH2SpatialIndex method findByGeometry.

/**
 * {@inheritDoc}
 */
@Override
public Cursor findByGeometry(TableFilter filter, SearchRow first, SearchRow last, SearchRow intersection) {
    Value v = intersection.getValue(columnIds[0]);
    Geometry g = ((ValueGeometry) v.convertTo(Value.GEOMETRY)).getGeometry();
    int seg = segmentsCount() == 1 ? 0 : H2Utils.context(filter.getSession()).segment();
    GridCursor<IndexRow> cursor = delegate.findByGeometry(seg, filter, g);
    GridCursor<H2Row> h2cursor = new IndexValueCursor<>(cursor, this::mapIndexRow);
    return new H2Cursor(h2cursor);
}
Also used : ValueGeometry(org.h2.value.ValueGeometry) Geometry(org.locationtech.jts.geom.Geometry) ValueGeometry(org.h2.value.ValueGeometry) IndexRow(org.apache.ignite.internal.cache.query.index.sorted.IndexRow) H2Cursor(org.apache.ignite.internal.processors.query.h2.H2Cursor) Value(org.h2.value.Value) IndexValueCursor(org.apache.ignite.internal.cache.query.index.sorted.IndexValueCursor)

Example 5 with H2Cursor

use of org.apache.ignite.internal.processors.query.h2.H2Cursor 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)

Aggregations

H2Cursor (org.apache.ignite.internal.processors.query.h2.H2Cursor)6 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4 IndexRow (org.apache.ignite.internal.cache.query.index.sorted.IndexRow)4 IndexValueCursor (org.apache.ignite.internal.cache.query.index.sorted.IndexValueCursor)3 IndexQueryContext (org.apache.ignite.internal.cache.query.index.sorted.inline.IndexQueryContext)2 H2Row (org.apache.ignite.internal.processors.query.h2.opt.H2Row)2 QueryContext (org.apache.ignite.internal.processors.query.h2.opt.QueryContext)2 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 CursorIteratorWrapper (org.apache.ignite.internal.processors.query.h2.opt.join.CursorIteratorWrapper)1 IndexingQueryCacheFilter (org.apache.ignite.spi.indexing.IndexingQueryCacheFilter)1 SearchRow (org.h2.result.SearchRow)1 Value (org.h2.value.Value)1 ValueGeometry (org.h2.value.ValueGeometry)1 Geometry (org.locationtech.jts.geom.Geometry)1