Search in sources :

Example 6 with IndexingQueryFilter

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

the class H2TreeIndex method find.

/** {@inheritDoc} */
@Override
public Cursor find(Session ses, SearchRow lower, SearchRow upper) {
    try {
        IndexingQueryFilter f = threadLocalFilter();
        IgniteBiPredicate<Object, Object> p = null;
        if (f != null) {
            String cacheName = getTable().cacheName();
            p = f.forCache(cacheName);
        }
        int seg = threadLocalSegment();
        H2Tree tree = treeForRead(seg);
        return new H2Cursor(tree.find(lower, upper), p);
    } catch (IgniteCheckedException e) {
        throw DbException.convert(e);
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IndexingQueryFilter(org.apache.ignite.spi.indexing.IndexingQueryFilter) H2Cursor(org.apache.ignite.internal.processors.query.h2.H2Cursor)

Example 7 with IndexingQueryFilter

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

the class GridQueryProcessor method querySqlFields.

/**
     * Query SQL fields.
     *
     * @param cctx Cache context.
     * @param qry Query.
     * @param keepBinary Keep binary flag.
     * @return Cursor.
     */
@SuppressWarnings("unchecked")
public FieldsQueryCursor<List<?>> querySqlFields(final GridCacheContext<?, ?> cctx, final SqlFieldsQuery qry, final boolean keepBinary) {
    checkxEnabled();
    validateSqlFieldsQuery(qry);
    boolean loc = (qry.isReplicatedOnly() && cctx.isReplicatedAffinityNode()) || cctx.isLocal() || qry.isLocal();
    if (!busyLock.enterBusy())
        throw new IllegalStateException("Failed to execute query (grid is stopping).");
    try {
        final String schemaName = qry.getSchema() != null ? qry.getSchema() : idx.schema(cctx.name());
        final int mainCacheId = CU.cacheId(cctx.name());
        IgniteOutClosureX<FieldsQueryCursor<List<?>>> clo;
        if (loc) {
            clo = new IgniteOutClosureX<FieldsQueryCursor<List<?>>>() {

                @Override
                public FieldsQueryCursor<List<?>> applyx() throws IgniteCheckedException {
                    GridQueryCancel cancel = new GridQueryCancel();
                    FieldsQueryCursor<List<?>> cur;
                    if (cctx.config().getQueryParallelism() > 1) {
                        qry.setDistributedJoins(true);
                        cur = idx.queryDistributedSqlFields(schemaName, qry, keepBinary, cancel, mainCacheId);
                    } else {
                        IndexingQueryFilter filter = idx.backupFilter(requestTopVer.get(), qry.getPartitions());
                        cur = idx.queryLocalSqlFields(schemaName, qry, keepBinary, filter, cancel);
                    }
                    sendQueryExecutedEvent(qry.getSql(), qry.getArgs(), cctx.name());
                    return cur;
                }
            };
        } else {
            clo = new IgniteOutClosureX<FieldsQueryCursor<List<?>>>() {

                @Override
                public FieldsQueryCursor<List<?>> applyx() throws IgniteCheckedException {
                    return idx.queryDistributedSqlFields(schemaName, qry, keepBinary, null, mainCacheId);
                }
            };
        }
        return executeQuery(GridCacheQueryType.SQL_FIELDS, qry.getSql(), cctx, clo, true);
    } catch (IgniteCheckedException e) {
        throw new CacheException(e);
    } finally {
        busyLock.leaveBusy();
    }
}
Also used : FieldsQueryCursor(org.apache.ignite.cache.query.FieldsQueryCursor) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) CacheException(javax.cache.CacheException) IndexingQueryFilter(org.apache.ignite.spi.indexing.IndexingQueryFilter)

Aggregations

IndexingQueryFilter (org.apache.ignite.spi.indexing.IndexingQueryFilter)7 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)5 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)3 CacheObject (org.apache.ignite.internal.processors.cache.CacheObject)2 IgniteBiPredicate (org.apache.ignite.lang.IgniteBiPredicate)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 CacheException (javax.cache.CacheException)1 IgniteSystemProperties.getString (org.apache.ignite.IgniteSystemProperties.getString)1 FieldsQueryCursor (org.apache.ignite.cache.query.FieldsQueryCursor)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1 GridKernalContext (org.apache.ignite.internal.GridKernalContext)1 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)1 GridCacheAffinityManager (org.apache.ignite.internal.processors.cache.GridCacheAffinityManager)1 IgniteCacheOffheapManager (org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManager)1 CacheDataRow (org.apache.ignite.internal.processors.cache.database.CacheDataRow)1 H2Cursor (org.apache.ignite.internal.processors.query.h2.H2Cursor)1 GridCursor (org.apache.ignite.internal.util.lang.GridCursor)1 IndexReader (org.apache.lucene.index.IndexReader)1 MultiFieldQueryParser (org.apache.lucene.queryParser.MultiFieldQueryParser)1