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 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 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 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; }
private AbstractFunctionCallExpression createPrimaryKeyRecordExpression(List<String> pkFieldName, SourceLocation sourceLoc) { //Create lowest level of nested uuid AbstractFunctionCallExpression uuidFn = new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(BuiltinFunctions.CREATE_UUID)); uuidFn.setSourceLocation(sourceLoc); List<Mutable<ILogicalExpression>> openRecordConsArgs = new ArrayList<>(); ConstantExpression pkFieldNameExpression = new ConstantExpression(new AsterixConstantValue(new AString(pkFieldName.get(pkFieldName.size() - 1)))); pkFieldNameExpression.setSourceLocation(sourceLoc); openRecordConsArgs.add(new MutableObject<>(pkFieldNameExpression)); openRecordConsArgs.add(new MutableObject<>(uuidFn)); AbstractFunctionCallExpression openRecFn = new ScalarFunctionCallExpression( FunctionUtil.getFunctionInfo(BuiltinFunctions.OPEN_RECORD_CONSTRUCTOR), openRecordConsArgs); openRecFn.setSourceLocation(sourceLoc); //Create higher levels for (int i = pkFieldName.size() - 2; i > -1; i--) { AString fieldName = new AString(pkFieldName.get(i)); openRecordConsArgs = new ArrayList<>(); openRecordConsArgs.add( new MutableObject<ILogicalExpression>(new ConstantExpression(new AsterixConstantValue(fieldName)))); openRecordConsArgs.add(new MutableObject<ILogicalExpression>(openRecFn)); openRecFn = new ScalarFunctionCallExpression( FunctionUtil.getFunctionInfo(BuiltinFunctions.OPEN_RECORD_CONSTRUCTOR), openRecordConsArgs); openRecFn.setSourceLocation(sourceLoc); } return openRecFn; }
.getExternalFunctionInfo(metadataProvider.getMetadataTxnContext(), function); f = new ScalarFunctionCallExpression(finfo, args); f.setSourceLocation(sourceLoc); } else if (function.getLanguage().equalsIgnoreCase(Function.LANGUAGE_AQL) || function.getLanguage().equalsIgnoreCase(Function.LANGUAGE_SQLPP)) { IFunctionInfo finfo = FunctionUtil.getFunctionInfo(signature); f = new ScalarFunctionCallExpression(finfo, args); f.setSourceLocation(sourceLoc); } else { throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc,
private AssignOperator processExists(ILogicalExpression inputExpr, LogicalVariable v1, boolean not, SourceLocation sourceLoc) { AbstractFunctionCallExpression count = new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(BuiltinFunctions.SCALAR_COUNT)); count.getArguments().add(new MutableObject<>(inputExpr)); count.setSourceLocation(sourceLoc); AbstractFunctionCallExpression comparison = new ScalarFunctionCallExpression( FunctionUtil.getFunctionInfo(not ? BuiltinFunctions.EQ : BuiltinFunctions.NEQ)); ConstantExpression eZero = new ConstantExpression(new AsterixConstantValue(new AInt64(0L))); eZero.setSourceLocation(sourceLoc); comparison.getArguments().add(new MutableObject<>(count)); comparison.getArguments().add(new MutableObject<>(eZero)); comparison.setSourceLocation(sourceLoc); AssignOperator a = new AssignOperator(v1, new MutableObject<>(comparison)); a.setSourceLocation(sourceLoc); return a; }
private WindowOperator createHelperWindowOperator(List<Mutable<ILogicalExpression>> partExprList, List<Pair<OrderOperator.IOrder, Mutable<ILogicalExpression>>> orderExprList, LogicalVariable rowNumVar, LogicalVariable denseRankVar, ListSet<LogicalVariable> usedVars, SourceLocation sourceLoc) throws CompilationException { WindowOperator winOp = new WindowOperator(partExprList, orderExprList); winOp.setSourceLocation(sourceLoc); for (LogicalVariable usedVar : usedVars) { FunctionIdentifier fid; if (usedVar.equals(rowNumVar)) { fid = BuiltinFunctions.ROW_NUMBER_IMPL; } else if (usedVar.equals(denseRankVar)) { fid = BuiltinFunctions.DENSE_RANK_IMPL; } else { throw new CompilationException(ErrorCode.COMPILATION_ILLEGAL_STATE, sourceLoc, usedVar.toString()); } AbstractFunctionCallExpression valueExpr = BuiltinFunctions.makeWindowFunctionExpression(fid, new ArrayList<>()); if (BuiltinFunctions.windowFunctionHasProperty(valueExpr.getFunctionIdentifier(), BuiltinFunctions.WindowFunctionProperty.INJECT_ORDER_ARGS)) { for (Pair<OrderOperator.IOrder, Mutable<ILogicalExpression>> p : orderExprList) { valueExpr.getArguments().add(new MutableObject<>(p.second.getValue().cloneExpression())); } } valueExpr.setSourceLocation(winOp.getSourceLocation()); winOp.getVariables().add(usedVar); winOp.getExpressions().add(new MutableObject<>(valueExpr)); } return winOp; } }
functionCallExpression.getArguments().add(new MutableObject<>(startIndexPair.first)); functionCallExpression.getArguments().add(new MutableObject<>(endIndexPair.first)); functionCallExpression.setSourceLocation(sourceLoc); } else { functionCallExpression = new ScalarFunctionCallExpression( functionCallExpression.getArguments().add(new MutableObject<>(expressionPair.first)); functionCallExpression.getArguments().add(new MutableObject<>(startIndexPair.first)); functionCallExpression.setSourceLocation(sourceLoc);
@Override public Pair<ILogicalOperator, LogicalVariable> visit(ListConstructor lc, Mutable<ILogicalOperator> tupSource) throws CompilationException { SourceLocation sourceLoc = lc.getSourceLocation(); FunctionIdentifier fid = (lc.getType() == ListConstructor.Type.ORDERED_LIST_CONSTRUCTOR) ? BuiltinFunctions.ORDERED_LIST_CONSTRUCTOR : BuiltinFunctions.UNORDERED_LIST_CONSTRUCTOR; AbstractFunctionCallExpression f = new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(fid)); f.setSourceLocation(sourceLoc); LogicalVariable v1 = context.newVar(); AssignOperator a = new AssignOperator(v1, new MutableObject<>(f)); a.setSourceLocation(sourceLoc); Mutable<ILogicalOperator> topOp = tupSource; for (Expression expr : lc.getExprList()) { Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = langExprToAlgExpression(expr, topOp); f.getArguments().add(new MutableObject<>(eo.first)); topOp = eo.second; } a.getInputs().add(topOp); return new Pair<>(a, v1); }
AbstractFunctionCallExpression getHandle = new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(BuiltinFunctions.GET_HANDLE)); getHandle.setSourceLocation(sourceLoc); VariableReferenceExpression tRef = new VariableReferenceExpression(t); tRef.setSourceLocation(sourceLoc); getData.setSourceLocation(sourceLoc); VariableReferenceExpression ref2 = new VariableReferenceExpression(x.getVariableReference()); ref2.setSourceLocation(sourceLoc);
@Override public Pair<ILogicalOperator, LogicalVariable> visit(IndexAccessor ia, Mutable<ILogicalOperator> tupSource) throws CompilationException { SourceLocation sourceLoc = ia.getSourceLocation(); // Expression pair Pair<ILogicalExpression, Mutable<ILogicalOperator>> expressionPair = langExprToAlgExpression(ia.getExpr(), tupSource); LogicalVariable v = context.newVar(); AbstractFunctionCallExpression f; // Index expression Pair<ILogicalExpression, Mutable<ILogicalOperator>> indexPair = null; if (ia.isAny()) { f = new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(BuiltinFunctions.ANY_COLLECTION_MEMBER)); f.getArguments().add(new MutableObject<>(expressionPair.first)); } else { indexPair = langExprToAlgExpression(ia.getIndexExpr(), expressionPair.second); f = new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(BuiltinFunctions.GET_ITEM)); f.getArguments().add(new MutableObject<>(expressionPair.first)); f.getArguments().add(new MutableObject<>(indexPair.first)); } f.setSourceLocation(sourceLoc); AssignOperator a = new AssignOperator(v, new MutableObject<>(f)); if (ia.isAny()) { a.getInputs().add(expressionPair.second); } else { a.getInputs().add(indexPair.second); // NOSONAR: Called only if value exists } a.setSourceLocation(sourceLoc); return new Pair<>(a, v); }
@Override public Pair<ILogicalOperator, LogicalVariable> visit(RecordConstructor rc, Mutable<ILogicalOperator> tupSource) throws CompilationException { AbstractFunctionCallExpression f = new ScalarFunctionCallExpression( FunctionUtil.getFunctionInfo(BuiltinFunctions.OPEN_RECORD_CONSTRUCTOR)); f.setSourceLocation(rc.getSourceLocation()); LogicalVariable v1 = context.newVar(); AssignOperator a = new AssignOperator(v1, new MutableObject<>(f)); a.setSourceLocation(rc.getSourceLocation()); Mutable<ILogicalOperator> topOp = tupSource; for (FieldBinding fb : rc.getFbList()) { Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo1 = langExprToAlgExpression(fb.getLeftExpr(), topOp); f.getArguments().add(new MutableObject<>(eo1.first)); topOp = eo1.second; Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo2 = langExprToAlgExpression(fb.getRightExpr(), topOp); f.getArguments().add(new MutableObject<>(eo2.first)); topOp = eo2.second; } a.getInputs().add(topOp); return new Pair<>(a, v1); }
@Override public Pair<ILogicalOperator, LogicalVariable> visit(FieldAccessor fa, Mutable<ILogicalOperator> tupSource) throws CompilationException { SourceLocation sourceLoc = fa.getSourceLocation(); Pair<ILogicalExpression, Mutable<ILogicalOperator>> p = langExprToAlgExpression(fa.getExpr(), tupSource); LogicalVariable v = context.newVarFromExpression(fa); AbstractFunctionCallExpression fldAccess = new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(BuiltinFunctions.FIELD_ACCESS_BY_NAME)); fldAccess.setSourceLocation(sourceLoc); fldAccess.getArguments().add(new MutableObject<>(p.first)); ConstantExpression faExpr = new ConstantExpression(new AsterixConstantValue(new AString(fa.getIdent().getValue()))); faExpr.setSourceLocation(sourceLoc); fldAccess.getArguments().add(new MutableObject<>(faExpr)); AssignOperator a = new AssignOperator(v, new MutableObject<>(fldAccess)); a.getInputs().add(p.second); a.setSourceLocation(sourceLoc); return new Pair<>(a, v); }
conj.setSourceLocation(firstSelect.getSourceLocation());
AbstractFunctionCallExpression castFunc = new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(BuiltinFunctions.CAST_TYPE)); castFunc.setSourceLocation(argExpr.getValue().getSourceLocation()); castFunc.getArguments().add(argExpr); TypeCastUtils.setRequiredAndInputTypes(castFunc, requiredRecordType, inputRecordType);
AbstractFunctionCallExpression externalLookupFunc = new ScalarFunctionCallExpression(externalLookup, externalLookupArgs); externalLookupFunc.setSourceLocation(sourceLoc); UnnestMapOperator unnestOp = new UnnestMapOperator(externalUnnestVars, new MutableObject<ILogicalExpression>(externalLookupFunc), outputTypes, retainInput);
AbstractFunctionCallExpression primaryIndexSearchFunc = new ScalarFunctionCallExpression(primaryIndexSearch, primaryIndexFuncArgs); primaryIndexSearchFunc.setSourceLocation(sourceLoc);
private AbstractFunctionCallExpression lookupBuiltinFunction(String functionName, int arity, List<Mutable<ILogicalExpression>> args, SourceLocation sourceLoc) { AbstractFunctionCallExpression f; FunctionIdentifier fi = getBuiltinFunctionIdentifier(functionName, arity); if (fi == null) { return null; } if (BuiltinFunctions.isBuiltinAggregateFunction(fi)) { f = BuiltinFunctions.makeAggregateFunctionExpression(fi, args); } else if (BuiltinFunctions.isBuiltinUnnestingFunction(fi)) { UnnestingFunctionCallExpression ufce = new UnnestingFunctionCallExpression(FunctionUtil.getFunctionInfo(fi), args); ufce.setReturnsUniqueValues(BuiltinFunctions.returnsUniqueValues(fi)); f = ufce; } else if (BuiltinFunctions.isWindowFunction(fi)) { f = BuiltinFunctions.makeWindowFunctionExpression(fi, args); } else { f = new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(fi), args); } f.setSourceLocation(sourceLoc); return f; }
AbstractFunctionCallExpression m = new ScalarFunctionCallExpression( FunctionUtil.getFunctionInfo(BuiltinFunctions.NUMERIC_UNARY_MINUS)); m.setSourceLocation(sourceLoc); m.getArguments().add(new MutableObject<>(eo.first)); a = new AssignOperator(v1, new MutableObject<>(m));