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

The following examples show how to use com.gemstone.gemfire.cache.query.TypeMismatchException. 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: RangeJunction.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a Filter of type SingleCondnEvaluator if there exists atleast one
 * key of type "NOT EQUAL" which satisfies the 'less' or 'greater' type
 * operand. Otherwise the Filter is nothing but the CompiledComparison
 * representing the 'less' or 'greater' inequality
 * 
 * @param notEqualKeys
 *                Set containing NotEqual type Keys
 * @param operand
 *                CompiledValue representing the 'Less' or 'Greater' operand
 * @param operator
 *                Type of 'Less' or 'Greater' operand
 * @param condnKey
 *                The Key corresponding to the Operand representing the 'Less'
 *                or 'Greater' inequality
 * @param indxInfo
 *                The IndexInfo object for this RangeJunction
 * @return Filter object of type CompiledComparison or
 *         RangeJunction.SingleCondnEvaluator object
 * @throws TypeMismatchException
 */
private Filter generateSingleCondnEvaluatorIfRequired(Set notEqualKeys,
    CompiledValue operand, int operator, Object condnKey, IndexInfo indxInfo)
    throws TypeMismatchException {
  Filter rangeFilter;
  if (notEqualKeys != null) {
    // Eliminate all the not equal keys which will never be satisfied by
    // the given greater condn
    Iterator itr = notEqualKeys.iterator();
    while (itr.hasNext()) {
      Object neKey = itr.next();
      if (!((Boolean)TypeUtils.compare(neKey, condnKey, operator))
          .booleanValue()) {
        itr.remove();
      }
    }
    if (notEqualKeys.isEmpty()) {
      notEqualKeys = null;
    }
  }
  rangeFilter = (notEqualKeys != null) ? new SingleCondnEvaluator(operator,
      condnKey, notEqualKeys, indxInfo) : (Filter)operand;
  return rangeFilter;
}
 
Example #2
Source File: MemoryIndexStore.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public boolean removeFromKeysToRemove(Collection keysToRemove, Object key) {
  Iterator iterator = keysToRemove.iterator();
  while (iterator.hasNext()) {
    try {
      if (TypeUtils
          .compare(key, iterator.next(), OQLLexerTokenTypes.TOK_EQ).equals(
              Boolean.TRUE)) {
        iterator.remove();
        return true;
      }
    } catch (TypeMismatchException e) {
      // they are not equals, so we just continue iterating
    }
  }
  return false;
}
 
Example #3
Source File: BaseOQLQueryFactory.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public Object executeQueryPreparedStatement(Query pstmt, Object[] params)
    throws NameResolutionException, TypeMismatchException,
    FunctionDomainException, QueryInvocationTargetException {
  if (QueryPrms.logQueries()) {
    Log.getLogWriter().info("Executing query: " + pstmt.getQueryString());
  }
  //Collection rs = new ArrayList();
  Object rs = pstmt.execute(params);
  /*
  if (value instanceof Collection) {
    rs.addAll((Collection)value);
  }
  else {
    rs.add(value);
  }
  */
  if (QueryPrms.logQueries()) {
    Log.getLogWriter().info("Executed query: " + pstmt);
  }
  return rs;
}
 
Example #4
Source File: CompiledComparison.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);
  int indexFieldsSize = -1;
  boolean conditioningNeeded = true;
  if(idxInfo == null || idxInfo.length > 1) {
    return conditioningNeeded;
  }
  //assert idxInfo.length == 1;
  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);
  }
  return ich == null || ich.shufflingNeeded;
 

}
 
Example #5
Source File: MapIndexStore.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public boolean hasNext() {
  if (iterator.hasNext()) {
    IndexMap.IndexEntry indexEntry = iterator.next();
    nextEntry.setIndexEntry(indexEntry);
    needToCallHasNext = false;
    if (keysToRemove != null) {
      Iterator keysToRemoveIterator = keysToRemove.iterator();
      while (keysToRemoveIterator.hasNext()) {
        try {
          if (TypeUtils
              .compare(nextEntry.getDeserializedValue(), keysToRemoveIterator.next(), OQLLexerTokenTypes.TOK_EQ).equals(
                  Boolean.TRUE)) {
            return hasNext();
          }
        } catch (TypeMismatchException e) {
          // they are not equals, so we just continue iterating
        }
      }
    }
    return true;
  }
  return false;
}
 
Example #6
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 #7
Source File: MapRangeIndex.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
@Override
void lockedQuery(Object key, int operator, Collection results,
    CompiledValue iterOps, RuntimeIterator runtimeItr,
    ExecutionContext context, List projAttrib,
    SelectResults intermediateResults, boolean isIntersection)
    throws TypeMismatchException, FunctionDomainException,
    NameResolutionException, QueryInvocationTargetException
{
  Object[] mapKeyAndVal = (Object[])key;
  RangeIndex ri = this.mapKeyToValueIndex.get(mapKeyAndVal[1]);
  if (ri != null) {
    long start = CFactory.nanoTime();
    ri.internalIndexStats.incUsesInProgress(1);
    ri.lockedQuery(mapKeyAndVal[0], operator, results, iterOps, runtimeItr,
        context, projAttrib, intermediateResults, isIntersection);
    ri.internalIndexStats.incNumUses();
    ri.internalIndexStats.incUsesInProgress(-1);
    ri.internalIndexStats.incUseTime(CFactory.nanoTime() - start);
  }
}
 
Example #8
Source File: CompiledComparison.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) && ip.getType() != IndexType.PRIMARY_KEY && pi.isPreferred) {
        return true;
      }
    }
  }
  return false;
}
 
Example #9
Source File: CompiledComparison.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 * get the path to see if there's an index for, and also determine which
 * CompiledValue is the key while we're at it
 */
private PathAndKey getPathAndKey(ExecutionContext context)
    throws TypeMismatchException, AmbiguousNameException {
  // RuntimeIterator lIter = context.findRuntimeIterator(_left);
  // RuntimeIterator rIter = context.findRuntimeIterator(_right);
  boolean isLeftDependent = context.isDependentOnCurrentScope(_left);
  boolean isRightDependent = context.isDependentOnCurrentScope(_right);
  if ((isLeftDependent == false) == (isRightDependent == false)) return null;
  CompiledValue indexKey;
  CompiledValue path;
  if (isLeftDependent == false) {
    path = _right;
    indexKey = _left;
  }
  else {
    path = _left;
    indexKey = _right;
  }
  if (indexKey.isDependentOnCurrentScope(context)) return null; // this check
  // seems to be
  // redunant.
  return new PathAndKey(path, indexKey);
}
 
Example #10
Source File: CompiledComparison.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public int getSizeEstimate(ExecutionContext context)
    throws FunctionDomainException, TypeMismatchException,
    NameResolutionException, QueryInvocationTargetException
{
  IndexInfo[] idxInfo = getIndexInfo(context);
  if (idxInfo == null) {
    // Asif: This implies it is an independent condition. So evaluate it first
    // in filter operand
    return 0;
  }
  assert idxInfo.length == 1;
  Object key = idxInfo[0].evaluateIndexKey(context);
  if (key != null && key.equals(QueryService.UNDEFINED))
    return 0;
  // if the key is the LEFT operand, then reflect the operator
  // before the index lookup
  int op = reflectOnOperator(idxInfo[0]._key());

  return idxInfo[0]._index.getSizeEstimate(key, op, idxInfo[0]._matchLevel);

}
 
Example #11
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,
    CompiledValue iterOps, RuntimeIterator runtimeItr,
    ExecutionContext context, List projAttrib,
    SelectResults intermediateResults, boolean isIntersection)
    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, iterOps, runtimeItr,
        context, projAttrib, intermediateResults, isIntersection);
    ri.internalIndexStats.incNumUses();
    ri.internalIndexStats.incUsesInProgress(-1);
    ri.internalIndexStats.incUseTime(CFactory.nanoTime() - start);
  }
}
 
Example #12
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 #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: 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 #15
Source File: MiscTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public void xtestBug32763() throws FunctionDomainException, TypeMismatchException, NameResolutionException,
    QueryInvocationTargetException, TimeoutException, CacheWriterException
  {
  Region region = CacheUtils.createRegion("pos", Portfolio.class);
  region.put("0", new Portfolio(0));
  region.put("1", new Portfolio(1));
  region.put("2", new Portfolio(2));
  region.put("3", new Portfolio(3));
  QueryService qs = CacheUtils.getQueryService();
  String qStr = "SELECT DISTINCT key: key, iD: entry.value.iD, secId: posnVal.secId  FROM /pos.entries entry, entry.value.positions.values posnVal  WHERE entry.value.\"type\" = 'type0' AND posnVal.secId = 'YHOO'";
  Query q = qs.newQuery(qStr);
  SelectResults result = (SelectResults) q.execute();
  StructType type = (StructType) result.getCollectionType().getElementType();
  String names[] = type.getFieldNames();
  List list = result.asList();
  if (list.size() < 1) fail("Test failed as the resultset's size is zero");
  for (int i = 0; i < list.size(); ++i) {
    Struct stc = (Struct) list.get(i);
    if (!stc.get(names[2]).equals("YHOO")) {
      fail("Test failed as the SecID value is not YHOO");
    }
  }
}
 
