@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; }
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(); } }
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 List<LogicalVariable> getGbyVarList() { List<LogicalVariable> varList = new ArrayList<>(gByList.size()); for (Pair<LogicalVariable, Mutable<ILogicalExpression>> ve : gByList) { ILogicalExpression expr = ve.second.getValue(); if (expr.getExpressionTag() == LogicalExpressionTag.VARIABLE) { VariableReferenceExpression v = (VariableReferenceExpression) expr; varList.add(v.getVariableReference()); } } return varList; }
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; }
public void computeColumnSet(List<Pair<LogicalVariable, Mutable<ILogicalExpression>>> gbyList) { columnSet.clear(); for (Pair<LogicalVariable, Mutable<ILogicalExpression>> p : gbyList) { ILogicalExpression expr = p.second.getValue(); if (expr.getExpressionTag() == LogicalExpressionTag.VARIABLE) { VariableReferenceExpression v = (VariableReferenceExpression) expr; columnSet.add(v.getVariableReference()); } } }
private void computeColumnSet(List<Pair<LogicalVariable, Mutable<ILogicalExpression>>> gbyList) { columnSet.clear(); for (Pair<LogicalVariable, Mutable<ILogicalExpression>> p : gbyList) { ILogicalExpression expr = p.second.getValue(); if (expr.getExpressionTag() == LogicalExpressionTag.VARIABLE) { VariableReferenceExpression v = (VariableReferenceExpression) expr; columnSet.add(v.getVariableReference()); } } }
public boolean isDistinctByVar(LogicalVariable var) { for (Mutable<ILogicalExpression> eRef : expressions) { ILogicalExpression e = eRef.getValue(); if (e.getExpressionTag() == LogicalExpressionTag.VARIABLE) { VariableReferenceExpression v = (VariableReferenceExpression) e; if (v.getVariableReference() == var) { return true; } } } return false; }
@Override public Pair<Boolean, ILogicalExpression> visitVariableReferenceExpression(VariableReferenceExpression expr, Void arg) { LogicalVariable v = expr.getVariableReference(); int idx = variables.indexOf(v); if (idx < 0) { return new Pair<Boolean, ILogicalExpression>(false, expr); } else { return new Pair<Boolean, ILogicalExpression>(true, expressions.get(idx).getValue()); } }
private static LogicalVariable getKey(ILogicalExpression keyExpression) { if (keyExpression.getExpressionTag() != LogicalExpressionTag.VARIABLE) { throw new NotImplementedException(); } return ((VariableReferenceExpression) keyExpression).getVariableReference(); }
/** * @param recordInAssign the variable reference expression in assign op * @param recordInScan the record (payload) variable in scan op * @return true if the expression in the assign op is a variable and that variable = record variable in scan op */ private boolean sameRecords(ILogicalExpression recordInAssign, LogicalVariable recordInScan) { return recordInAssign != null && recordInAssign.getExpressionTag() == LogicalExpressionTag.VARIABLE && ((VariableReferenceExpression) recordInAssign).getVariableReference().equals(recordInScan); }
@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); }
private LogicalVariable getNewGbyVar(GroupByOperator g, LogicalVariable v) { for (Pair<LogicalVariable, Mutable<ILogicalExpression>> p : g.getGroupByList()) { ILogicalExpression e = p.second.getValue(); if (e.getExpressionTag() == LogicalExpressionTag.VARIABLE) { LogicalVariable v2 = ((VariableReferenceExpression) e).getVariableReference(); if (v2 == v) { return p.first; } } } return null; }
private IScalarEvaluatorFactory createVariableEvaluatorFactory(VariableReferenceExpression expr, IOperatorSchema[] inputSchemas) throws AlgebricksException { LogicalVariable variable = expr.getVariableReference(); for (IOperatorSchema scm : inputSchemas) { int pos = scm.findVariable(variable); if (pos >= 0) { return new ColumnAccessEvalFactory(pos); } } throw new AlgebricksException("Variable " + variable + " could not be found in any input schema."); }
private LogicalVariable getNewDecorVar(GroupByOperator g, LogicalVariable v) { for (Pair<LogicalVariable, Mutable<ILogicalExpression>> p : g.getDecorList()) { ILogicalExpression e = p.second.getValue(); if (e.getExpressionTag() == LogicalExpressionTag.VARIABLE) { LogicalVariable v2 = ((VariableReferenceExpression) e).getVariableReference(); if (v2 == v) { return (p.first != null) ? p.first : v2; } } } return null; }
private static LogicalVariable getLhsGbyVar(GroupByOperator gby, LogicalVariable var) { for (Pair<LogicalVariable, Mutable<ILogicalExpression>> ve : gby.getGroupByList()) { ILogicalExpression e = ve.second.getValue(); if (e.getExpressionTag() != LogicalExpressionTag.VARIABLE) { throw new IllegalStateException( "Right hand side of group by assignment should have been normalized to a variable reference."); } LogicalVariable v = ((VariableReferenceExpression) e).getVariableReference(); if (v.equals(var)) { return ve.first; } } return null; }
@Override public boolean transform(Mutable<ILogicalExpression> exprRef) throws AlgebricksException { ILogicalExpression e = exprRef.getValue(); switch (e.getExpressionTag()) { case VARIABLE: return transformVariableReferenceExpression(exprRef, ((VariableReferenceExpression) e).getVariableReference()); case FUNCTION_CALL: return transformFunctionCallExpression((AbstractFunctionCallExpression) e); default: return false; } }
private LogicalVariable createAssignment(ILogicalExpression expr, TranslationContext tCtx) { if (expr.getExpressionTag() == LogicalExpressionTag.VARIABLE) { return ((VariableReferenceExpression) expr).getVariableReference(); } LogicalVariable result = newLogicalVariable(); AssignOperator aOp = new AssignOperator(result, mutable(expr)); aOp.getInputs().add(mutable(tCtx.op)); tCtx.op = aOp; return result; }
private LogicalVariable findListifiedVariable(AggregateOperator nspAgg, LogicalVariable varFromNestedAgg) { int n = nspAgg.getVariables().size(); for (int i = 0; i < n; i++) { if (nspAgg.getVariables().get(i).equals(varFromNestedAgg)) { AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) nspAgg.getExpressions().get(i).getValue(); if (fce.getFunctionIdentifier().equals(BuiltinFunctions.LISTIFY)) { ILogicalExpression argExpr = fce.getArguments().get(0).getValue(); if (argExpr.getExpressionTag() == LogicalExpressionTag.VARIABLE) { return ((VariableReferenceExpression) argExpr).getVariableReference(); } } } } return null; }
protected int[] getFdColumns(GroupByOperator gby, IOperatorSchema inputSchema) throws AlgebricksException { int numFds = gby.getDecorList().size(); int fdColumns[] = new int[numFds]; int j = 0; for (Pair<LogicalVariable, Mutable<ILogicalExpression>> p : gby.getDecorList()) { ILogicalExpression expr = p.second.getValue(); if (expr.getExpressionTag() != LogicalExpressionTag.VARIABLE) { throw new AlgebricksException("pre-sorted group-by expects variable references."); } VariableReferenceExpression v = (VariableReferenceExpression) expr; LogicalVariable decor = v.getVariableReference(); fdColumns[j++] = inputSchema.findVariable(decor); } return fdColumns; }