/** * Added to reset the state from the last execution. This is added for CQs only. */ @Override public void reset() { super.reset(); this.execCacheStack.clear(); }
/** * 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; }