public boolean isEarlyCalculated(OCommandContext ctx) { for (OExpression exp : expressions) { if (!exp.isEarlyCalculated(ctx)) { return false; } } return true; }
@Override public boolean isEarlyCalculated(OCommandContext ctx) { // TODO implement query execution and early calculation; return expression != null && expression.isEarlyCalculated(ctx); }
public boolean isEarlyCalculated(OCommandContext ctx) { if (isTraverseFunction()) return false; for (OExpression param : params) { if (!param.isEarlyCalculated(ctx)) { return false; } } return true; }
private Map<String, Object> getEqualityOperations(OAndBlock condition, OCommandContext ctx) { Map<String, Object> result = new HashMap<String, Object>(); for (OBooleanExpression expression : condition.subBlocks) { if (expression instanceof OBinaryCondition) { OBinaryCondition b = (OBinaryCondition) expression; if (b.operator instanceof OEqualsCompareOperator) { if (b.left.isBaseIdentifier() && b.right.isEarlyCalculated(ctx)) { result.put(b.left.toString(), b.right.execute((OResult) null, ctx)); } } } } return result; }
public OCollection splitForAggregation(AggregateProjectionSplit aggregateProj, OCommandContext ctx) { if (isAggregate()) { OCollection result = new OCollection(-1); for (OExpression exp : this.expressions) { if (exp.isAggregate() || exp.isEarlyCalculated(ctx)) { result.expressions.add(exp.splitForAggregation(aggregateProj, ctx)); } else { throw new OCommandExecutionException("Cannot mix aggregate and non-aggregate operations in a collection: " + toString()); } } return result; } else { return this; } }
/** * splits LET clauses in global (executed once) and local (executed once per record) */ private static void splitLet(QueryPlanningInfo info, OCommandContext ctx) { if (info.perRecordLetClause != null && info.perRecordLetClause.getItems() != null) { Iterator<OLetItem> iterator = info.perRecordLetClause.getItems().iterator(); while (iterator.hasNext()) { OLetItem item = iterator.next(); if (item.getExpression() != null && item.getExpression().isEarlyCalculated(ctx)) { iterator.remove(); addGlobalLet(info, item.getVarName(), item.getExpression()); } else if (item.getQuery() != null && !item.getQuery().refersToParent()) { iterator.remove(); addGlobalLet(info, item.getVarName(), item.getQuery()); } } } }
@Override public OBooleanExpression rewriteIndexChainsAsSubqueries(OCommandContext ctx, OClass clazz) { if (operator instanceof OEqualsCompareOperator && right.isEarlyCalculated(ctx) && left.isIndexChain(ctx, clazz)) { OInCondition result = new OInCondition(-1); result.left = new OExpression(-1); OBaseExpression base = new OBaseExpression(-1); base.identifier = new OBaseIdentifier(-1); base.identifier.suffix = new OSuffixIdentifier(-1); base.identifier.suffix.identifier = ((OBaseExpression) left.mathExpression).identifier.suffix.identifier; result.left.mathExpression = base; result.operator = new OInOperator(-1); OClass nextClazz = clazz.getProperty(base.identifier.suffix.identifier.getStringValue()).getLinkedClass(); result.rightStatement = indexChainToStatement(((OBaseExpression) left.mathExpression).modifier, nextClazz, right, ctx); return result; } return this; }
if (indexField.equals(fieldName)) { OBinaryCompareOperator operator = ((OBinaryCondition) singleExp).getOperator(); if (!((OBinaryCondition) singleExp).getRight().isEarlyCalculated(ctx)) { continue; //this cannot be used because the value depends on single record String fieldName = left.getDefaultAlias().getStringValue(); if (indexField.equals(fieldName)) { if (!((OContainsAnyCondition) singleExp).getRight().isEarlyCalculated(ctx)) { continue; //this cannot be used because the value depends on single record