use of org.apache.ignite.internal.processors.cache.mvcc.StaticMvccQueryTracker in project ignite by apache.
the class IgniteH2Indexing method executeUpdateOnDataNodeTransactional.
/**
* {@inheritDoc}
*/
@Override
public UpdateSourceIterator<?> executeUpdateOnDataNodeTransactional(GridCacheContext<?, ?> cctx, int[] ids, int[] parts, String schema, String qry, Object[] params, int flags, int pageSize, int timeout, AffinityTopologyVersion topVer, MvccSnapshot mvccSnapshot, GridQueryCancel cancel) throws IgniteCheckedException {
SqlFieldsQuery fldsQry = QueryUtils.withQueryTimeout(new SqlFieldsQuery(qry), timeout, TimeUnit.MILLISECONDS);
if (params != null)
fldsQry.setArgs(params);
fldsQry.setEnforceJoinOrder(U.isFlagSet(flags, GridH2QueryRequest.FLAG_ENFORCE_JOIN_ORDER));
fldsQry.setTimeout(timeout, TimeUnit.MILLISECONDS);
fldsQry.setPageSize(pageSize);
fldsQry.setLocal(true);
fldsQry.setLazy(U.isFlagSet(flags, GridH2QueryRequest.FLAG_LAZY));
boolean loc = true;
final boolean replicated = U.isFlagSet(flags, GridH2QueryRequest.FLAG_REPLICATED);
GridCacheContext<?, ?> cctx0;
if (!replicated && !F.isEmpty(ids) && (cctx0 = CU.firstPartitioned(cctx.shared(), ids)) != null && cctx0.config().getQueryParallelism() > 1) {
fldsQry.setDistributedJoins(true);
loc = false;
}
QueryParserResult parseRes = parser.parse(schema, fldsQry, false);
assert parseRes.remainingQuery() == null;
QueryParserResultDml dml = parseRes.dml();
assert dml != null;
IndexingQueryFilter filter = backupFilter(topVer, parts);
UpdatePlan plan = dml.plan();
GridCacheContext planCctx = plan.cacheContext();
// Force keepBinary for operation context to avoid binary deserialization inside entry processor
DmlUtils.setKeepBinaryContext(planCctx);
SqlFieldsQuery selectFieldsQry = QueryUtils.withQueryTimeout(new SqlFieldsQuery(plan.selectQuery(), fldsQry.isCollocated()), fldsQry.getTimeout(), TimeUnit.MILLISECONDS).setArgs(fldsQry.getArgs()).setDistributedJoins(fldsQry.isDistributedJoins()).setEnforceJoinOrder(fldsQry.isEnforceJoinOrder()).setLocal(fldsQry.isLocal()).setPageSize(fldsQry.getPageSize()).setTimeout(fldsQry.getTimeout(), TimeUnit.MILLISECONDS).setLazy(fldsQry.isLazy());
QueryCursorImpl<List<?>> cur;
// sub-query and not some dummy stuff like "select 1, 2, 3;"
if (!loc && !plan.isLocalSubquery()) {
cur = executeSelectForDml(RunningQueryManager.UNDEFINED_QUERY_ID, schema, selectFieldsQry, new StaticMvccQueryTracker(planCctx, mvccSnapshot), cancel, timeout);
} else {
selectFieldsQry.setLocal(true);
QueryParserResult selectParseRes = parser.parse(schema, selectFieldsQry, false);
GridQueryFieldsResult res = executeSelectLocal(RunningQueryManager.UNDEFINED_QUERY_ID, selectParseRes.queryDescriptor(), selectParseRes.queryParameters(), selectParseRes.select(), filter, new StaticMvccQueryTracker(planCctx, mvccSnapshot), cancel, true, timeout);
cur = new QueryCursorImpl<>(new Iterable<List<?>>() {
@Override
public Iterator<List<?>> iterator() {
try {
return res.iterator();
} catch (IgniteCheckedException e) {
throw new IgniteException(e);
}
}
}, cancel, true, selectParseRes.queryParameters().lazy());
}
return plan.iteratorForTransaction(connMgr, cur);
}
Aggregations