Search in sources :

Example 1 with IndexingQueryCacheFilter

use of org.apache.ignite.spi.indexing.IndexingQueryCacheFilter in project ignite by apache.

the class H2PkHashIndex method find.

/**
 * {@inheritDoc}
 */
@Override
public Cursor find(Session ses, final SearchRow lower, final SearchRow upper) {
    IndexingQueryFilter f = threadLocalFilter();
    IndexingQueryCacheFilter p = null;
    if (f != null) {
        String cacheName = getTable().cacheName();
        p = f.forCache(cacheName);
    }
    KeyCacheObject lowerObj = null;
    KeyCacheObject upperObj = null;
    if (lower != null)
        lowerObj = cctx.toCacheKeyObject(lower.getValue(0).getObject());
    if (upper != null)
        upperObj = cctx.toCacheKeyObject(upper.getValue(0).getObject());
    try {
        List<GridCursor<? extends CacheDataRow>> cursors = new ArrayList<>();
        for (IgniteCacheOffheapManager.CacheDataStore store : cctx.offheap().cacheDataStores()) cursors.add(store.cursor(cctx.cacheId(), lowerObj, upperObj));
        return new H2Cursor(new CompositeGridCursor<>(cursors.iterator()), p);
    } catch (IgniteCheckedException e) {
        throw DbException.convert(e);
    }
}
Also used : CacheDataRow(org.apache.ignite.internal.processors.cache.persistence.CacheDataRow) GridCursor(org.apache.ignite.internal.util.lang.GridCursor) IndexingQueryFilter(org.apache.ignite.spi.indexing.IndexingQueryFilter) ArrayList(java.util.ArrayList) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteCacheOffheapManager(org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManager) IndexingQueryCacheFilter(org.apache.ignite.spi.indexing.IndexingQueryCacheFilter) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject)

Example 2 with IndexingQueryCacheFilter

use of org.apache.ignite.spi.indexing.IndexingQueryCacheFilter in project ignite by apache.

the class H2Tree method getRow.

/**
 * {@inheritDoc}
 */
@Override
protected GridH2Row getRow(BPlusIO<SearchRow> io, long pageAddr, int idx, Object filter) throws IgniteCheckedException {
    if (filter != null) {
        // Filter out not interesting partitions without deserializing the row.
        IndexingQueryCacheFilter filter0 = (IndexingQueryCacheFilter) filter;
        long link = ((H2RowLinkIO) io).getLink(pageAddr, idx);
        int part = PageIdUtils.partId(PageIdUtils.pageId(link));
        if (!filter0.applyPartition(part))
            return null;
    }
    return (GridH2Row) io.getLookupRow(this, pageAddr, idx);
}
Also used : GridH2Row(org.apache.ignite.internal.processors.query.h2.opt.GridH2Row) H2RowLinkIO(org.apache.ignite.internal.processors.query.h2.database.io.H2RowLinkIO) IndexingQueryCacheFilter(org.apache.ignite.spi.indexing.IndexingQueryCacheFilter)

Example 3 with IndexingQueryCacheFilter

use of org.apache.ignite.spi.indexing.IndexingQueryCacheFilter in project ignite by apache.

the class H2TreeIndex method find.

/**
 * {@inheritDoc}
 */
@Override
public Cursor find(Session ses, SearchRow lower, SearchRow upper) {
    try {
        IndexingQueryCacheFilter filter = partitionFilter(threadLocalFilter());
        int seg = threadLocalSegment();
        H2Tree tree = treeForRead(seg);
        if (indexType.isPrimaryKey() && lower != null && upper != null && tree.compareRows(lower, upper) == 0) {
            GridH2Row row = tree.findOne(lower, filter);
            return (row == null) ? EMPTY_CURSOR : new SingleRowCursor(row);
        } else {
            GridCursor<GridH2Row> cursor = tree.find(lower, upper, filter);
            return new H2Cursor(cursor);
        }
    } 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) SingleRowCursor(org.h2.index.SingleRowCursor)

Example 4 with IndexingQueryCacheFilter

use of org.apache.ignite.spi.indexing.IndexingQueryCacheFilter 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 5 with IndexingQueryCacheFilter

use of org.apache.ignite.spi.indexing.IndexingQueryCacheFilter in project ignite by apache.

the class GridH2SpatialIndex method rowIterator.

/**
 * @param i Spatial key iterator.
 * @param filter Table filter.
 * @return Iterator over rows.
 */
@SuppressWarnings("unchecked")
private GridCursor<GridH2Row> rowIterator(Iterator<SpatialKey> i, TableFilter filter) {
    if (!i.hasNext())
        return EMPTY_CURSOR;
    long time = System.currentTimeMillis();
    IndexingQueryFilter qryFilter = threadLocalFilter();
    IndexingQueryCacheFilter qryCacheFilter = qryFilter != null ? qryFilter.forCache(getTable().cacheName()) : null;
    List<GridH2Row> rows = new ArrayList<>();
    do {
        GridH2Row row = idToRow.get(i.next().getId());
        assert row != null;
        if (row.expireTime() != 0 && row.expireTime() <= time)
            continue;
        if (qryCacheFilter == null || qryCacheFilter.applyPartition(row.partition()))
            rows.add(row);
    } while (i.hasNext());
    return new GridCursorIteratorWrapper(rows.iterator());
}
Also used : IndexingQueryFilter(org.apache.ignite.spi.indexing.IndexingQueryFilter) ArrayList(java.util.ArrayList) GridCursorIteratorWrapper(org.apache.ignite.internal.util.GridCursorIteratorWrapper) IndexingQueryCacheFilter(org.apache.ignite.spi.indexing.IndexingQueryCacheFilter)

Aggregations

IndexingQueryCacheFilter (org.apache.ignite.spi.indexing.IndexingQueryCacheFilter)6 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4 GridH2Row (org.apache.ignite.internal.processors.query.h2.opt.GridH2Row)3 ArrayList (java.util.ArrayList)2 H2Cursor (org.apache.ignite.internal.processors.query.h2.H2Cursor)2 IndexingQueryFilter (org.apache.ignite.spi.indexing.IndexingQueryFilter)2 IOException (java.io.IOException)1 IgniteCacheOffheapManager (org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManager)1 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)1 CacheDataRow (org.apache.ignite.internal.processors.cache.persistence.CacheDataRow)1 H2RowLinkIO (org.apache.ignite.internal.processors.query.h2.database.io.H2RowLinkIO)1 GridCursorIteratorWrapper (org.apache.ignite.internal.util.GridCursorIteratorWrapper)1 GridCursor (org.apache.ignite.internal.util.lang.GridCursor)1 IndexReader (org.apache.lucene.index.IndexReader)1 MultiFieldQueryParser (org.apache.lucene.queryparser.classic.MultiFieldQueryParser)1 BooleanQuery (org.apache.lucene.search.BooleanQuery)1 IndexSearcher (org.apache.lucene.search.IndexSearcher)1 NumericRangeQuery (org.apache.lucene.search.NumericRangeQuery)1 Query (org.apache.lucene.search.Query)1 TopDocs (org.apache.lucene.search.TopDocs)1