Search in sources :

Example 11 with ExecutionContext

use of org.apache.geode.cache.query.internal.ExecutionContext in project geode by apache.

the class CqServiceImpl method evaluateQuery.

/**
   * 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;
    // 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;
}
Also used : ExecutionContext(org.apache.geode.cache.query.internal.ExecutionContext) SelectResults(org.apache.geode.cache.query.SelectResults) DefaultQuery(org.apache.geode.cache.query.internal.DefaultQuery) CompiledSelect(org.apache.geode.cache.query.internal.CompiledSelect)

Aggregations

ExecutionContext (org.apache.geode.cache.query.internal.ExecutionContext)11 DefaultQuery (org.apache.geode.cache.query.internal.DefaultQuery)6 QueryExecutionContext (org.apache.geode.cache.query.internal.QueryExecutionContext)6 HashSet (java.util.HashSet)5 Set (java.util.Set)4 CompiledSelect (org.apache.geode.cache.query.internal.CompiledSelect)4 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)4 Test (org.junit.Test)4 QueryService (org.apache.geode.cache.query.QueryService)3 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 List (java.util.List)2 ExecutionException (java.util.concurrent.ExecutionException)2 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)2 InternalGemFireException (org.apache.geode.InternalGemFireException)2 QueryException (org.apache.geode.cache.query.QueryException)2 IOException (java.io.IOException)1 Integer (java.lang.Integer)1 Field (java.lang.reflect.Field)1 Method (java.lang.reflect.Method)1