com.gemstone.gemfire.cache.query.NameResolutionException Java Examples

The following examples show how to use com.gemstone.gemfire.cache.query.NameResolutionException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractIndex.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
private void doNestedIterations(int level, ExecutionContext context) throws TypeMismatchException,
    AmbiguousNameException, FunctionDomainException,
    NameResolutionException, QueryInvocationTargetException, IMQException
{
  List iterList = context.getCurrentIterators();
  if (level == this.iteratorSize) {
    applyProjection(context);
  }
  else {
    RuntimeIterator rIter = (RuntimeIterator)iterList.get(level);
    // System.out.println("Level = "+level+" Iter = "+rIter.getDef());
    Collection c = rIter.evaluateCollection(context);
    if (c == null)
      return;
    Iterator cIter = c.iterator();
    while (cIter.hasNext()) {
      rIter.setCurrent(cIter.next());
      doNestedIterations(level + 1, context);
    }
  }
}
 
Example #2
Source File: CompactRangeIndex.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * @param add
 *          true if adding to index, false if removing
 * @param context
 */
private void doNestedIterations(int level, boolean add,
    ExecutionContext context) throws TypeMismatchException,
    AmbiguousNameException, FunctionDomainException,
    NameResolutionException, QueryInvocationTargetException, IMQException {
  List iterList = context.getCurrentIterators();
  if (level == this.iteratorSize) {
    applyProjection(add, context);
  } else {
    RuntimeIterator rIter = (RuntimeIterator) iterList.get(level);
    // System.out.println("Level = "+level+" Iter = "+rIter.getDef());
    Collection c = rIter.evaluateCollection(context);
    if (c == null)
      return;
    Iterator cIter = c.iterator();
    while (cIter.hasNext()) {
      rIter.setCurrent(cIter.next());
      doNestedIterations(level + 1, add, context);
    }
  }
}
 
Example #3
Source File: QueryPerfClient.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public static void createIndexesTask() throws SQLException, 
    NameResolutionException, RegionNotFoundException, IndexExistsException,
    IndexNameConflictException {
  if (useExistingData) {
    Log.getLogWriter().info("No indexes created, using existing data");
    return; // noop
  }
  if (QueryPerfPrms.createIndexes()) {
    QueryPerfClient c = new QueryPerfClient();
    c.initialize();
    c.initAdditionalLocalParameters();
    if (c.sttgid == 0) {
      c.createIndexes();
    }
  }
}
 
Example #4
Source File: QueryPerfClient.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
private void preparedOQLQueryQueryData() throws NameResolutionException,
    TypeMismatchException, FunctionDomainException,
    QueryInvocationTargetException {
  int queryType = this.queryFactory.getQueryType();
  String stmt = this.queryFactory.getPreparedQuery(queryType);
  //PreparedStatement pstmt = connection.prepareStatement(stmt);
  //Query query = ((OQLQueryFactory) queryFactory).prepareOQLStatement(stmt);
  
  Query query = PoolHelper.getPool("clientPool").getQueryService().newQuery(stmt);
  //= cache.getQueryService().newQuery(stmt);
  do {
    int key = getNextKey();
    executeTaskTerminator();
    executeWarmupTerminator();
    preparedOQLQueryQueryData(key, queryType, query);
    ++this.batchCount;
    ++this.count;
    ++this.keyCount;
  } while (!executeBatchTerminator());

  //pstmt.close();
}
 
Example #5
Source File: RangeJunction.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public boolean isBetterFilter(Filter comparedTo, ExecutionContext context, int thisSize) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException
{
  //If the current filter is equality & comparedTo filter is also equality based , then 
  // return the one with lower size estimate is better
  boolean isThisBetter = true;
 
  int thatOperator = comparedTo.getOperator() ;    
  switch(thatOperator) {
      case TOK_EQ:        
         isThisBetter = false;
         break;
      case TOK_NE:
      case TOK_NE_ALT:
        //Give preference to Range
        break;        
      default :
          throw  new IllegalArgumentException("The operator type ="+ thatOperator + " is unknown");
  }          
    
  return isThisBetter;
}
 
