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);
}
}
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();
}
}
Aggregations