private boolean isUnnestingFunction(ILogicalExpression expr) { if (expr.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) { AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expr; return fce.getKind() == FunctionKind.UNNEST; } return false; } }
private static <T> boolean hasComplexExpressions(List<T> exprList, Function<T, Mutable<ILogicalExpression>> exprGetter) { for (T item : exprList) { Mutable<ILogicalExpression> exprMutable = exprGetter.apply(item); if (exprMutable.getValue().getExpressionTag() != LogicalExpressionTag.VARIABLE) { return true; } } return false; } }
public static void findVariableExpressions(Mutable<ILogicalExpression> mutableLe, List<Mutable<ILogicalExpression>> finds) { ILogicalExpression le = mutableLe.getValue(); if (le.getExpressionTag() == LogicalExpressionTag.VARIABLE) { finds.add(mutableLe); } else if (le.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) { AbstractFunctionCallExpression afce = (AbstractFunctionCallExpression) le; for (Mutable<ILogicalExpression> argExp : afce.getArguments()) { findVariableExpressions(argExp, finds); } } }
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; }
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 static boolean isAccessByNameToFieldRecord(ILogicalExpression expr) { if (expr.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) { AbstractFunctionCallExpression fc = (AbstractFunctionCallExpression) expr; FunctionIdentifier fid = fc.getFunctionIdentifier(); if (fid.equals(BuiltinFunctions.FIELD_ACCESS_BY_NAME)) { return true; } } return false; }
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; }
private static LogicalVariable getKey(ILogicalExpression keyExpression) { if (keyExpression.getExpressionTag() != LogicalExpressionTag.VARIABLE) { throw new NotImplementedException(); } return ((VariableReferenceExpression) keyExpression).getVariableReference(); }
@Override public boolean transform(Mutable<ILogicalExpression> exprRef) throws AlgebricksException { ILogicalExpression e = exprRef.getValue(); switch (e.getExpressionTag()) { case FUNCTION_CALL: return transformFunctionCallExpression((AbstractFunctionCallExpression) e); default: return false; } }
/** * @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); }
private static AbstractFunctionCallExpression asFunctionCallExpression(ILogicalExpression ex, FunctionIdentifier fi) { AbstractFunctionCallExpression fctCall = (ex.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL ? (AbstractFunctionCallExpression) ex : null); if (fctCall != null && (fi == null || fctCall.getFunctionIdentifier().equals(fi))) return fctCall; return null; }
private boolean checkArgs(AbstractFunctionCallExpression expr) { for (Mutable<ILogicalExpression> r : expr.getArguments()) { if (r.getValue().getExpressionTag() != LogicalExpressionTag.CONSTANT) { return false; } } return true; } }
private boolean exprIsRecord(IVariableTypeEnvironment typeEnvironment, ILogicalExpression recordExpr) throws AlgebricksException { if (recordExpr.getExpressionTag() == LogicalExpressionTag.VARIABLE) { IAType type = (IAType) typeEnvironment.getType(recordExpr); return type != null && type.getTypeTag() == ATypeTag.OBJECT; } return false; }
private boolean isEqJoinCondition(ILogicalExpression expr) { AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression) expr; if (funcExpr.getFunctionIdentifier().equals(AlgebricksBuiltinFunctions.EQ)) { ILogicalExpression arg1 = funcExpr.getArguments().get(0).getValue(); ILogicalExpression arg2 = funcExpr.getArguments().get(1).getValue(); if (arg1.getExpressionTag() == LogicalExpressionTag.VARIABLE && arg2.getExpressionTag() == LogicalExpressionTag.VARIABLE) { return true; } } return false; }
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 void sweepExpression(ILogicalExpression expr) throws AlgebricksException { if (expr.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL && !expr.isFunctional()) { AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expr; throw new CompilationException(ErrorCode.COMPILATION_ERROR, fce.getSourceLocation(), "Found non-functional function " + fce.getFunctionIdentifier()); } }
public static AbstractFunctionCallExpression getFunctionCall(Mutable<ILogicalOperator> opRef) { AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue(); if (op.getOperatorTag() != LogicalOperatorTag.UNNEST) { return null; } UnnestOperator unnest = (UnnestOperator) op; ILogicalExpression unnestExpr = unnest.getExpressionRef().getValue(); if (unnestExpr.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) { return null; } return (AbstractFunctionCallExpression) unnestExpr; }
public static boolean isAccessToFieldRecord(ILogicalExpression expr) { if (expr.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) { AbstractFunctionCallExpression fc = (AbstractFunctionCallExpression) expr; FunctionIdentifier fid = fc.getFunctionIdentifier(); if (fid.equals(BuiltinFunctions.FIELD_ACCESS_BY_INDEX) || fid.equals(BuiltinFunctions.FIELD_ACCESS_BY_NAME) || fid.equals(BuiltinFunctions.FIELD_ACCESS_NESTED)) { return true; } } 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; }