Example #6
Source File: QueryPerfClient.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
private void directUpdateData() throws SQLException,
NameResolutionException, TypeMismatchException, FunctionDomainException,
QueryInvocationTargetException {
  switch(this.queryAPI) {
    case QueryPrms.GFE_GFK:
    case QueryPrms.GFE_GFK_DVD:
    case QueryPrms.GFE:
      updateDataFromRegion();
      break;
    case QueryPrms.MYSQL:
    case QueryPrms.MYSQLC:
    case QueryPrms.ORACLE:
    case QueryPrms.GPDB:
    case QueryPrms.GFXD:
      updateQueryData();
      break;
    default:
      unsupported();
  }
}
 
Example #7
Source File: CompactRangeIndex.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
private void doNestedExpansion(int level, ExecutionContext expansionContext, List expandedResults, Object lowerBoundKey, Object upperBoundKey, int lowerBoundOperator, int upperBoundOperator, Object value) throws TypeMismatchException,
AmbiguousNameException, FunctionDomainException,
NameResolutionException, QueryInvocationTargetException, IMQException {
  List iterList = expansionContext.getCurrentIterators();
  int iteratorSize = iterList.size();
  if (level == iteratorSize) {
    expand(expansionContext, expandedResults, lowerBoundKey, upperBoundKey, lowerBoundOperator, upperBoundOperator, value);
  }
  else {
    RuntimeIterator rIter = (RuntimeIterator)iterList.get(level);
    Collection c = rIter.evaluateCollection(expansionContext);
    if (c == null)
      return;
    Iterator cIter = c.iterator();
    while (cIter.hasNext()) {
      rIter.setCurrent(cIter.next());
      doNestedExpansion(level + 1, expansionContext,expandedResults, lowerBoundKey, upperBoundKey, lowerBoundOperator, upperBoundOperator, value);
    }
  }
}
 
Example #8
Source File: CompiledIn.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
protected PlanInfo protGetPlanInfo(ExecutionContext context)
    throws TypeMismatchException, AmbiguousNameException, NameResolutionException {
  PlanInfo result = new PlanInfo();
  IndexInfo[] indexInfo = getIndexInfo(context);
  if (indexInfo == null) return result;
  for (int i = 0; i < indexInfo.length; ++i) {
    result.indexes.add(indexInfo[i]._index);
  }
  result.evalAsFilter = true;
  String preferredCondn = (String)context.cacheGet(PREF_INDEX_COND);
  if(preferredCondn != null) {
    //This means that the system is having only one independent iterator so equi join is ruled out.
    // thus the first index is guaranteed to be on the condition which may match our preferred index
    if(indexInfo[0]._index.getCanonicalizedIndexedExpression().equals(preferredCondn) && 
        (indexInfo[0]._index.getType() == IndexType.FUNCTIONAL || indexInfo[0]._index.getType() == IndexType.HASH)) {
      result.isPreferred = true;
    }
  }
  return result;
}
 
Example #9
Source File: QueryPerfClient.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
private void directPreparedUpdateData() throws SQLException,
NameResolutionException, TypeMismatchException, FunctionDomainException,
QueryInvocationTargetException {
  switch(this.queryAPI) {
    case QueryPrms.GFE_GFK:
    case QueryPrms.GFE_GFK_DVD:
    case QueryPrms.GFE:
      updateDataFromRegion();
      break;
    case QueryPrms.MYSQL:
    case QueryPrms.MYSQLC:
    case QueryPrms.ORACLE:
    case QueryPrms.GPDB:
    case QueryPrms.GFXD:
      preparedUpdateQueryData();
      break;
    case QueryPrms.RTE:
      preparedUpdateQueryData();
      break;
    default:
      unsupported();
  }
}
 
Example #10
Source File: CompactMapRangeIndex.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
@Override
void lockedQuery(Object key, int operator, Collection results,
    Set keysToRemove, ExecutionContext context) throws TypeMismatchException, FunctionDomainException,
    NameResolutionException, QueryInvocationTargetException
{
  Object[] mapKeyAndVal = (Object[])key;
  CompactRangeIndex ri = this.mapKeyToValueIndex.get(mapKeyAndVal[1]);
  if (ri != null) {
    long start = CFactory.nanoTime();
    ri.internalIndexStats.incUsesInProgress(1);
    ri.lockedQuery(mapKeyAndVal[0], operator, results, keysToRemove, context);
    ri.internalIndexStats.incNumUses();
    ri.internalIndexStats.incUsesInProgress(-1);
    ri.internalIndexStats.incUseTime(CFactory.nanoTime() - start);
  }
}
 