Example #16
Source File: QueryPerfClient.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
private void preparedMixQueryQueryData() throws SQLException,
    NameResolutionException, TypeMismatchException, FunctionDomainException,
    QueryInvocationTargetException {
  switch (this.queryAPI) {
    case QueryPrms.MYSQL:
    case QueryPrms.MYSQLC:
    case QueryPrms.ORACLE:
    case QueryPrms.GPDB: 
    case QueryPrms.RTE:
    case QueryPrms.GFXD:
      preparedSQLMixQueryQueryData();
      break;
    default:
      unsupported();
  }
}
 
Example #17
Source File: QRegionInterfaceTest.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
public void testUnsupportedExceptionInSubregionsMethod() {
  Region region1 = null;
  Region region2 = null;
  try{
    region1 = CacheUtils.getRegion("/Portfolios").createSubregion("region1", CacheUtils.getRegion("/Portfolios").getAttributes());
    region2 =  CacheUtils.getRegion("/Portfolios").createSubregion("region2", CacheUtils.getRegion("/Portfolios").getAttributes());
  }catch(RegionExistsException ree) {
    fail("Test failed because of Exception= "+ree);
  }
  region1.put("5",new Portfolio(0));
  region1.put("5",new Portfolio(1));
  region2.put("6",new Portfolio(2));
  region2.put("6",new Portfolio(3));
  Query query = CacheUtils.getQueryService().newQuery("select distinct * from /Portfolios.subregions(false) where remove('5')!= null");
  try{
    query.execute();
    assertTrue(!region1.containsKey("5"));
    assertTrue(!region2.containsKey("5"));
    fail("The test should have thrown TypeMismatchException exception");
  }catch (TypeMismatchException tme ) {
    //Test has passed successfuly as this exception is expected
  }catch(Exception e) {
    fail("Test failed because of Exception= "+e);
  }
}
 
Example #18
Source File: PartitionedIndex.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@Override
void lockedQuery(Object key, int operator, Collection results, Set keysToRemove,
    ExecutionContext context ) throws TypeMismatchException
{
  throw new RuntimeException("Not supported on partitioned index");
  
}
 
Example #19
Source File: QueryPerfClient.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public static void preparedMixQueryQueryDataTask() throws SQLException,
    NameResolutionException, TypeMismatchException, FunctionDomainException,
    QueryInvocationTargetException {
  QueryPerfClient c = new QueryPerfClient();
  c.initialize(QUERIES);
  c.initAdditionalLocalParameters();
  c.preparedMixQueryQueryData();
}
 
Example #20
Source File: AbstractIndex.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public boolean removeFromKeysToRemove(Collection keysToRemove, Object key) {
  Iterator iterator = keysToRemove.iterator();
  while (iterator.hasNext()) {
    try {
      if (TypeUtils.compare(key, iterator.next(), OQLLexerTokenTypes.TOK_EQ).equals(Boolean.TRUE)) {
        iterator.remove();
        return true;
      }
    }
    catch (TypeMismatchException e) {
      //they are not equals, so we just continue iterating
    }
  }
  return false;
}
 
Example #21
Source File: PrimaryKeyIndex.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@Override
void lockedQuery(Object lowerBoundKey, int lowerBoundOperator,
    Object upperBoundKey, int upperBoundOperator, Collection results,
    Set keysToRemove, ExecutionContext context) throws TypeMismatchException {
  throw new UnsupportedOperationException(
      LocalizedStrings.PrimaryKeyIndex_FOR_A_PRIMARYKEY_INDEX_A_RANGE_HAS_NO_MEANING
        .toLocalizedString());

}
 
Example #22
Source File: PartitionedIndex.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/**
 * Not supported on partitioned index.
 */
@Override
void lockedQuery(Object lowerBoundKey, int lowerBoundOperator,
    Object upperBoundKey, int upperBoundOperator, Collection results,
    Set keysToRemove, ExecutionContext context) throws TypeMismatchException
{
  throw new RuntimeException(LocalizedStrings.PartitionedIndex_NOT_SUPPORTED_ON_PARTITIONED_INDEX.toLocalizedString());

}
 
Example #23
Source File: MapRangeIndex.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public int getSizeEstimate(Object key, int op, int matchLevel)
    throws TypeMismatchException
{
  Object[] mapKeyAndVal = (Object[])key;
  Object mapKey = mapKeyAndVal[1];
  RangeIndex ri = this.mapKeyToValueIndex.get(mapKey);
  if (ri != null) {
    return ri.getSizeEstimate(mapKeyAndVal[0], op, matchLevel);
  }
  else {
    return 0;
  }
}
 
