private boolean matchingPathIds(String receiverId, CompiledValue cv) { if (isCompiledPath(cv)) { CompiledPath path = (CompiledPath) cv; return receiverId.equals(QueryUtils.getCompiledIdFromPath(path).getId()); } return false; }
@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; }
public void addDerivedResults(IndexInfo indexInfo, SelectResults selectResults) { IndexProtocol index = indexInfo._index; String key = QueryUtils.getCompiledIdFromPath(indexInfo._path).getId() + ":" + index.getCanonicalizedIteratorDefinitions()[0]; if (derivedResults.containsKey(key)) { for (Object result : selectResults) { if (!derivedResults.get(key).contains(result)) { derivedResults.get(key).add(result); } } } else { derivedResults.put(key, selectResults); } newDerivatives.add( new Object[] {QueryUtils.getCompiledIdFromPath(indexInfo._path).getId(), selectResults}); successfulOps.add(currentOp); }
public void projection() { // find an id or null on the stack, then an expr CompiledValue // push an Object[2] on the stack. First element is id, second is CompiledValue CompiledID id = (CompiledID) pop(); CompiledValue expr = (CompiledValue) pop(); push(new Object[] {id == null ? null : id.getId(), expr}); }
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 { CompiledValue v = context.resolve(getId()); return context.addDependencies(this, v.computeDependencies(context)); }
name = ((CompiledPath) projExpr).getTailID(); } else if (type == Identifier) { name = ((CompiledID) projExpr).getId(); } else if (type == LITERAL) { name = (((CompiledLiteral) projExpr)._obj).toString();
if (prj[0] != null) { if (groupByAttr instanceof CompiledID) { if (prj[0].equals(((CompiledID) groupByAttr).getId())) { lhsBuffer.delete(0, lhsBuffer.length()); rhsBuffer.delete(0, rhsBuffer.length());
case OQLLexerTokenTypes.Identifier: CompiledID cid = (CompiledID) expr; expr = context.resolve(cid.getId()); break; default:
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); } } }
@Override public Object evaluate(ExecutionContext context) throws FunctionDomainException, TypeMismatchException, NameResolutionException, QueryInvocationTargetException { CompiledValue v = context.resolve(getId()); Object obj = v.evaluate(context); // check for BucketRegion substitution PartitionedRegion pr = context.getPartitionedRegion(); if (pr != null && (obj instanceof Region)) { if (pr.getFullPath().equals(((Region) obj).getFullPath())) { obj = context.getBucketRegion(); } } return obj; }
String id = ((CompiledID) this.elm).getId(); if (id.equals("key") || id.equals("getKey")) { resolution = context.resolve(id); CompiledValue cVal = cPath.getReceiver(); if (cVal instanceof CompiledID) { resolution = context.resolve(((CompiledID) cVal).getId()); if (cOp.getMethodName().equals("key") || cOp.getMethodName().equals("getKey")) { if (cOp.getReceiver(context) instanceof CompiledID) { resolution = context.resolve(((CompiledID) cOp.getReceiver(context)).getId()); } else if (cOp.getReceiver(context) == null) { match = true; // implicit operation on the iterator
if (prj[0] != null && prj[0].equals(((CompiledID) expr).getId())) {
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 ""; }
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)); }
expr = context.resolve(((CompiledID) expr).getId()); } else if (expr instanceof CompiledRegion) { QRegion qrgn = (QRegion) ((CompiledRegion) expr).evaluate(context);
public void methodInvocation() { // find on stack: // argList, methodName, receiver (which may be null if receiver is implicit) List argList = (List) TypeUtils.checkCast(pop(), List.class); CompiledID methodName = (CompiledID) TypeUtils.checkCast(pop(), CompiledID.class); CompiledValue rcvr = (CompiledValue) TypeUtils.checkCast(pop(), CompiledValue.class); push(new CompiledOperation(rcvr, methodName.getId(), argList)); }
CompiledValue expr = resolve(((CompiledID) path).getId()); return findIterator(expr);
CompiledValue path = currentLevel.getCmpIteratorDefn().getCollectionExpr(); if (useDerivedResults && derivedResults != null && path.hasIdentifierAtLeafNode()) { key = getCompiledIdFromPath(path).getId() + ':' + currentLevel.getDefinition(); if (derivedResults.containsKey(key)) {