@Override public AbstractLogicalExpression cloneExpression() { Map<Object, IExpressionAnnotation> m = new HashMap<>(); annotationMap.forEach((key, value1) -> m.put(key, value1.copy())); ConstantExpression c = new ConstantExpression(value); c.annotationMap = m; c.setSourceLocation(sourceLoc); return c; }
private ConstantExpression createConstantExpression(IAObject value, SourceLocation sourceLoc) { ConstantExpression constExpr = new ConstantExpression(new AsterixConstantValue(value)); constExpr.setSourceLocation(sourceLoc); return constExpr; } }
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; }
@Override public Pair<ILogicalOperator, LogicalVariable> visit(LiteralExpr l, Mutable<ILogicalOperator> tupSource) { SourceLocation sourceLoc = l.getSourceLocation(); LogicalVariable var = context.newVar(); AsterixConstantValue cValue = new AsterixConstantValue(ConstantHelper.objectFromLiteral(l.getValue())); ConstantExpression cExpr = new ConstantExpression(cValue); cExpr.setSourceLocation(sourceLoc); AssignOperator a = new AssignOperator(var, new MutableObject<>(cExpr)); a.setSourceLocation(sourceLoc); if (tupSource != null) { a.getInputs().add(tupSource); } return new Pair<>(a, var); }
IAObject simThreshold = FuzzyUtils.getSimThreshold(metadataProvider, simFuncName); ConstantExpression simThresholdExpr = new ConstantExpression(new AsterixConstantValue(simThreshold)); simThresholdExpr.setSourceLocation(sourceLoc); cmpArgs.add(new MutableObject<ILogicalExpression>(simThresholdExpr)); ScalarFunctionCallExpression cmpExpr = FuzzyUtils.getComparisonExpr(simFuncName, cmpArgs);
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 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; }
@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); }
new AsterixConstantValue(ConstantHelper.objectFromLiteral(val.getValue())); ConstantExpression cExpr = new ConstantExpression(cValue); cExpr.setSourceLocation(expr.getSourceLocation()); args.add(new MutableObject<>(cExpr)); break;
eFalse.setSourceLocation(sourceLoc); ifMissingOrNullArgs.add(new MutableObject<>(eo2.first)); ifMissingOrNullArgs.add(new MutableObject<>(eFalse));
new AsterixConstantValue(ConstantHelper.objectFromLiteral(val.getValue())); ConstantExpression cExpr = new ConstantExpression(cValue); cExpr.setSourceLocation(sourceLoc); return new Pair<>(cExpr, topOpRef); default: