private boolean isCompiledPath(CompiledValue cv) { return cv.getType() == CompiledValue.PATH; }
@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; }
@Override public boolean hasIdentifierAtLeafNode() { if (this.receiver.getType() == Identifier) { return true; } else { return this.receiver.hasIdentifierAtLeafNode(); } }
private LinkedHashMap<Integer, CompiledAggregateFunction> identifyAggregateExpressions( List projAttribs) { if (projAttribs != null) { LinkedHashMap<Integer, CompiledAggregateFunction> mapping = new LinkedHashMap<Integer, CompiledAggregateFunction>(); int index = 0; for (Object o : projAttribs) { CompiledValue proj = (CompiledValue) ((Object[]) o)[1]; if (proj.getType() == OQLLexerTokenTypes.AGG_FUNC) { mapping.put(index, (CompiledAggregateFunction) proj); } ++index; } return mapping.size() == 0 ? null : mapping; } else { return null; } }
@Override public boolean hasIdentifierAtLeafNode() { if (this.receiver.getType() == Identifier) { return true; } else { return this.receiver.hasIdentifierAtLeafNode(); } }
@Override public boolean hasIdentifierAtLeafNode() { if (this._receiver.getType() == Identifier) { return true; } else { return this._receiver.hasIdentifierAtLeafNode(); } }
/** * Creates appropriate CompiledValue for the like predicate based on the sargability of the String * or otherwise. It also works on the last character to see if the sargable like predicate results * in a CompiledJunction or a Comparison. Currently we are supporting only the '%' terminated * "like" predicate. * * @param var The CompiledValue representing the variable * @param patternOrBindParam The CompiledLiteral reprsenting the pattern of the like predicate * @return CompiledValue representing the "like" predicate * */ CompiledValue createCompiledValueForLikePredicate(CompiledValue var, CompiledValue patternOrBindParam) { if (!(patternOrBindParam.getType() == CompiledBindArgument.QUERY_PARAM)) { CompiledLiteral pattern = (CompiledLiteral) patternOrBindParam; if (pattern._obj == null) { throw new UnsupportedOperationException( "Null values are not supported with LIKE predicate."); } } // From 6.6 Like is enhanced to support special character (% and _) at any // position of the string. return new CompiledLike(var, patternOrBindParam); }
static CompiledID getCompiledIdFromPath(CompiledValue path) { int type = path.getType(); if (type == OQLLexerTokenTypes.Identifier) { return (CompiledID) path; } return getCompiledIdFromPath(path.getReceiver()); }
private void createDerivedJoinResultsFromOpsList(String theCallingIndexId, ExecutionContext context, List opsList) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { Iterator iter = opsList.iterator(); while (iter.hasNext()) { CompiledValue cv = (CompiledValue) iter.next(); this.currentOp = cv; if (cv.getType() == CompiledValue.COMPARISON) { createDerivedJoinResultsFromCC(theCallingIndexId, (CompiledComparison) cv, context); } } // Now let's derive from our derivatives (for multiple join clauses that can be chained, such as // a.id = 1 and a.id = b.id and b.id = c.id List<Object[]> newDerivatives = new ArrayList<Object[]>(this.newDerivatives); this.newDerivatives.clear(); if (newDerivatives.size() > 0) { Iterator<Object[]> iterator = newDerivatives.iterator(); while (iterator.hasNext()) { Object[] idDerivedAndResults = iterator.next(); derivedDerivative(idDerivedAndResults, context, this.getExpansionList()); } } }
@Override public List getPathOnIterator(RuntimeIterator itr, ExecutionContext context) throws TypeMismatchException, AmbiguousNameException { CompiledValue val = context.resolve(getId()); if (val == itr) return new ArrayList(); // empty path if (val.getType() == PATH && ((CompiledPath) val).getReceiver() == itr) { List list = new ArrayList(); list.add(_id); return list; } return null; }
private void prepareIndexExpression(String indexedExpression) throws IndexInvalidException { List indexedExprs = this.compiler.compileProjectionAttributes(indexedExpression); if (indexedExprs == null || indexedExprs.size() != 1) { throw new IndexInvalidException( String.format("Invalid indexed expressoion : ' %s '", indexedExpression)); } CompiledValue expr = (CompiledValue) ((Object[]) indexedExprs.get(0))[1]; if (expr.getType() == CompiledValue.LITERAL) throw new IndexInvalidException( String.format("Invalid indexed expressoion : ' %s '", indexedExpression)); try { StringBuilder sb = new StringBuilder(); expr.generateCanonicalizedExpression(sb, context); this.indexedExpression = sb.toString(); } catch (Exception e) { throw new IndexInvalidException( String.format("Invalid indexed expressoion : ' %s ' %s", new Object[] {indexedExpression, e.getMessage()})); } }
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 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; }
int type = projExpr.getType(); if (type == PATH) { name = ((CompiledPath) projExpr).getTailID();
for (int i = 0; i < this._operands.length; ++i) { PlanInfo pi = this._operands[i].getPlanInfo(context); if (pi.evalAsFilter && this._operands[i].getType() == JUNCTION) { return false; } else if (pi.evalAsFilter) {
indexExpr = (CompiledValue) TypeUtils.checkCast(indexList.get(0), CompiledValue.class); if (indexExpr.getType() == TOK_COLON) { throw new UnsupportedOperationException( "Ranges not supported in index operators");
private Region getRegionFromPath(String imports, String fromClause) throws RegionNotFoundException { QCompiler compiler = new QCompiler(); if (imports != null) { compiler.compileImports(imports); } List list = compiler.compileFromClause(fromClause); CompiledValue cv = QueryUtils .obtainTheBottomMostCompiledValue(((CompiledIteratorDef) list.get(0)).getCollectionExpr()); String regionPath = null; if (cv.getType() == OQLLexerTokenTypes.RegionPath) { regionPath = ((CompiledRegion) cv).getRegionPath(); } else { throw new RegionNotFoundException( String.format( "DefaultQueryService::createIndex:First Iterator of Index >From Clause does not evaluate to a Region Path. The from clause used for Index creation is %s", fromClause)); } Region region = cache.getRegion(regionPath); if (region == null) { throw new RegionNotFoundException( String.format("Region ' %s ' not found: from %s", new Object[] {regionPath, fromClause})); } return region; }
for (int i = 0; i < this._operands.length; ++i) { if (this._operands[i].getPlanInfo(context).evalAsFilter && this._operands[i].getType() == JUNCTION) { return false; } else if (this._operands[i].getPlanInfo(context).evalAsFilter) {
if (path.getType() == OQLLexerTokenTypes.Identifier || itr.getName().equals(pathName)) { return itr;
public void computeDerivedJoinResults(IndexInfo theCallingIndex, ExecutionContext context, CompiledValue iterOps) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { // Call this computeDerivedResults() // We are looking for join conditions so we can filter eval instead of iterate eval // Then we can apply the rest of the ops on the results if (theCallingIndex != null && iterOps != null) { if (iterOps instanceof CompiledJunction) { List opsList = ((CompiledJunction) iterOps).getOperands(); this.setOriginalOps(opsList); createDerivedJoinResultsFromOpsList( (QueryUtils.getCompiledIdFromPath(theCallingIndex._path)).getId(), context, opsList); } else if (iterOps.getType() == CompiledValue.COMPARISON) { createDerivedJoinResultsFromCC( (QueryUtils.getCompiledIdFromPath(theCallingIndex._path)).getId(), (CompiledComparison) iterOps, context); } } }