Example #11
Source File: QueryPerfClient.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
private void preparedOQLQueryQueryData(int i, int queryType, Query query)
    throws NameResolutionException, TypeMismatchException,
    FunctionDomainException, QueryInvocationTargetException {
  Object rs = null;
  long start = this.querystats.startQuery();
  switch (this.queryAPI) {
    case QueryPrms.OQL:
      rs =
          ((OQLQueryFactory) this.queryFactory)
              .fillAndExecutePreparedQueryStatement(query, queryType, i);
      ((OQLQueryFactory) this.queryFactory).readResultSet(queryType, rs);
      break;
    default:
      String s = "Unsupported API: " + QueryPrms.getAPIString(this.queryAPI);
      throw new HydraConfigException(s);
  }
  this.querystats.endQuery(start, this.histogram);//, this.isMainWorkload);
  //rs.close();
}
 
Example #12
Source File: CompiledIn.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Asif : Evaluates as a filter taking advantage of indexes if appropriate.
 * This function has a meaningful implementation only in CompiledComparison &
 * CompiledUndefined . It is unsupported in other classes. The additional
 * parameters which it takes are a boolean which is used to indicate whether
 * the index result set needs to be expanded to the top level or not. The
 * second is a CompiledValue representing the operands which are only iter
 * evaluatable. The CompiledValue passed will be null except if a
 * GroupJunction has only one filter evaluatable condition & rest are iter
 * operands. In such cases , the iter operands will be evaluated while
 * expanding/cutting down the index resultset
 * 
 * @return SelectResults
 */
public SelectResults filterEvaluate(ExecutionContext context,
    SelectResults intermediateResults, boolean completeExpansionNeeded,
    CompiledValue iterOperands, RuntimeIterator[] indpndntItrs, boolean isIntersection, boolean conditioningNeeded, boolean evalProj)
    throws FunctionDomainException, TypeMismatchException,
    NameResolutionException, QueryInvocationTargetException
{
  // see if we're dependent on the current iterator
  // if not let super handle it
  // RuntimeIterator itr = context.getCurrentIterator();
  // Support.Assert(itr != null);
  if (!isDependentOnCurrentScope(context))
    return super.filterEvaluate(context, intermediateResults);
  IndexInfo[] idxInfo = getIndexInfo(context);
  Support
      .Assert(
          idxInfo != null,
          "a comparison that is dependent, not indexed, and filter evaluated is not possible");
  Support.Assert(idxInfo.length == 1,
      "In operator should have only one index");

  return singleBaseCollectionFilterEvaluate(context, intermediateResults,
      completeExpansionNeeded, iterOperands, idxInfo[0], indpndntItrs, isIntersection,conditioningNeeded,evalProj);

}
 
Example #13
Source File: AbstractIndex.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Returns evaluated collection for dependent runtime iterator for this index
 * from clause and given RegionEntry.
 *
 * @param context passed here is query context.
 * @return Evaluated second level collection.
 * @throws QueryInvocationTargetException 
 * @throws NameResolutionException 
 * @throws TypeMismatchException 
 * @throws FunctionDomainException 
 */
protected List evaluateIndexIteratorsFromRE(Object value, ExecutionContext context)
    throws FunctionDomainException,
    TypeMismatchException, NameResolutionException,
    QueryInvocationTargetException {
  //We need NonTxEntry to call getValue() on it. RegionEntry does
  //NOT have public getValue() method.
  if (value instanceof RegionEntry) {
    value = ((LocalRegion) this.getRegion()).new NonTXEntry(
        (RegionEntry) value);
  }
  // Get all Independent and dependent iterators for this Index.
  List itrs = getAllDependentRuntimeIterators(context);

  List values = evaluateLastColl(value, context, itrs, 0);
  return values;
}
 
