if (type.equals(TypeUtils.OBJECT_TYPE)) { ObjectType typc = getCollectionElementTypeCast(); if (typc != null) { type = typc; type = computeElementType(context); String fromClause = genFromClause(context); rIter.setDefinition(fromClause); && !this.isDependentOnAnyIteratorOfScopeLessThanItsOwn(context)) { evaluateCollectionForIndependentIterator(context, rIter);
/** * (Re)evaluate in the context of the current iterations through the cross-product. If this * iterator is not dependent on the current iteration, then just return the previously evaluated * collection. Otherwise, re-evaluate. Returns null if the collection itself is null or UNDEFINED */ public SelectResults evaluateCollection(ExecutionContext context) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { if (this.collection != UNINITIALIZED && !this.cmpIteratorDefn.isDependentOnAnyIteratorOfScopeLessThanItsOwn(context) && this.scopeID != IndexCreationHelper.INDEX_QUERY_SCOPE_ID) { return this.collection; } // limit the scope for evaluation to this RuntimeIterator: // we don't want to use this iterator or subsequent ones in the from clause // to evaluate this collection. this.collection = this.cmpIteratorDefn.evaluateCollection(context, this); if (this.collection == null) { return null; } // if we already have a more specific elementType, set it in the collection if (!this.elementType.equals(TypeUtils.OBJECT_TYPE)) { this.collection.setElementType(elementType); } else { // Asif : The elementType in the Collection obtained is more // specific . So use that type. this.elementType = collection.getCollectionType().getElementType(); } return this.collection; }
RuntimeIterator(CompiledIteratorDef cmpIteratorDefn, ObjectType elementType) { if (elementType == null || cmpIteratorDefn == null) { throw new IllegalArgumentException( "elementType and/or cmpIteratorDefn should not be null"); } this.name = cmpIteratorDefn.getName(); this.elementType = elementType; this.cmpIteratorDefn = cmpIteratorDefn; }
for (int i = 0; i < size; i++) { CompiledIteratorDef iterDef = (CompiledIteratorDef) list.get(i); iterDef.computeDependencies(this.context); RuntimeIterator rIter = iterDef.getRuntimeIterator(this.context); this.context.addToIndependentRuntimeItrMapForIndexCreation(iterDef); this.context.bindIterator(rIter); if (i != 0 && !iterDef.isDependentOnCurrentScope(this.context)) { throw new IndexInvalidException( String.format( CompiledValue cv = iterDef.getCollectionExpr(); this.addnlProjType = rIter.getElementType(); String name = iterDef.getName(); if (isEmpty(name)) { newItr = new CompiledIteratorDef(name, null, newCollExpr); this.indexInitIterators = new ArrayList(); this.indexInitIterators.add(newItr);
Object[] retValues = {null, null}; try { CompiledValue def = iterDef.getCollectionExpr(); if (def instanceof CompiledRegion) { CompiledBindArgument bindArg = new CompiledBindArgument(1); CompiledIteratorDef newDef = new CompiledIteratorDef(iterDef.getName(), null, bindArg); retValues[0] = def.evaluate(this.context); retValues[1] = newDef; CompiledIteratorDef newDef = new CompiledIteratorDef(iterDef.getName(), null, cv); retValues[0] = v.evaluate(this.context); retValues[1] = newDef;
RuntimeIterator rIter = null; if (!this.hasInitOccurredOnce) { iterDef.computeDependencies(this.initContext); rIter = iterDef.getRuntimeIterator(this.initContext); this.initContext.addToIndependentRuntimeItrMapForIndexCreation(iterDef); rIter = iterDef.getRuntimeIterator(this.initContext);
if (iterDef.getCollectionExpr().getType() != OQLLexerTokenTypes.RegionPath) { throw new IndexInvalidException( "The fromClause for a Primary Key index should be a Region Path only"); iterDef.computeDependencies(this.context); RuntimeIterator rIter = (iterDef.getRuntimeIterator(this.context)); String definition = rIter.getDefinition(); this.canonicalizedIteratorDefinitions = new String[1];
@Test public void cacheClosedWhileEvaluateCollectionShouldNotThrowTypeMismatchException() throws Exception { CompiledValue compiledValue = mock(CompiledValue.class); CompiledIteratorDef compiledIteratorDef = new CompiledIteratorDef("TestIterator", TypeUtils.OBJECT_TYPE, compiledValue); ExecutionContext executionContext = mock(ExecutionContext.class); RuntimeIterator runtimeIterator = mock(RuntimeIterator.class); when(runtimeIterator.evaluateCollection(executionContext)) .thenThrow(CacheClosedException.class); try { compiledIteratorDef.evaluateCollectionForIndependentIterator(executionContext, runtimeIterator); fail(); } catch (Exception e) { assertTrue(e instanceof CacheClosedException); } } }
itr = itrDef.getRuntimeIterator(this); set.add(itr); QueryUtils.obtainTheBottomMostCompiledValue(itrDef.getCollectionExpr()); if (startVal.getType() == OQLLexerTokenTypes.RegionPath) { rgnPath = ((QRegion) ((CompiledRegion) startVal).evaluate(this)).getFullPath(); RuntimeIterator currItr = itrDef.getRuntimeIterator(this); currItr.setIndexInternalID((mgr == null || (tempIndexID = mgr.getCanonicalizedIteratorName(itrDef.genFromClause(this))) == null) ? currItr.getInternalId() : tempIndexID);
if (!(itrDef.getCollectionExpr() instanceof CompiledRegion)) { throw new UnsupportedOperationException( "CQ queries must have a region path only as the first iterator in the FROM clause");
/** * 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; }
try { CompiledIteratorDef iterDef = (CompiledIteratorDef) iterators.get(0); RuntimeIterator rIter = iterDef.getRuntimeIterator(context); context.bindIterator(rIter); Object evalResult = iterDef.getCollectionExpr().evaluate(context); if (evalResult == null || evalResult == QueryService.UNDEFINED) { return false;
if (currentLevel.getCmpIteratorDefn().getCollectionExpr() .getType() == OQLLexerTokenTypes.RegionPath) { key = currentLevel.getCmpIteratorDefn().getName() + ':' + currentLevel.getDefinition(); } else if (currentLevel.getCmpIteratorDefn().getCollectionExpr() .getType() == OQLLexerTokenTypes.LITERAL_select) { useDerivedResults = false; CompiledValue path = currentLevel.getCmpIteratorDefn().getCollectionExpr(); if (useDerivedResults && derivedResults != null && path.hasIdentifierAtLeafNode()) { key = getCompiledIdFromPath(path).getId()
public void iteratorDef() { // find type id and colln on the stack ObjectType type = assembleType(); // can be null CompiledID id = (CompiledID) TypeUtils.checkCast(pop(), CompiledID.class); // can be null CompiledValue colln = (CompiledValue) TypeUtils.checkCast(pop(), CompiledValue.class); if (type == null) { type = TypeUtils.OBJECT_TYPE; } push(new CompiledIteratorDef(id == null ? null : id.getId(), type, colln)); }
/** * Evaluate just the collectionExpr * * @param stopAtIter the RuntimeIterator associated with this iterator defn -- don't use this or * any subsequent runtime iterators to evaluate. */ SelectResults evaluateCollection(ExecutionContext context, RuntimeIterator stopAtIter) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { Object coll; context.currentScope().setLimit(stopAtIter); try { coll = this.collectionExpr.evaluate(context); } finally { context.currentScope().setLimit(null); } // if we don't have an elementType and there's a typecast, apply the // element type here if (TypeUtils.OBJECT_TYPE.equals(this.elementType)) { ObjectType elmTypc = getCollectionElementTypeCast(); if (elmTypc != null) { this.elementType = elmTypc; } } // PR bucketRegion substitution should have already happened // at the expression evaluation level return prepareIteratorDef(coll, this.elementType, context); }
itrDef.visitNodes(new CompiledValue.NodeVisitor() { @Override public boolean visit(CompiledValue node) { while (fromClauseIterator.hasNext()) { itrDef = (CompiledIteratorDef) fromClauseIterator.next(); itrDef.getRegionsInQuery(regions, parameters); if (!regions.isEmpty()) { throw new UnsupportedOperationException(
/** Evaluate just the collectionExpr */ SelectResults evaluateCollection(ExecutionContext context) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { return evaluateCollection(context, null); }
return new CompiledIteratorDef(iterDef.getName(), rItr.getElementType(), getModifiedDependentCompiledValue(context, currItrID, iterDef.getCollectionExpr(), isDependent));
RuntimeIterator rIter = null; if (!this.hasInitOccurredOnce) { iterDef.computeDependencies(this.initContext); rIter = iterDef.getRuntimeIterator(this.initContext); this.initContext.addToIndependentRuntimeItrMapForIndexCreation(iterDef); rIter = iterDef.getRuntimeIterator(this.initContext);
CompiledValue colnExpr = cIterDef.getCollectionExpr();