Example #24
Source File: CompiledLike.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
OrganizedOperands organizeOperands(ExecutionContext context,
    boolean completeExpansionNeeded, RuntimeIterator[] indpndntItrs)
    throws FunctionDomainException, TypeMismatchException,
    NameResolutionException, QueryInvocationTargetException {
  CompiledComparison[] cvs = getExpandedOperandsWithIndexInfoSetIfAny(context);
  Filter filter = null;
  if (cvs.length == 1) {
    // For the equality condition
    if (getOperator() == OQLLexerTokenTypes.TOK_NE) {
      cvs[0].negate();
    }
    filter = cvs[0];
  } else {
    // 2 or 3 conditions; create junctions
    if ((getOperator() == OQLLexerTokenTypes.TOK_NE)
        && (wildcardPosition == patternLength - 1)
        && (wildcardType == WILDCARD_PERCENT)) {
      // negation supported only for trailing %
      // GroupJunction is created since the boundary conditions go out of
      // range and will be evaluated as false if a RangeJunction was used
      // For example, for NOT LIKE a%, the CCs generated would be < A OR >= B
      // which would cause the checkForRangeBoundednessAndTrimNotEqualKeyset
      // method of RangeJunction to return false
      filter = new GroupJunction(OQLLexerTokenTypes.LITERAL_or, indpndntItrs,
          completeExpansionNeeded, cvs);

    } else {
      filter = new RangeJunction(OQLLexerTokenTypes.LITERAL_and,
          indpndntItrs, completeExpansionNeeded, cvs);
    }
  }
 
  OrganizedOperands result = new OrganizedOperands();
  result.isSingleFilter = true;
  result.filterOperand = filter;
  return result;
}
 
Example #25
Source File: RangeJunction.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public boolean isBetterFilter(Filter comparedTo, ExecutionContext context, final 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;
      case LITERAL_and:
       //Asif: What to do? Let current be the better one for the want of better estimation
       break;
      case TOK_LE:
      case TOK_LT:
      case TOK_GE:
      case TOK_GT:
        //Give preference to this rather than single condition inequalities as a rangejunction
        //would possibly be bounded resulting in lesser values
        break;
      default :
          throw  new IllegalArgumentException("The operator type ="+ thatOperator + " is unknown");
  }          
    
  return isThisBetter;
}
 
Example #26
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 #27
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 #28
Source File: AbstractIndex.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
void applyProjection(List projAttrib, ExecutionContext context,
    Collection result, Object iterValue, SelectResults intermediateResults,
    boolean isIntersection) throws FunctionDomainException,
    TypeMismatchException, NameResolutionException,
    QueryInvocationTargetException
{
  if (projAttrib == null) {
    this.addToResultsBagWithUnionOrIntersection(result, intermediateResults,
        isIntersection, iterValue);
  }
  else {
    if (result instanceof StructBag || result instanceof LinkedStructSet) {
      int projCount = projAttrib.size();
      Object[] values = new Object[projCount];
      Iterator projIter = projAttrib.iterator();
      int i = 0;
      while (projIter.hasNext()) {
        Object projDef[] = (Object[])projIter.next();
        values[i++] = ((CompiledValue)projDef[1]).evaluate(context);
      }
      this.addToStructBagWithUnionOrIntersection(result, intermediateResults,
          isIntersection, values);
    }
    else {
      Object[] temp = (Object[])projAttrib.get(0);
      Object val = ((CompiledValue)temp[1]).evaluate(context);
      this.addToResultsBagWithUnionOrIntersection(result,
          intermediateResults, isIntersection, val);
    }
  }
}
 
Example #29
Source File: CompiledComparison.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@Override
public SelectResults auxFilterEvaluate(ExecutionContext context,
    SelectResults intermediateResults) throws FunctionDomainException,
    TypeMismatchException, NameResolutionException,
    QueryInvocationTargetException {
  Support
      .assertionFailed(" This auxFilterEvaluate of CompiledComparison should never have got invoked.");
  return null;
}
 
Example #30
Source File: RangeJunction.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public Object evaluate(ExecutionContext context) throws TypeMismatchException, FunctionDomainException, NameResolutionException, QueryInvocationTargetException {
  Object evaluatedPath = this.indxInfo._path.evaluate(context);
  Boolean result =(Boolean) super.evaluate(context,evaluatedPath);
  if( result.booleanValue()) {
	  result = (Boolean)TypeUtils.compare(evaluatedPath, this.condnKey, this.condnOp);
  }
  return result;
}