Example #14
Source File: CompiledIn.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public boolean isConditioningNeededForIndex(RuntimeIterator independentIter, 
    ExecutionContext context, boolean completeExpnsNeeded) throws AmbiguousNameException, TypeMismatchException, NameResolutionException  {
  IndexConditioningHelper ich = null;
  IndexInfo[] idxInfo = getIndexInfo(context);
  assert idxInfo.length == 1;
  int indexFieldsSize = -1;
  boolean conditioningNeeded = true;
  ObjectType indexRsltType = idxInfo[0]._index.getResultSetType();
  if (indexRsltType instanceof StructType) {
    indexFieldsSize = ((StructTypeImpl)indexRsltType).getFieldNames().length;
  }
  else {
    indexFieldsSize = 1;      
  }
  
  if (independentIter != null   && indexFieldsSize == 1) {
    ich = new IndexConditioningHelper(idxInfo[0], context, indexFieldsSize,
        completeExpnsNeeded, null, independentIter);
  }
  conditioningNeeded = ich == null || ich.shufflingNeeded;
  return conditioningNeeded;

}
 
Example #15
Source File: CompiledComparison.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
@Override
protected PlanInfo protGetPlanInfo(ExecutionContext context)
    throws TypeMismatchException, AmbiguousNameException, NameResolutionException {
  PlanInfo result = new PlanInfo();
  IndexInfo[] indexInfo = getIndexInfo(context);
  if (indexInfo == null) return result;
  for (int i = 0; i < indexInfo.length; ++i) {
    result.indexes.add(indexInfo[i]._index);
  }
  result.evalAsFilter = true;
  String preferredCondn = (String)context.cacheGet(PREF_INDEX_COND);
 if(preferredCondn != null) {
   //This means that the system is having only one independent iterator so equi join is ruled out.
   // thus the first index is guaranteed to be on the condition which may match our preferred index
   if(indexInfo[0]._index.getCanonicalizedIndexedExpression().equals(preferredCondn) && 
       indexInfo[0]._index.getType() != IndexType.PRIMARY_KEY) {
     result.isPreferred = true;
   }
 }
  return result;
}
 
Example #16
Source File: CompiledSelect.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public SelectResults getEmptyResultSet(Object[] parameters, Cache cache)
throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException {
  ExecutionContext context = new QueryExecutionContext(parameters, cache);
  computeDependencies(context);
  context.newScope(this.scopeID);
  context.pushExecCache(scopeID);
  SelectResults results = null;
  try {
    Iterator iter = iterators.iterator();
    while (iter.hasNext()) {
      CompiledIteratorDef iterDef = (CompiledIteratorDef) iter.next();
      RuntimeIterator rIter = iterDef.getRuntimeIterator(context);
      context.bindIterator(rIter);      
    }
    results = prepareEmptyResultSet(context,false);
  }
  finally {
    context.popScope();
    context.popExecCache();
  }
  return results;
}
 
Example #17
Source File: CompiledSelect.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Yogesh : This methods evaluates sort criteria and returns a ArrayList of 
 *          Object[] arrays of evaluated criteria  
 * @param context
 * @param sr
 * @return ArrayList
 * @throws FunctionDomainException
 * @throws TypeMismatchException
 * @throws NameResolutionException
 * @throws QueryInvocationTargetException
 */
private ArrayList evaluateSortCriteria(ExecutionContext context, Object sr)
throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException {
	
  CompiledSortCriterion csc ;    
  ArrayList list = new ArrayList();
  if(orderByAttrs != null){
    Iterator orderiter = orderByAttrs.iterator();
    while (orderiter.hasNext()) {
  	csc = (CompiledSortCriterion)orderiter.next();
  	Object[] arr = new Object[2];
  	arr[0] = csc.evaluate(context);
  	arr[1] = Boolean.valueOf(csc.criterion);
   	list.add(arr);     	
    }
 
	}
  return list;
}
 
