@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); }
@Override public void generateCanonicalizedExpression(StringBuilder clauseBuffer, ExecutionContext context) throws AmbiguousNameException, TypeMismatchException, NameResolutionException { clauseBuffer.insert(0, ')'); _value.generateCanonicalizedExpression(clauseBuffer, context); clauseBuffer.insert(0, "NOT("); }
String genFromClause(ExecutionContext context) throws AmbiguousNameException, TypeMismatchException, NameResolutionException { StringBuilder sbuff = new StringBuilder(); collectionExpr.generateCanonicalizedExpression(sbuff, context); return sbuff.toString(); }
@Override public void generateCanonicalizedExpression(StringBuilder clauseBuffer, ExecutionContext context) throws AmbiguousNameException, TypeMismatchException, NameResolutionException { clauseBuffer.insert(0, ')'); _value.generateCanonicalizedExpression(clauseBuffer, context); if (_is_defined) clauseBuffer.insert(0, "IS_DEFINED("); else clauseBuffer.insert(0, "IS_UNDEFINED("); }
private void evalCanonicalizedExpressionForCSC(CompiledSortCriterion csc, ExecutionContext context, StringBuilder buffer) throws TypeMismatchException, NameResolutionException { csc.getExpr().generateCanonicalizedExpression(buffer, context); }
@Override public void generateCanonicalizedExpression(StringBuilder clauseBuffer, ExecutionContext context) throws AmbiguousNameException, TypeMismatchException, NameResolutionException { // The compiled ID can be an iterator variable or it can be a path variable. // So first resolve the type of variable using ExecutionContext // A compiledID will get resolved either to a RunTimeIterator or a CompiledPath context.resolve(_id).generateCanonicalizedExpression(clauseBuffer, context); }
@Override public void generateCanonicalizedExpression(StringBuilder clauseBuffer, ExecutionContext context) throws AmbiguousNameException, TypeMismatchException, NameResolutionException { // Asif: Canonicalize the tail ID. If the tail ID contains // something like getX ,convert it into x. int len; if (_tailID.startsWith("get") && (len = _tailID.length()) > 3) { clauseBuffer.insert(0, len > 4 ? _tailID.substring(4) : ""); clauseBuffer.insert(0, Character.toLowerCase(_tailID.charAt(3))); } else { clauseBuffer.insert(0, _tailID); } clauseBuffer.insert(0, '.'); _receiver.generateCanonicalizedExpression(clauseBuffer, context); } }
@Override public void generateCanonicalizedExpression(StringBuilder clauseBuffer, ExecutionContext context) throws AmbiguousNameException, TypeMismatchException, NameResolutionException { clauseBuffer.insert(0, ')'); if (this.expr != null) { this.expr.generateCanonicalizedExpression(clauseBuffer, context); } else { clauseBuffer.insert(0, '*'); } if (this.distinctOnly) { clauseBuffer.insert(0, "distinct "); } clauseBuffer.insert(0, '('); clauseBuffer.insert(0, getStringRep()); } }
@Override public void generateCanonicalizedExpression(StringBuilder clauseBuffer, ExecutionContext context) throws AmbiguousNameException, TypeMismatchException, NameResolutionException { clauseBuffer.insert(0, ')'); int len = this._args.length; for (int i = len - 1; i > 0; i--) { _args[i].generateCanonicalizedExpression(clauseBuffer, context); clauseBuffer.insert(0, ','); } _args[0].generateCanonicalizedExpression(clauseBuffer, context); switch (this._function) { case LITERAL_nvl: clauseBuffer.insert(0, "NVL("); break; case LITERAL_element: clauseBuffer.insert(0, "ELEMENT("); break; case LITERAL_to_date: clauseBuffer.insert(0, "TO_DATE("); break; default: super.generateCanonicalizedExpression(clauseBuffer, context); } } }
@Override public boolean isMatchingWithIndexExpression(CompiledValue condnExpr, String conditionExprStr, ExecutionContext context) throws AmbiguousNameException, TypeMismatchException, NameResolutionException { if (this.isAllKeys) { // check if the conditionExps is of type MapIndexable.If yes then check // the canonicalized string // stripped of the index arg & see if it matches. if (condnExpr instanceof MapIndexable) { MapIndexable mi = (MapIndexable) condnExpr; CompiledValue recvr = mi.getReceiverSansIndexArgs(); StringBuilder sb = new StringBuilder(); recvr.generateCanonicalizedExpression(sb, context); sb.append('[').append(']'); return sb.toString().equals(this.patternStr[0]); } else { return false; } } else { for (String expr : this.patternStr) { if (expr.equals(conditionExprStr)) { return true; } } return false; } }
for (int j = this.args.size(); j > 0;) { cv = (CompiledValue) this.args.get(--j); cv.generateCanonicalizedExpression(clauseBuffer, context); clauseBuffer.insert(0, ','); rcvr.generateCanonicalizedExpression(clauseBuffer, 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; }
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()})); } }
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(); 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);
cvProj.generateCanonicalizedExpression(lhsBuffer, context); groupByAttr.generateCanonicalizedExpression(rhsBuffer, context); if (lhsBuffer.length() == rhsBuffer.length()) { for (int indx = 0; indx < lhsBuffer.length(); ++indx) {
ListIterator<CompiledValue> listIter = expressions.listIterator(expressions.size()); while (listIter.hasPrevious()) { listIter.previous().generateCanonicalizedExpression(tempBuff, context); if (tempBuff.toString().equals(projAttribStr)) {
Iterator it = this.indexes.values().iterator(); StringBuilder sb = new StringBuilder(); indexedExpression.generateCanonicalizedExpression(sb, context); String indexExprStr = sb.toString(); while (it.hasNext()) {
expr.generateCanonicalizedExpression(orderByExprBuffer, context); final String orderByExprStr = orderByExprBuffer.toString(); for (int i = 0; i < projAttrs.size(); ++i) { Object[] prj = (Object[]) TypeUtils.checkCast(projAttrs.get(i), Object[].class); CompiledValue cvProj = (CompiledValue) TypeUtils.checkCast(prj[1], CompiledValue.class); cvProj.generateCanonicalizedExpression(projAttribBuffer, context); final String projAttribStr = projAttribBuffer.toString(); if (projAttribStr.equals(orderByExprStr)) { expr.generateCanonicalizedExpression(temp, context); String orderbyStr = temp.toString(); if (projAttribStr.equals(orderbyStr)) {
CompiledValue cv1 = (CompiledValue) aList; StringBuilder sb = new StringBuilder(); cv1.generateCanonicalizedExpression(sb, context); if (sb.toString().startsWith(this.canonicalizedIteratorNames[0])) { newList.add(getModifiedDependentCompiledValue(context, currItrID, cv1, true)); CompiledValue cv1 = cvArray[i]; StringBuilder sb = new StringBuilder(); cv1.generateCanonicalizedExpression(sb, context); if (sb.toString().startsWith(this.canonicalizedIteratorNames[0])) { newCvArray[i] = getModifiedDependentCompiledValue(context, currItrID, cv1, true); CompiledValue cv1 = co.getExpression(); StringBuilder sb = new StringBuilder(); cv1.generateCanonicalizedExpression(sb, context); if (sb.toString().startsWith(this.canonicalizedIteratorNames[0])) { cv1 = getModifiedDependentCompiledValue(context, currItrID, cv1, true);
Iterator iter = this.indexes.values().iterator(); StringBuilder sb = new StringBuilder(); indexedExpression.generateCanonicalizedExpression(sb, context); String indexExprStr = sb.toString(); PartitionedIndex prIndex = null;