@Override public Object evaluate(ExecutionContext context) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { boolean b = _value.evaluate(context) == QueryService.UNDEFINED; return Boolean.valueOf(_is_defined ? !b : b); }
/** * Returns an unmodifiable Set containing the Region names which are present in the Query. A * region which is associated with the query as a bind parameter will not be included in the list. * The Region names returned by the query do not indicate anything about the state of the region * or whether the region actually exists in the GemfireCache etc. * * @param parameters the parameters to be passed in to the query when executed * @return Unmodifiable List containing the region names. */ public Set<String> getRegionsInQuery(Object[] parameters) { Set<String> regions = new HashSet<>(); this.compiledQuery.getRegionsInQuery(regions, parameters); return Collections.unmodifiableSet(regions); }
@Override public boolean hasIdentifierAtLeafNode() { if (this.receiver.getType() == Identifier) { return true; } else { return this.receiver.hasIdentifierAtLeafNode(); } }
@Override public boolean isProjectionEvaluationAPossibility(ExecutionContext context) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { for (int i = 0; i < this._operands.length; ++i) { // LIKE gives rise to a JUNCTION in CompiledLike whether wildcard is present or not if ((this._operands[i].getType() == JUNCTION || this._operands[i].getType() == LIKE) && this._operands[i].getPlanInfo(context).evalAsFilter) { return false; } } return true; }
static CompiledID getCompiledIdFromPath(CompiledValue path) { int type = path.getType(); if (type == OQLLexerTokenTypes.Identifier) { return (CompiledID) path; } return getCompiledIdFromPath(path.getReceiver()); }
for (int i = 0; i < _operands.length; i++) { CompiledValue operand = _operands[i]; if (operand.getPlanInfo(context).evalAsFilter) { Indexable cc = (Indexable) operand; if (indxInfo == null) { Object evaluatedCCKey = ccKey.evaluate(context); int operator = ((CompiledComparison) cc).reflectOnOperator(ccKey); if (evaluatedCCKey == null) { } else if (!_operands[i].isDependentOnCurrentScope(context)) {
expr.generateCanonicalizedExpression(sb, this.context); sb.append('[').append('*').append(']'); expr.generateCanonicalizedExpression(sb, this.context); this.mapKeys = new Object[indexingKeys.size()]; expr = mi.getReceiverSansIndexArgs(); expr.generateCanonicalizedExpression(sb, this.context); sb.append('['); String prefixStr = sb.toString(); for (int j = 0; j < size; ++j) { CompiledValue cv = indexingKeys.get(size - j - 1); this.mapKeys[size - j - 1] = cv.evaluate(this.context); StringBuilder sb3 = new StringBuilder(); cv.generateCanonicalizedExpression(sb3, this.context); sb3.insert(0, prefixStr); sb3.append(']'); this.multiIndexKeysPattern[j] = sb3.toString(); cv.generateCanonicalizedExpression(sb2, this.context); sb2.insert(0, ','); expr.generateCanonicalizedExpression(sb, this.context);
private boolean checkProjectionInGroupBy(Object[] projElem, ExecutionContext context) throws AmbiguousNameException, TypeMismatchException, NameResolutionException { boolean found = false; StringBuilder projAttribBuffer = new StringBuilder(); CompiledValue cvProj = (CompiledValue) TypeUtils.checkCast(projElem[1], CompiledValue.class); cvProj.generateCanonicalizedExpression(projAttribBuffer, context); String projAttribStr = projAttribBuffer.toString(); if (this.groupBy != null) { for (CompiledValue grpBy : this.groupBy) { if (grpBy.getType() == OQLLexerTokenTypes.Identifier) { if (projElem[0] != null && projElem[0].equals(((CompiledID) grpBy).getId())) { found = true; break; } } // the grpup by expr is not an alias check for path StringBuilder groupByExprBuffer = new StringBuilder(); grpBy.generateCanonicalizedExpression(groupByExprBuffer, context); final String grpByExprStr = groupByExprBuffer.toString(); if (projAttribStr.equals(grpByExprStr)) { found = true; break; } } } return found; }
@Override public Set computeDependencies(ExecutionContext context) throws TypeMismatchException, AmbiguousNameException, NameResolutionException { context.addDependencies(this, _left.computeDependencies(context)); return context.addDependencies(this, _right.computeDependencies(context)); }
@Override public void generateCanonicalizedExpression(StringBuilder clauseBuffer, ExecutionContext context) throws AmbiguousNameException, TypeMismatchException, NameResolutionException { // Asif: The canonicalization of Index operator will be of // the form IterX.getPositions[IterY.a.b.c] clauseBuffer.insert(0, ']'); indexExpr.generateCanonicalizedExpression(clauseBuffer, context); clauseBuffer.insert(0, '['); receiver.generateCanonicalizedExpression(clauseBuffer, context); }
if (!operand.isDependentOnCurrentScope(context)) { indexCount++; if (operand.getPlanInfo(context).evalAsFilter) { if (operand.getType() == LIKE && this._operator == OQLLexerTokenTypes.LITERAL_and && ((CompiledLike) operand).getOperator() != OQLLexerTokenTypes.TOK_NE) { expandedOperands = boolean operandEvalAsFilter = expndOperand.getPlanInfo(context).evalAsFilter; isJunctionNeeded = isJunctionNeeded || operandEvalAsFilter; Set set = QueryUtils.getCurrentScopeUltimateRuntimeIteratorsIfAny(expndOperand, context);
this.compiledQuery.computeDependencies(context); if (testHook != null) { testHook.doTestHook(DefaultQuery.TestHook.SPOTS.BEFORE_QUERY_EXECUTION, this); results = this.compiledQuery.evaluate(context); } catch (QueryExecutionCanceledException ignore) { reinterpretQueryExecutionCanceledException();
private boolean isCompiledPath(CompiledValue cv) { return cv.getType() == CompiledValue.PATH; }
@Test @Parameters(method = "getCompiledValuesWhichDoNotImplementGetReceiver") public void whenGetReceiverIsNotImplementedThenHasIdentifierAtLeafMustReturnFalse( CompiledValue compiledValue) { assertFalse(compiledValue.hasIdentifierAtLeafNode()); }
@Override public List getPathOnIterator(RuntimeIterator itr, ExecutionContext context) throws TypeMismatchException, AmbiguousNameException { if (!isDependentOnIterator(itr, context)) return null; List list = new ArrayList(); list.add(getTailID()); CompiledValue v = getReceiver(); int type = v.getType(); while (type == PATH) { CompiledPath p = (CompiledPath) v; list.add(0, p.getTailID()); v = p.getReceiver(); type = v.getType(); } ; if (type == Identifier) { List path = v.getPathOnIterator(itr, context); if (path == null) return null; list.addAll(0, path); return list; } return null; }
if (_operands[i].getPlanInfo(context).evalAsFilter) { indexCount++; evalOperands.add(0, _operands[i]); PlanInfo pi = _operands[i].getPlanInfo(context); } else if (!_operands[i].isDependentOnCurrentScope(context)) {
@Override public PlanInfo getPlanInfo(ExecutionContext context) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { /* * This function would be called only if the RangeJunction is a part of GroupJunction.It would * be invoked in the organized operands method of GroupJunction. In such case it is guaranteed * that all the operands are the filter operand using the same index. In such case there is zero * possibility o first iterator being either an iter operand or a constant. As those types of * Operands would be part of Group Junction */ return this._operands[0].getPlanInfo(context); }
private String getReceiverNameFromPath(CompiledValue path) { if (path instanceof CompiledID) { return ((CompiledID) path).getId(); } else if (path instanceof CompiledPath) { return getReceiverNameFromPath(path.getReceiver()); } else if (path instanceof CompiledOperation) { return getReceiverNameFromPath(path.getReceiver()); } else if (path instanceof CompiledIndexOperation) { return getReceiverNameFromPath(path.getReceiver()); } return ""; }
private ObjectType getFieldTypeOfProjAttrib(ExecutionContext context, CompiledValue cv) throws TypeMismatchException, AmbiguousNameException { // Identify the RuntimeIterator for the compiled value ObjectType retType = TypeUtils.OBJECT_TYPE; try { RuntimeIterator rit = context.findRuntimeIterator(cv); List pathOnItr = cv.getPathOnIterator(rit, context); if (pathOnItr != null) { String path[] = (String[]) pathOnItr.toArray(new String[pathOnItr.size()]); ObjectType ot[] = PathUtils.calculateTypesAlongPath(context, rit.getElementType(), path); retType = ot[ot.length - 1]; } } catch (NameNotFoundException ignore) { // Unable to determine the type Of attribute.It will default to // ObjectType } return retType; }
ObjectType getCollectionElementTypeCast() throws TypeMismatchException { ObjectType typ = this.collectionExpr.getTypecast(); if (typ != null) { if (!(typ instanceof CollectionType)) { throw new TypeMismatchException( String.format("An iterator definition must be a collection type, not a %s", typ)); } if (typ instanceof MapType) { // we iterate over map entries return ((MapType) typ).getEntryType(); } return ((CollectionType) typ).getElementType(); } return null; }