Example #18
Source File: CompiledLike.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isOrderByApplicableAtIndexLevel(ExecutionContext context,
    String canonicalizedOrderByClause) throws FunctionDomainException,
    TypeMismatchException, NameResolutionException,
    QueryInvocationTargetException {

  if (this.getPlanInfo(context).evalAsFilter) {
    PlanInfo pi = this.getPlanInfo(context);
    if (pi.indexes.size() == 1) {
      IndexProtocol ip = (IndexProtocol)pi.indexes.get(0);
      if (ip.getCanonicalizedIndexedExpression().equals(
          canonicalizedOrderByClause)) {
        return true;
      }
    }
  }
  return false;
}
 
Example #19
Source File: QueryPerfClient.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
private void deleteData() throws SQLException,
NameResolutionException, TypeMismatchException, FunctionDomainException,
QueryInvocationTargetException {
  switch(this.queryAPI) {
    case QueryPrms.GFXD:
      deleteQueryData();
      break;
    default:
      unsupported();
  }
}
 
Example #20
Source File: CompiledSelect.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
private SelectResults doIterationEvaluate(ExecutionContext context, boolean evaluateWhereClause)
    throws TypeMismatchException, FunctionDomainException, NameResolutionException,
    QueryInvocationTargetException {
  
  SelectResults results = context.getResults();
  if (results == null) {
    results = prepareEmptyResultSet(context,false);
  }
  //TODO:Asif: SELF : Work on limit implementation on bulk get    
  // check for bulk get optimization
  if (evaluateWhereClause) {
    List tmpResults = optimizeBulkGet(context);
    if (tmpResults != null) {
      // (has only one iterator)
      RuntimeIterator rIter = (RuntimeIterator)context.getCurrentIterators().get(0); 
      for (Iterator itr = tmpResults.iterator(); itr.hasNext(); ) {
        Object currObj = itr.next();
        rIter.setCurrent(currObj);
        QueryObserver observer = QueryObserverHolder.getInstance();
        observer.beforeIterationEvaluation(rIter, currObj);
        applyProjectionAndAddToResultSet(context, results, this.orderByAttrs ==null);
      }
      return results;
    }
  }
  int numElementsInResult = 0;
  try {
    doNestedIterations(0, results, context, evaluateWhereClause,numElementsInResult);
  }catch(CompiledSelect.NullIteratorException cnie) {
    return null;
  }
  return results;
}
 
Example #21
Source File: CompiledSelect.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
private Integer evaluateLimitValue(Object[] bindArguments) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException {
  Integer limitValue = -1;
  if (this.limit != null) {
    if (this.limit instanceof CompiledBindArgument) {
      limitValue = (Integer)((CompiledBindArgument)this.limit).evaluate(bindArguments);
    }
    else {
      //Assume limit is a compiled literal which does not need a context
      limitValue =  (Integer)this.limit.evaluate(null);
    }
  }
  return limitValue;
}
 
Example #22
Source File: RangeJunction.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Segregates the operands of the RangeJunction into iter evaluatable and
 * filter evaluatable.
 */
@Override
OrganizedOperands organizeOperands(ExecutionContext context)
    throws FunctionDomainException, TypeMismatchException,
    NameResolutionException, QueryInvocationTargetException {
  // get the list of operands to evaluate,
  // and evaluate operands that can use indexes first
  if (getOperator() == LITERAL_and) {
    return organizeOperandsForAndJunction(context);
  }
  else {
    throw new IllegalStateException(
      LocalizedStrings.RangeJunction_IN_THE_CASE_OF_AN_OR_JUNCTION_A_RANGEJUNCTION_SHOULD_NOT_BE_FORMED_FOR_NOW.toLocalizedString());
  }
}
 
Example #23
Source File: RangeJunction.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@Override
public SelectResults filterEvaluate(ExecutionContext context,
    SelectResults iterationLimit) throws FunctionDomainException,
    TypeMismatchException, NameResolutionException,
    QueryInvocationTargetException {
  throw new UnsupportedOperationException();
}
 
