public static ScalarFunctionCallExpression getComparisonExpr(String simFuncName, ArrayList<Mutable<ILogicalExpression>> cmpArgs) { if (simFuncName.equals(JACCARD_FUNCTION_NAME)) { return new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(AlgebricksBuiltinFunctions.GE), cmpArgs); } else if (simFuncName.equals(EDIT_DISTANCE_FUNCTION_NAME)) { return new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(AlgebricksBuiltinFunctions.LE), cmpArgs); } return null; }
private static ILogicalExpression sfce(Function fn, ILogicalExpression... argExprs) { List<Mutable<ILogicalExpression>> args = new ArrayList<Mutable<ILogicalExpression>>(); for (ILogicalExpression e : argExprs) { args.add(mutable(e)); } return new ScalarFunctionCallExpression(fn, args); }
private ILogicalExpression data(ILogicalExpression expr) throws SystemException { return new ScalarFunctionCallExpression(BuiltinFunctions.FN_DATA_1, Collections.singletonList(mutable(expr))); }
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); }
private ILogicalExpression makeCondition(List<Mutable<ILogicalExpression>> predList, IOptimizationContext context) { if (predList.size() > 1) { IFunctionInfo finfo = context.getMetadataProvider().lookupFunction(AlgebricksBuiltinFunctions.AND); return new ScalarFunctionCallExpression(finfo, predList); } else { return predList.get(0).getValue(); } }
protected static AbstractFunctionCallExpression createFunctionCallExpression(FunctionIdentifier fid, SourceLocation sourceLoc) { ScalarFunctionCallExpression callExpr = new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(fid)); callExpr.setSourceLocation(sourceLoc); return callExpr; }
private AbstractFunctionCallExpression createRecordMergeFunction(ILogicalExpression rec0, ILogicalExpression rec1, SourceLocation sourceLoc) { List<Mutable<ILogicalExpression>> recordMergeFnArgs = new ArrayList<>(); recordMergeFnArgs.add(new MutableObject<>(rec0)); recordMergeFnArgs.add(new MutableObject<>(rec1)); AbstractFunctionCallExpression recordMergeFn = new ScalarFunctionCallExpression( FunctionUtil.getFunctionInfo(BuiltinFunctions.RECORD_MERGE), recordMergeFnArgs); recordMergeFn.setSourceLocation(sourceLoc); return recordMergeFn; } }
private ILogicalExpression createNotNullFunction(ILogicalExpression mergedRec) { List<Mutable<ILogicalExpression>> args = new ArrayList<>(); args.add(new MutableObject<ILogicalExpression>(mergedRec)); AbstractFunctionCallExpression notNullFn = new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(BuiltinFunctions.CHECK_UNKNOWN), args); notNullFn.setSourceLocation(mergedRec.getSourceLocation()); return notNullFn; }
private ILogicalExpression getScalarExpr(FunctionIdentifier func, ILogicalExpression interval) { List<Mutable<ILogicalExpression>> intervalArg = new ArrayList<>(); intervalArg.add(new MutableObject<ILogicalExpression>(interval)); ScalarFunctionCallExpression fnExpr = new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(func), intervalArg); fnExpr.setSourceLocation(interval.getSourceLocation()); return fnExpr; }
private ILogicalExpression createSelectCondition(List<Mutable<ILogicalExpression>> predList) { if (predList.size() > 1) { IFunctionInfo finfo = FunctionUtil.getFunctionInfo(AlgebricksBuiltinFunctions.AND); ScalarFunctionCallExpression andExpr = new ScalarFunctionCallExpression(finfo, predList); andExpr.setSourceLocation(predList.get(0).getValue().getSourceLocation()); return andExpr; } return predList.get(0).getValue(); }
private static AbstractFunctionCallExpression createRectangleExpression( AbstractFunctionCallExpression createPointExpr1, AbstractFunctionCallExpression createPointExpr2) { List<Mutable<ILogicalExpression>> expressions = new ArrayList<>(); AbstractFunctionCallExpression createRectangleExpr = new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(BuiltinFunctions.CREATE_RECTANGLE)); createRectangleExpr.setSourceLocation(createPointExpr1.getSourceLocation()); expressions.add(new MutableObject<ILogicalExpression>(createPointExpr1)); expressions.add(new MutableObject<ILogicalExpression>(createPointExpr2)); createRectangleExpr.getArguments().addAll(expressions); return createRectangleExpr; }
private ILogicalExpression getScalarExpr(FunctionIdentifier func, ILogicalExpression interval1, ILogicalExpression interval2) { List<Mutable<ILogicalExpression>> intervalArg = new ArrayList<>(); intervalArg.add(new MutableObject<ILogicalExpression>(interval1)); intervalArg.add(new MutableObject<ILogicalExpression>(interval2)); ScalarFunctionCallExpression fnExpr = new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(func), intervalArg); fnExpr.setSourceLocation(interval1.getSourceLocation()); return fnExpr; }
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); }
private ILogicalExpression normalize(ILogicalExpression expr, SequenceType type) throws SystemException { if (type.getItemType().isAtomicType()) { ILogicalExpression atomizedExpr = new ScalarFunctionCallExpression(BuiltinFunctions.FN_DATA_1, Collections.singletonList(mutable(expr))); AtomicType aType = (AtomicType) type.getItemType(); if (TypeUtils.isSubtypeTypeOf(aType, BuiltinTypeRegistry.XS_BOOLEAN)) { return new ScalarFunctionCallExpression(BuiltinFunctions.FN_BOOLEAN_1, Collections.singletonList(mutable(atomizedExpr))); } return promote(atomizedExpr, type); } else { return treat(expr, type); } }
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; }
@Override public ScalarFunctionCallExpression cloneExpression() { List<Mutable<ILogicalExpression>> clonedArgs = cloneArguments(); ScalarFunctionCallExpression funcExpr = new ScalarFunctionCallExpression(finfo, clonedArgs); funcExpr.getAnnotations().putAll(cloneAnnotations()); funcExpr.setOpaqueParameters(this.getOpaqueParameters()); funcExpr.setSourceLocation(sourceLoc); return funcExpr; }
@Override public ILogicalExpression visitScalarFunctionCallExpression(ScalarFunctionCallExpression expr, Void arg) throws AlgebricksException { ScalarFunctionCallExpression exprCopy = new ScalarFunctionCallExpression(expr.getFunctionInfo(), deepCopyExpressionReferenceList(expr.getArguments())); deepCopyAnnotations(expr, exprCopy); deepCopyOpaqueParameters(expr, exprCopy); copySourceLocation(expr, exprCopy); return exprCopy; }
@SuppressWarnings("unchecked") private boolean convertAlgebricksExpression(Mutable<ILogicalExpression> searchM, IFunctionInfo funcInfo, boolean isBoolean) { AbstractFunctionCallExpression searchFunction = (AbstractFunctionCallExpression) searchM.getValue(); searchFunction.setFunctionInfo(funcInfo); if (isBoolean) { ScalarFunctionCallExpression functionCallExp = new ScalarFunctionCallExpression( BuiltinFunctions.FN_BOOLEAN_1, new MutableObject<ILogicalExpression>(searchM.getValue())); searchM.setValue(functionCallExp); } return true; } }
private ILogicalExpression translateConstantValue(IAObject value, SourceLocation sourceLoc) throws CompilationException { ConstantExpression constExpr = new ConstantExpression(new AsterixConstantValue(value)); constExpr.setSourceLocation(sourceLoc); IAType valueType = value.getType(); if (valueType.getTypeTag().isDerivedType()) { ScalarFunctionCallExpression castExpr = new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(BuiltinFunctions.CAST_TYPE)); castExpr.setSourceLocation(sourceLoc); castExpr.getArguments().add(new MutableObject<>(constExpr)); TypeCastUtils.setRequiredAndInputTypes(castExpr, BuiltinType.ANY, valueType); return castExpr; } else { return constExpr; } }
private static AbstractFunctionCallExpression getClosedFieldAccessFunction(Mutable<ILogicalExpression> varRef, int position, SourceLocation sourceLoc) { Mutable<ILogicalExpression> indexRef = new MutableObject<>(new ConstantExpression(new AsterixConstantValue(new AInt32(position)))); ScalarFunctionCallExpression fnExpr = new ScalarFunctionCallExpression( FunctionUtil.getFunctionInfo(BuiltinFunctions.FIELD_ACCESS_BY_INDEX), varRef, indexRef); fnExpr.setSourceLocation(sourceLoc); return fnExpr; }