Search in sources :

Example 36 with CompiledSelect

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

the class ServerCQImpl method constructServerSideQuery.

/**
   * Returns parameterized query used by the server. This method replaces Region name with $1 and if
   * type is not specified in the query, looks for type from cqattributes and appends into the
   * query.
   * 
   * @return String modified query.
   */
private Query constructServerSideQuery() throws QueryException {
    InternalCache cache = cqService.getInternalCache();
    DefaultQuery locQuery = (DefaultQuery) cache.getLocalQueryService().newQuery(this.queryString);
    CompiledSelect select = locQuery.getSimpleSelect();
    CompiledIteratorDef from = (CompiledIteratorDef) select.getIterators().get(0);
    // WARNING: ASSUMES QUERY WAS ALREADY VALIDATED FOR PROPER "FORM" ON CLIENT;
    // THIS VALIDATION WILL NEED TO BE DONE ON THE SERVER FOR NATIVE CLIENTS,
    // BUT IS NOT DONE HERE FOR JAVA CLIENTS.
    // The query was already checked on the client that the sole iterator is a
    // CompiledRegion
    this.regionName = ((CompiledRegion) from.getCollectionExpr()).getRegionPath();
    from.setCollectionExpr(new CompiledBindArgument(1));
    return locQuery;
}
Also used : CompiledIteratorDef(org.apache.geode.cache.query.internal.CompiledIteratorDef) CompiledBindArgument(org.apache.geode.cache.query.internal.CompiledBindArgument) DefaultQuery(org.apache.geode.cache.query.internal.DefaultQuery) CompiledSelect(org.apache.geode.cache.query.internal.CompiledSelect) InternalCache(org.apache.geode.internal.cache.InternalCache)

Aggregations

CompiledSelect (org.apache.geode.cache.query.internal.CompiledSelect)36 DefaultQuery (org.apache.geode.cache.query.internal.DefaultQuery)33 Region (org.apache.geode.cache.Region)28 Query (org.apache.geode.cache.query.Query)28 QueryService (org.apache.geode.cache.query.QueryService)28 SelectResults (org.apache.geode.cache.query.SelectResults)28 Test (org.junit.Test)28 Struct (org.apache.geode.cache.query.Struct)27 Iterator (java.util.Iterator)26 ObjectType (org.apache.geode.cache.query.types.ObjectType)24 StructType (org.apache.geode.cache.query.types.StructType)22 Portfolio (org.apache.geode.cache.query.data.Portfolio)15 PortfolioPdx (org.apache.geode.cache.query.data.PortfolioPdx)13 HashSet (java.util.HashSet)12 ExecutionContext (org.apache.geode.cache.query.internal.ExecutionContext)4 CompiledSortCriterion (org.apache.geode.cache.query.internal.CompiledSortCriterion)3 QueryExecutionContext (org.apache.geode.cache.query.internal.QueryExecutionContext)3 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 List (java.util.List)2