for (final Object o : getRegionsInQuery(parameters)) { String regionPath = (String) o; Region rgn = this.cache.getRegion(regionPath); if (!this.isQueryWithFunctionContext()) { throw new UnsupportedOperationException( String.format( CompiledSelect select = getSimpleSelect(); if (select == null) { throw new UnsupportedOperationException( if (!this.isQueryWithFunctionContext()) { while (fromClauseIterator.hasNext()) { itrDef = (CompiledIteratorDef) fromClauseIterator.next();
String queryStr = constructRegionQueryString(predicate.trim()); DefaultQuery query = (DefaultQuery) qs.newQuery(queryStr); if (query.getRegionsInQuery(params).size() != 1) { throw new QueryInvalidException( "Prevent multiple region query from being executed through region.query()"); results = (SelectResults) query.execute(params);
return executeOnServer(params); QueryExecutor qe = checkQueryOnPR(params); indexObserver = this.startTrace(); if (qe != null) { if (DefaultQuery.testHook != null) { if (needsPDXDeserializationWrapper(true /* is query on PR */) && result instanceof SelectResults) { result = executeUsingContext(context); if (needsPDXDeserializationWrapper(false /* is query on PR */) && result instanceof SelectResults) { result = new ResultsCollectionPdxDeserializerWrapper((SelectResults) result, needsCopyOnReadWrapper); } else if (!isRemoteQuery() && this.cache.getCopyOnRead() && result instanceof SelectResults) { if (needsCopyOnReadWrapper) { return reinterpretQueryExecutionCanceledException(); } finally { this.cache.setPdxReadSerializedOverride(initialPdxReadSerialized); queryMonitor.stopMonitoringQueryThread(this); this.endTrace(indexObserver, startTime, result);
public QueryMessage(InternalDistributedMember recipient, int regionId, ReplyProcessor21 processor, DefaultQuery query, Object[] parameters, final List buckets) { super(recipient, regionId, processor); this.queryString = query.getQueryString(); this.buckets = buckets; this.parameters = parameters; this.cqQuery = query.isCqQuery(); this.traceOn = query.isTraced() || DefaultQuery.QUERY_VERBOSE; }
private void checkIfQueryShouldBeCancelled() { if (QueryMonitor.isLowMemory()) { String reason = "Query execution canceled due to low memory while gathering results from partitioned regions"; query.setQueryCanceledException(new QueryExecutionLowMemoryException(reason)); if (DefaultQuery.testHook != null) { DefaultQuery.testHook .doTestHook(DefaultQuery.TestHook.SPOTS.BEFORE_THROW_QUERY_CANCELED_EXCEPTION, null); } throw query.getQueryCanceledException(); } else if (query.isCanceled()) { throw query.getQueryCanceledException(); } }
/** * Each query can have a different maxQueryExecution time. Make this method public to expose that * feature to callers. * * Must not be called from a thread that is not the query thread, because this class uses a * ThreadLocal on the query thread! */ private void monitorQueryThread(final DefaultQuery query, final long maxQueryExecutionTime) { // cq query is not monitored if (query.isCqQuery()) { return; } query.setCancelationTask(scheduleCancelationTask(query, maxQueryExecutionTime)); if (logger.isDebugEnabled()) { logDebug(query, "Adding thread to QueryMonitor."); } }
? ((DefaultQuery) context.getQuery()).getSelect().isDistinct() : false;
private void executeSequentially(Collection<Collection> resultCollector, List buckets) throws QueryException, InterruptedException, ForceReattemptException { ExecutionContext context = new QueryExecutionContext(this.parameters, this.pr.getCache(), this.query); CompiledSelect cs = this.query.getSimpleSelect(); int limit = this.query.getLimit(parameters); if (cs != null && cs.isOrderBy()) { for (Integer bucketID : this._bucketsToQuery) { List<Integer> singleBucket = Collections.singletonList(bucketID); context.setBucketList(singleBucket); executeQueryOnBuckets(resultCollector, context); } Collection mergedResults = coalesceOrderedResults(resultCollector, context, cs, limit); resultCollector.clear(); resultCollector.add(mergedResults); } else { context.setBucketList(buckets); executeQueryOnBuckets(resultCollector, context); } }
InvocationTargetException { DefaultQuery q = (DefaultQuery) CacheUtils.getQueryService().newQuery(orderByQuery); CompiledSelect cs = q.getSimpleSelect(); List<CompiledSortCriterion> orderByAttribs = null; if (cs.getType() == CompiledValue.GROUP_BY_SELECT) {
CompiledSelect select = locQuery.getSimpleSelect(); if (select == null) { throw new UnsupportedOperationException( Set regionsInQuery = locQuery.getRegionsInQuery(parameters);
DefaultQuery query = new DefaultQuery(this.queryString, pr.getCache(), false); query.setRemoteQuery(true); QueryObserver indexObserver = query.startTrace(); boolean isQueryTraced = false; List queryTraceList = null; query.setIsCqQuery(this.cqQuery); PRQueryProcessor qp = new PRQueryProcessor(pr, query, this.parameters, this.buckets); if (logger.isDebugEnabled()) { logger.debug("Started executing query from remote node: {}", query.getQueryString()); query.isTraced() && this.sender.getVersionObject().compareTo(Version.GFE_81) >= 0; QueryMonitor.getMemoryUsedBytes()); throw new QueryExecutionLowMemoryException(reason); } else if (query.isCanceled()) { throw query.getQueryCanceledException(); query.setRemoteQuery(false); query.endTrace(indexObserver, traceStartTime, this.resultCollector);
private DefaultQuery mockQuery() { InternalQueryService queryService = mock(InternalQueryService.class); when(cache.getQueryService()).thenReturn(queryService); DefaultQuery query = mock(DefaultQuery.class); when(queryService.newQuery(any())).thenReturn(query); when(query.getRegionsInQuery(any())).thenReturn(Collections.singleton(REGION)); return query; }
if (authzRequest != null) { query = qService.newQuery(cqQueryString); cqRegionNames = ((DefaultQuery) query).getRegionsInQuery(null); executeCQContext = authzRequest.executeCQAuthorize(cqName, cqQueryString, cqRegionNames); String newCqQueryString = executeCQContext.getQuery(); cqRegionNames = executeCQContext.getRegionNames(); if (cqRegionNames == null) { cqRegionNames = ((DefaultQuery) query).getRegionsInQuery(null); if (query == null) { query = qService.newQuery(cqQueryString); cqRegionNames = ((DefaultQuery) query).getRegionsInQuery(null); ((DefaultQuery) query).setIsCqQuery(true); successQuery = processQuery(clientMessage, query, cqQueryString, cqRegionNames, start, cqQuery, executeCQContext, serverConnection, sendResults, securityService);
List<CompiledSortCriterion> orderByAttribs = null; if (sender.getVersionObject().compareTo(Version.GFE_90) < 0) { CompiledSelect cs = this.query.getSimpleSelect(); if (cs != null && cs.isOrderBy()) { sortNeeded = true; if (!QueryMonitor.isLowMemory() && !this.query.isCanceled()) { results.add(objects); } else { String reason = "Query execution canceled due to low memory while gathering results from partitioned regions"; query.setQueryCanceledException(new QueryExecutionLowMemoryException(reason)); } else { if (logger.isDebugEnabled()) { logger.debug("query cancelled while gathering results, aborting due to exception " + query.getQueryCanceledException());
((DefaultQuery) query).setLastUsed(true); } else { query = queryService.newQuery(queryString); Set regionNames = ((DefaultQuery) query).getRegionsInQuery(queryParams); regionNames = queryContext.getRegionNames(); if (regionNames == null) { regionNames = ((DefaultQuery) query).getRegionsInQuery(null);
QueryExecutor qe = checkQueryOnPR(params); indexObserver = startTrace(); if (qe != null) { LocalDataSet localDataSet = this.endTrace(indexObserver, startTime, result);
/** * Applies the query on the event. This method takes care of the performance related changed done * to improve the CQ-query performance. When CQ-query is executed first time, it saves the query * related information in the execution context and uses that info in later executions. */ private boolean evaluateQuery(CqQueryImpl cQuery, Object[] event) throws Exception { ExecutionContext execContext = cQuery.getQueryExecutionContext(); execContext.reset(); execContext.setBindArguments(event); boolean status = false; // Check if the CQ query is executed once. // If not execute the query in normal way. // During this phase the query execution related info are stored in the // ExecutionContext. if (execContext.getScopeNum() <= 0) { SelectResults results = (SelectResults) ((DefaultQuery) cQuery.getQuery()).executeUsingContext(execContext); if (results != null && results.size() > 0) { status = true; } } else { // Execute using the saved query info (in ExecutionContext). // This avoids building resultSet, index look-up, generating build-plans // that are not required for; query execution on single object. CompiledSelect cs = ((DefaultQuery) (cQuery.getQuery())).getSelect(); status = cs.evaluateCq(execContext); } return status; }
context.setCqQueryContext(query.isCqQuery()); if (GemFireCacheImpl.getInstance() != null) { queryMonitor = GemFireCacheImpl.getInstance().getQueryMonitor(); Object results = query.executeUsingContext(context);
@Override public ScheduledFuture<?> schedule(final Runnable command, final long timeLimitMillis, final TimeUnit unit, final ScheduledExecutorService scheduledExecutorService, final DefaultQuery query) { final CacheRuntimeException lowMemoryException = createCancelationException(timeLimitMillis, query); query.setQueryCanceledException(lowMemoryException); throw lowMemoryException; }
@Override public Object execute() throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { return execute(EMPTY_ARRAY); }