Example #24
Source File: LocalDataSet.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public Object selectValue(String queryPredicate)
    throws FunctionDomainException, TypeMismatchException,
    NameResolutionException, QueryInvocationTargetException {
  SelectResults result = query(queryPredicate);
  if (result.isEmpty()) {
    return null;
  }
  if (result.size() > 1) {
    throw new FunctionDomainException(LocalizedStrings
        .AbstractRegion_SELECTVALUE_EXPECTS_RESULTS_OF_SIZE_1_BUT_FOUND_RESULTS_OF_SIZE_0
            .toLocalizedString(Integer.valueOf(result.size())));
  }
  return result.iterator().next();
}
 
Example #25
Source File: QueryPerfClient.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static void updateQueryDataTask() throws SQLException,
NameResolutionException, TypeMismatchException, FunctionDomainException,
QueryInvocationTargetException {
  QueryPerfClient c = new QueryPerfClient();
  c.initialize(UPDATES);
  c.initAdditionalLocalParameters();
  c.directUpdateData();
}
 
Example #26
Source File: CompiledIn.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public IndexInfo[] getIndexInfo(ExecutionContext context)
    throws TypeMismatchException, AmbiguousNameException,
    NameResolutionException {
  IndexInfo[] indexInfo = privGetIndexInfo(context);
  if (indexInfo != null) {
    if (indexInfo == NO_INDEXES_IDENTIFIER) {
      return null;
    } else {
      return indexInfo;
    }
  }
  if (!IndexUtils.indexesEnabled)
    return null;
  // get the path and index key to try
  PathAndKey pAndK = getPathAndKey(context);
  IndexInfo newIndexInfo[] = null;
  if (pAndK != null) {
    CompiledValue path = pAndK._path;
    CompiledValue indexKey = pAndK._key;
    IndexData indexData = QueryUtils.getAvailableIndexIfAny(path, context,
        this.TOK_EQ);
    IndexProtocol index = null;
    if (indexData != null) {
      index = indexData.getIndex();
    }
    if (index != null && index.isValid()) {
      newIndexInfo = new IndexInfo[1];
      newIndexInfo[0] = new IndexInfo(indexKey, path, index, indexData
          .getMatchLevel(), indexData.getMapping(), this.TOK_EQ);
    }
  }
  if (newIndexInfo != null) {
    privSetIndexInfo(newIndexInfo, context);
  } else {
    privSetIndexInfo(NO_INDEXES_IDENTIFIER, context);
  }
  return newIndexInfo;
}
 
Example #27
Source File: CompiledComparison.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * evaluate as a filter, producing an intermediate result set. This may
 * require iteration if there is no index available. Asif :The booelan true
 * implies that CompiledComparsion when existing on its own always requires a
 * Completeexpansion to top level iterators. This flag can get toggled to
 * false only from inside a GroupJunction
 * 
 * @param intermediateResults if this parameter is provided, and we have to
 *          iterate, then iterate over this result set instead of the entire
 *          base collection.
 */
@Override
public SelectResults filterEvaluate(ExecutionContext context,
    SelectResults intermediateResults) throws FunctionDomainException,
    TypeMismatchException, NameResolutionException,
    QueryInvocationTargetException {
  // Asif : This function can be invoked only if the where clause contains
  // a single condition which is CompiledComparison.
  // If a CompiledComparison exists inside a GroupJunction, then it will
  // always
  // call the overloaded filterEvalauate with the RuntimeIterator passed
  // as not null.
  // Thus if the RuntimeIterator array passed is null then it is
  // guaranteed
  // that the condition was a isolatory condition ( directly in where
  // clause)
  // and the final iterators to which we need to expand to is all the
  // iterators
  // of the scope
  //Asif: hack for customer
  RuntimeIterator indpndntItr = null;
  
  List currentScopeIndpndntItrs = context.getAllIndependentIteratorsOfCurrentScope();
  Set rntmItrs =  QueryUtils.getCurrentScopeUltimateRuntimeIteratorsIfAny(this,context);
  if(rntmItrs.size() ==1 && currentScopeIndpndntItrs.size() ==1  ) {
    indpndntItr = (RuntimeIterator)rntmItrs.iterator().next();
  }
  
  
  return filterEvaluate(context, intermediateResults, true/*
                                                           * Complete
                                                           * Expansion needed
                                                           */, null, indpndntItr !=null?new RuntimeIterator[]{indpndntItr}:null/*
                  * Asif :It is safe to pass null as the independent iterator
                  * to which the condition belongs is required only if boolean
                  * complete expansion turns out to be false, which can happen
                  * only in case of CompiledComparison/CompiledUndefined
                  * called from roupJunction or CompositeGroupJunction
                  */, true,this.isConditioningNeededForIndex(indpndntItr, context, true),true /*evaluate projection attribute */);
}
 
