@Override public AbstractLogicalExpression cloneExpression() { VariableReferenceExpression varRef = new VariableReferenceExpression(variable); varRef.setSourceLocation(sourceLoc); return varRef; }
@Override public boolean equals(Object obj) { if (obj instanceof VariableReferenceExpression) { final VariableReferenceExpression varRefExpr = (VariableReferenceExpression) obj; return tupleRef == varRefExpr.tupleRef && variable.equals(varRefExpr.getVariableReference()); } return false; }
@Override public String visitVariableReferenceExpression(VariableReferenceExpression expr, Integer indent) throws AlgebricksException { return expr.toString(); }
@Override public ClosedDataInfo visitVariableReferenceExpression(VariableReferenceExpression expr, Void arg) throws AlgebricksException { Object varType = env.getVarType(expr.getVariableReference()); if (varType == null) { throw new CompilationException(ErrorCode.COMPILATION_ERROR, expr.getSourceLocation(), "Could not infer type for variable '" + expr.getVariableReference() + "'."); } return new ClosedDataInfo(false, TypeHelper.isClosed((IAType) varType), expr); }
@Override public ILogicalExpression visitVariableReferenceExpression(VariableReferenceExpression expr, Void arg) throws AlgebricksException { LogicalVariable var = expr.getVariableReference(); if (freeVars.contains(var)) { return expr; } LogicalVariable givenVarReplacement = inVarMapping.get(var); if (givenVarReplacement != null) { outVarMapping.put(var, givenVarReplacement); VariableReferenceExpression varRef = new VariableReferenceExpression(givenVarReplacement); copySourceLocation(expr, varRef); return varRef; } LogicalVariable varCopy = outVarMapping.get(var); if (varCopy == null) { varCopy = varContext.newVar(); outVarMapping.put(var, varCopy); } VariableReferenceExpression varRef = new VariableReferenceExpression(varCopy); copySourceLocation(expr, varRef); return varRef; } }
if (expr.getExpressionTag() == LogicalExpressionTag.VARIABLE) { VariableReferenceExpression varExpr = (VariableReferenceExpression) expr; LogicalVariable sourceVar = varExpr.getVariableReference(); updateInputToOutputVarMapping(sourceVar, keyVarExprRef.first, false); groupKeyVars.add(keyVarExprRef.first); if (!groupKeyVars.contains(keyVar)) { LogicalVariable newVar = context.newVar(); VariableReferenceExpression keyVarRef = new VariableReferenceExpression(keyVar); keyVarRef.setSourceLocation(op.getSourceLocation()); op.getGroupByList().add(new Pair<>(newVar, new MutableObject<>(keyVarRef))); addedGroupKeyMapping.put(keyVar, newVar); if (expr.getExpressionTag() == LogicalExpressionTag.VARIABLE) { VariableReferenceExpression varExpr = (VariableReferenceExpression) expr; if (correlatedKeyVars.contains(varExpr.getVariableReference())) { decorExprIter.remove();
private static ILogicalExpression vre(LogicalVariable var) { if (var == null) { throw new NullPointerException(); } return new VariableReferenceExpression(var); }
if (varEx == null) { varEx = varArg; } else if (!varEx.getVariableReference().equals(varArg.getVariableReference())) { return false; AbstractFunctionCallExpression eqExp = new ScalarFunctionCallExpression(eqFctInfo); eqExp.setSourceLocation(sourceLoc); VariableReferenceExpression scanVarRef = new VariableReferenceExpression(scanVar); scanVarRef.setSourceLocation(sourceLoc); eqExp.getArguments().add(new MutableObject<>(scanVarRef)); eqExp.getArguments().add(new MutableObject<>(varEx.cloneExpression())); eqExp.getAnnotations().put(IndexedNLJoinExpressionAnnotation.INSTANCE, IndexedNLJoinExpressionAnnotation.INSTANCE);
LogicalVariable fieldVar = varExpr.getVariableReference(); Map<LogicalVariable, EquivalenceClass> ecs = context.getEquivalenceClassMap(assignOp); if (ecs == null) { context.putEquivalenceClassMap(assignOp, ecs); VariableReferenceExpression recordVarRef = new VariableReferenceExpression(recordVar); recordVarRef.setSourceLocation(funcExpr.getSourceLocation()); ScalarFunctionCallExpression expr = new ScalarFunctionCallExpression( FunctionUtil.getFunctionInfo(BuiltinFunctions.FIELD_ACCESS_BY_INDEX),
private static ILogicalExpression createFunctionCall(Function fn, List<LogicalVariable> vars) { List<Mutable<ILogicalExpression>> args = new ArrayList<Mutable<ILogicalExpression>>(); for (LogicalVariable var : vars) { args.add(mutable(new VariableReferenceExpression(var))); } return new ScalarFunctionCallExpression(fn, args); }
public static void prepareVarAndExpression(List<String> field, LogicalVariable resVar, List<LogicalVariable> vars, List<Mutable<ILogicalExpression>> assignExpressions, List<Mutable<ILogicalExpression>> varRefs, IVariableContext context, SourceLocation sourceLoc) { VariableReferenceExpression dummyVarRef = new VariableReferenceExpression(DUMMY_VAR); dummyVarRef.setSourceLocation(sourceLoc); ScalarFunctionCallExpression f = createFieldAccessExpression(dummyVarRef, field, sourceLoc); f.substituteVar(DUMMY_VAR, resVar); assignExpressions.add(new MutableObject<ILogicalExpression>(f)); LogicalVariable v = context.newVar(); vars.add(v); if (varRefs != null) { VariableReferenceExpression vRef = new VariableReferenceExpression(v); vRef.setSourceLocation(sourceLoc); varRefs.add(new MutableObject<ILogicalExpression>(vRef)); } }
public static LogicalVariable getDecorVariable(Pair<LogicalVariable, Mutable<ILogicalExpression>> p) { if (p.first != null) { return p.first; } else { VariableReferenceExpression e = (VariableReferenceExpression) p.second.getValue(); return e.getVariableReference(); } }
private AggregateOperator getAggregateOperator(LogicalVariable unnestVariable, LogicalVariable aggregateVariable) { List<LogicalVariable> aggregateVariables = new ArrayList<LogicalVariable>(); aggregateVariables.add(aggregateVariable); List<Mutable<ILogicalExpression>> aggregateSequenceArgs = new ArrayList<Mutable<ILogicalExpression>>(); Mutable<ILogicalExpression> unnestVariableRef = new MutableObject<ILogicalExpression>( new VariableReferenceExpression(unnestVariable)); aggregateSequenceArgs.add(unnestVariableRef); List<Mutable<ILogicalExpression>> exprs = new ArrayList<Mutable<ILogicalExpression>>(); ILogicalExpression aggregateExp = new AggregateFunctionCallExpression(BuiltinOperators.SEQUENCE, false, aggregateSequenceArgs); Mutable<ILogicalExpression> aggregateExpRef = new MutableObject<ILogicalExpression>(aggregateExp); exprs.add(aggregateExpRef); return new AggregateOperator(aggregateVariables, exprs); }
@Override public String visitVariableReferenceExpression(VariableReferenceExpression expr, Integer indent) throws AlgebricksException { return expr.toString(); }
private static AbstractFunctionCallExpression createPointExpression(List<LogicalVariable> pointVars, SourceLocation sourceLoc) { List<Mutable<ILogicalExpression>> expressions = new ArrayList<>(); AbstractFunctionCallExpression createPointExpr1 = new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(BuiltinFunctions.CREATE_POINT)); createPointExpr1.setSourceLocation(sourceLoc); VariableReferenceExpression pointVarRef0 = new VariableReferenceExpression(pointVars.get(0)); pointVarRef0.setSourceLocation(sourceLoc); expressions.add(new MutableObject<ILogicalExpression>(pointVarRef0)); VariableReferenceExpression pointVarRef1 = new VariableReferenceExpression(pointVars.get(1)); pointVarRef1.setSourceLocation(sourceLoc); expressions.add(new MutableObject<ILogicalExpression>(pointVarRef1)); createPointExpr1.getArguments().addAll(expressions); return createPointExpr1; }
public List<LogicalVariable> getDistinctByVarList() { List<LogicalVariable> varList = new ArrayList<LogicalVariable>(expressions.size()); for (Mutable<ILogicalExpression> eRef : expressions) { ILogicalExpression e = eRef.getValue(); if (e.getExpressionTag() == LogicalExpressionTag.VARIABLE) { VariableReferenceExpression v = (VariableReferenceExpression) e; varList.add(v.getVariableReference()); } } return varList; }
private AssignOperator getAssignOperator(LogicalVariable unnestVariable, LogicalVariable outputVariable, IFunctionInfo inputFunction) { List<Mutable<ILogicalExpression>> nodeArgs = new ArrayList<Mutable<ILogicalExpression>>(); nodeArgs.add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(unnestVariable))); ScalarFunctionCallExpression unctionExpression = new ScalarFunctionCallExpression(inputFunction, nodeArgs); Mutable<ILogicalExpression> nodeTreeIdExpression = new MutableObject<ILogicalExpression>(unctionExpression); return new AssignOperator(outputVariable, nodeTreeIdExpression); }
/** * Finds a variable assigned to a given expression and returns a new {@link VariableReferenceExpression} * referring to this variable. * @param assignVarList list of variables * @param assignExprList list of expressions assigned to those variables * @param searchExpr expression to search for * @return said value, {@code null} if a variable is not found */ public static VariableReferenceExpression findAssignedVariable(List<LogicalVariable> assignVarList, List<Mutable<ILogicalExpression>> assignExprList, ILogicalExpression searchExpr) { for (int i = 0, n = assignExprList.size(); i < n; i++) { ILogicalExpression expr = assignExprList.get(i).getValue(); if (expr.equals(searchExpr)) { VariableReferenceExpression result = new VariableReferenceExpression(assignVarList.get(i)); result.setSourceLocation(expr.getSourceLocation()); return result; } } return null; } }
protected int readVarList(List<Mutable<ILogicalExpression>> funcArgs, int index, List<LogicalVariable> varList) { int numLowKeys = AccessMethodUtils.getInt32Constant(funcArgs.get(index)); if (numLowKeys > 0) { for (int i = 0; i < numLowKeys; i++) { LogicalVariable var = ((VariableReferenceExpression) funcArgs.get(index + 1 + i).getValue()).getVariableReference(); varList.add(var); } } return index + numLowKeys + 1; }
public VariableReferenceExpression getVariableReferenceExpression(Identifier id) throws CompilationException { LogicalVariable var = map.get(id); if (var == null) { throw new CompilationException(ErrorCode.COMPILATION_AQLPLUS_IDENTIFIER_NOT_FOUND, id.toString()); } return new VariableReferenceExpression(var); }