/** * Checks whether query flags are compatible with server side update. * * @param qry Query. * @return {@code true} if update can be distributed. */ public static boolean isSkipReducerOnUpdateQuery(SqlFieldsQuery qry) { return qry != null && !qry.isLocal() && qry instanceof SqlFieldsQueryEx && ((SqlFieldsQueryEx)qry).isSkipReducerOnUpdate(); }
/** * Make a copy of {@link SqlFieldsQuery} with all flags and preserving type. * @param oldQry Query to copy. * @return Query copy. */ private SqlFieldsQuery cloneFieldsQuery(SqlFieldsQuery oldQry) { return oldQry.copy().setLocal(oldQry.isLocal()).setPageSize(oldQry.getPageSize()); }
Long qryId = registerRunningQuery(schemaName, null, qry.getSql(), qry.isLocal(), true);
throw new CacheException("Using both partitions and distributed JOINs is not supported for the same query"); if (qry.isLocal() && ctx.clientNode() && (cctx == null || cctx.config().getCacheMode() != CacheMode.LOCAL)) throw new CacheException("Execution of local SqlFieldsQuery on client node disallowed.");
String sqlQry = qry.getSql(); boolean loc = qry.isLocal();
/** * @param cache Cache. * @param qry Query. * @return Query plan. */ protected final String queryPlan(IgniteCache<?, ?> cache, SqlFieldsQuery qry) { return (String)cache.query(new SqlFieldsQuery("explain " + qry.getSql()) .setArgs(qry.getArgs()) .setLocal(qry.isLocal()) .setCollocated(qry.isCollocated()) .setPageSize(qry.getPageSize()) .setDistributedJoins(qry.isDistributedJoins()) .setEnforceJoinOrder(qry.isEnforceJoinOrder())) .getAll().get(0).get(0); }
/** Serialize SQL field query to stream. */ void write(SqlFieldsQuery qry, BinaryOutputStream out) { writeObject(out, qry.getSchema()); out.writeInt(qry.getPageSize()); out.writeInt(-1); // do not limit writeObject(out, qry.getSql()); ClientUtils.collection(qry.getArgs() == null ? null : Arrays.asList(qry.getArgs()), out, this::writeObject); out.writeByte((byte)0); // statement type ANY out.writeBoolean(qry.isDistributedJoins()); out.writeBoolean(qry.isLocal()); out.writeBoolean(qry.isReplicatedOnly()); out.writeBoolean(qry.isEnforceJoinOrder()); out.writeBoolean(qry.isCollocated()); out.writeBoolean(qry.isLazy()); out.writeLong(qry.getTimeout()); out.writeBoolean(true); // include column names }
else { res.cacheIds(cacheIds); res.local(qry.isLocal());
cancel = new GridQueryCancel(); Long qryId = registerRunningQuery(schemaName, cancel, qry.getSql(), qry.isLocal(), registerAsNewQry);
.setDistributedJoins(qry.isDistributedJoins()) .setEnforceJoinOrder(qry.isEnforceJoinOrder()) .setLocal(qry.isLocal()) .setPageSize(qry.getPageSize()) .setTimeout(qry.getTimeout(), TimeUnit.MILLISECONDS)
.setDistributedJoins(fieldsQry.isDistributedJoins()) .setEnforceJoinOrder(fieldsQry.isEnforceJoinOrder()) .setLocal(fieldsQry.isLocal()) .setPageSize(fieldsQry.getPageSize()) .setTimeout((int)timeout, TimeUnit.MILLISECONDS) .setDistributedJoins(fieldsQry.isDistributedJoins()) .setEnforceJoinOrder(fieldsQry.isEnforceJoinOrder()) .setLocal(fieldsQry.isLocal()) .setPageSize(fieldsQry.getPageSize()) .setTimeout(fieldsQry.getTimeout(), TimeUnit.MILLISECONDS)
/** * Checks whether query flags are compatible with server side update. * * @param qry Query. * @return {@code true} if update can be distributed. */ public static boolean isSkipReducerOnUpdateQuery(SqlFieldsQuery qry) { return qry != null && !qry.isLocal() && qry instanceof SqlFieldsQueryEx && ((SqlFieldsQueryEx)qry).isSkipReducerOnUpdate(); }
/** * Make a copy of {@link SqlFieldsQuery} with all flags and preserving type. * @param oldQry Query to copy. * @return Query copy. */ private SqlFieldsQuery cloneFieldsQuery(SqlFieldsQuery oldQry) { return oldQry.copy().setLocal(oldQry.isLocal()).setPageSize(oldQry.getPageSize()); }
/** * Validate SQL fields query. * * @param qry Query. * @param ctx Kernal context. * @param cctx Cache context. */ private static void validateSqlFieldsQuery(SqlFieldsQuery qry, GridKernalContext ctx, @Nullable GridCacheContext<?, ?> cctx) { if (qry.isReplicatedOnly() && qry.getPartitions() != null) throw new CacheException("Partitions are not supported in replicated only mode."); if (qry.isDistributedJoins() && qry.getPartitions() != null) throw new CacheException("Using both partitions and distributed JOINs is not supported for the same query"); if (qry.isLocal() && ctx.clientNode() && (cctx == null || cctx.config().getCacheMode() != CacheMode.LOCAL)) throw new CacheException("Execution of local SqlFieldsQuery on client node disallowed."); }
/** Serialize SQL field query to stream. */ void write(SqlFieldsQuery qry, BinaryOutputStream out) { writeObject(out, qry.getSchema()); out.writeInt(qry.getPageSize()); out.writeInt(-1); // do not limit writeObject(out, qry.getSql()); ClientUtils.collection(qry.getArgs() == null ? null : Arrays.asList(qry.getArgs()), out, this::writeObject); out.writeByte((byte)0); // statement type ANY out.writeBoolean(qry.isDistributedJoins()); out.writeBoolean(qry.isLocal()); out.writeBoolean(qry.isReplicatedOnly()); out.writeBoolean(qry.isEnforceJoinOrder()); out.writeBoolean(qry.isCollocated()); out.writeBoolean(qry.isLazy()); out.writeLong(qry.getTimeout()); out.writeBoolean(true); // include column names }
/** * Split query into two-step query. * @param prepared JDBC prepared statement. * @param qry Original fields query. * @return Two-step query. * @throws IgniteCheckedException in case of error inside {@link GridSqlQuerySplitter}. * @throws SQLException in case of error inside {@link GridSqlQuerySplitter}. */ private GridCacheTwoStepQuery split(Prepared prepared, SqlFieldsQuery qry) throws IgniteCheckedException, SQLException { GridCacheTwoStepQuery res = GridSqlQuerySplitter.split(connectionForThread(qry.getSchema()), prepared, qry.getArgs(), qry.isCollocated(), qry.isDistributedJoins(), qry.isEnforceJoinOrder(), this); List<Integer> cacheIds = collectCacheIds(null, res); if (!F.isEmpty(cacheIds) && hasSystemViews(res)) { throw new IgniteSQLException("Normal tables and system views cannot be used in the same query.", IgniteQueryErrorCode.UNSUPPORTED_OPERATION); } if (F.isEmpty(cacheIds)) res.local(true); else { res.cacheIds(cacheIds); res.local(qry.isLocal()); } res.pageSize(qry.getPageSize()); return res; }
.setDistributedJoins(qry.isDistributedJoins()) .setEnforceJoinOrder(qry.isEnforceJoinOrder()) .setLocal(qry.isLocal()) .setPageSize(qry.getPageSize()) .setTimeout(qry.getTimeout(), TimeUnit.MILLISECONDS);