Example #28
Source File: CompiledComparison.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Asif : Evaluates as a filter taking advantage of indexes if appropriate.
 * This function has a meaningful implementation only in CompiledComparison &
 * CompiledUndefined . It is unsupported in other classes. The additional
 * parameters which it takes are a boolean which is used to indicate whether
 * the index result set needs to be expanded to the top level or not. The
 * second is a CompiledValue representing the operands which are only iter
 * evaluatable. The CompiledValue passed will be null except if a
 * GroupJunction has only one filter evaluatable condition & rest are iter
 * operands. In such cases , the iter operands will be evaluated while
 * expanding/cutting down the index resultset
 * 
 * @return SelectResults
 */
@Override
public SelectResults filterEvaluate(ExecutionContext context,
    SelectResults intermediateResults, boolean completeExpansionNeeded,
    @Retained CompiledValue iterOperands, RuntimeIterator[] indpndntItrs, boolean isIntersection, boolean conditioningNeeded, boolean evaluateProjection)
    throws FunctionDomainException, TypeMismatchException,
    NameResolutionException, QueryInvocationTargetException {
  // see if we're dependent on the current iterator
  // if not let super handle it
  // RuntimeIterator itr = context.getCurrentIterator();
  // Support.Assert(itr != null);
  if (!isDependentOnCurrentScope(context))
      return super.filterEvaluate(context, intermediateResults);
  IndexInfo[] idxInfo = getIndexInfo(context);
  Support
      .Assert(
          idxInfo != null,
          "a comparison that is dependent, not indexed, and filter evaluated is not possible");
  if (idxInfo.length == 1) {
    return singleBaseCollectionFilterEvaluate(context, intermediateResults,
        completeExpansionNeeded, iterOperands, idxInfo[0], indpndntItrs, isIntersection,conditioningNeeded, evaluateProjection);
  }
  else {
    Support
        .Assert(
            idxInfo.length == 2,
            "A Composite CompiledComparison which is filter evaluatable needs to have two indexes");
    return doubleBaseCollectionFilterEvaluate(context, intermediateResults,
        completeExpansionNeeded, iterOperands, idxInfo, indpndntItrs);
  }
}
 
Example #29
Source File: CompiledComparison.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public Object evaluate(ExecutionContext context)
    throws FunctionDomainException, TypeMismatchException,
    NameResolutionException, QueryInvocationTargetException {
  Object left = _left.evaluate(context);
  Object right = _right.evaluate(context);
  
  if (context.isCqQueryContext() && left instanceof Region.Entry) {
    left = ((Region.Entry) left).getValue();
  }
  if (context.isCqQueryContext() && right instanceof Region.Entry) {
    right = ((Region.Entry) right).getValue();
  }
  
  // if either of the operands is PdxString convert the other
  if (left instanceof PdxString) {
    if (right instanceof String) {
      if (_right.getType() == LITERAL) {
        right = ((CompiledLiteral) _right).getSavedPdxString();
      } else if (_right.getType() == QUERY_PARAM) {
        right = ((CompiledBindArgument) _right).getSavedPdxString(context);
      }
    }
  } else if (right instanceof PdxString) {
    if (_left.getType() == LITERAL) {
      left = ((CompiledLiteral) _left).getSavedPdxString();
    } else if (_left.getType() == QUERY_PARAM) {
      left = ((CompiledBindArgument) _left).getSavedPdxString(context);
    }
  }
 return TypeUtils.compare(left,right,_operator);
}
 
Example #30
Source File: ProxyRegion.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public SelectResults query(String queryPredicate)
    throws FunctionDomainException, TypeMismatchException,
    NameResolutionException, QueryInvocationTargetException {
  try {
    preOp();
    return this.realRegion.query(queryPredicate);
  } finally {
    postOp();
  }
}