public static void resetLOJMissingPlaceholderVarInGroupByOp(AccessMethodAnalysisContext analysisCtx, LogicalVariable newMissingPlaceholderVaraible, IOptimizationContext context) throws AlgebricksException { //reset the missing placeholder variable in groupby operator ScalarFunctionCallExpression isMissingFuncExpr = analysisCtx.getLOJIsMissingFuncInGroupBy(); isMissingFuncExpr.getArguments().clear(); VariableReferenceExpression newMissingVarRef = new VariableReferenceExpression(newMissingPlaceholderVaraible); newMissingVarRef.setSourceLocation(isMissingFuncExpr.getSourceLocation()); isMissingFuncExpr.getArguments().add(new MutableObject<ILogicalExpression>(newMissingVarRef)); //recompute type environment. OperatorPropertiesUtil.typeOpRec(analysisCtx.getLOJGroupbyOpRef(), context); }
/** * Inject a dynamic cast function wrapping an existing expression * * @param funcInfo * the cast function * @param reqType * the required type * @param inputType * the original type * @param exprRef * the expression reference * @param argExpr * the original expression * @throws AlgebricksException */ private static void injectCastFunction(IFunctionInfo funcInfo, IAType reqType, IAType inputType, Mutable<ILogicalExpression> exprRef, ILogicalExpression argExpr) throws AlgebricksException { ScalarFunctionCallExpression cast = new ScalarFunctionCallExpression(funcInfo); cast.getArguments().add(new MutableObject<ILogicalExpression>(argExpr)); exprRef.setValue(cast); TypeCastUtils.setRequiredAndInputTypes(cast, reqType, inputType); }
private static ScalarFunctionCallExpression getNestedIsMissingCall(AbstractFunctionCallExpression call, OptimizableOperatorSubTree rightSubTree) throws AlgebricksException { ScalarFunctionCallExpression isMissingFuncExpr; if (call.getFunctionIdentifier().equals(AlgebricksBuiltinFunctions.NOT)) { if (call.getArguments().get(0).getValue().getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) { if (((AbstractFunctionCallExpression) call.getArguments().get(0).getValue()).getFunctionIdentifier() .equals(AlgebricksBuiltinFunctions.IS_MISSING)) { isMissingFuncExpr = (ScalarFunctionCallExpression) call.getArguments().get(0).getValue(); if (isMissingFuncExpr.getArguments().get(0).getValue() .getExpressionTag() == LogicalExpressionTag.VARIABLE) { LogicalVariable var = ((VariableReferenceExpression) isMissingFuncExpr.getArguments().get(0).getValue()) .getVariableReference(); List<LogicalVariable> liveSubplanVars = new ArrayList<>(); VariableUtilities.getSubplanLocalLiveVariables(rightSubTree.getRoot(), liveSubplanVars); if (liveSubplanVars.contains(var)) { return isMissingFuncExpr; } } } } } return null; }
public static void prepareMetaKeyAccessExpression(List<String> field, LogicalVariable resVar, List<Mutable<ILogicalExpression>> assignExpressions, List<LogicalVariable> vars, List<Mutable<ILogicalExpression>> varRefs, IVariableContext context, SourceLocation sourceLoc) { IAObject value = (field.size() > 1) ? new AOrderedList(field) : new AString(field.get(0)); ScalarFunctionCallExpression metaKeyFunction = new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(BuiltinFunctions.META_KEY)); metaKeyFunction.setSourceLocation(sourceLoc); VariableReferenceExpression resVarRef = new VariableReferenceExpression(resVar); resVarRef.setSourceLocation(sourceLoc); metaKeyFunction.getArguments().add(new MutableObject<ILogicalExpression>(resVarRef)); metaKeyFunction.getArguments() .add(new MutableObject<>(new ConstantExpression(new AsterixConstantValue(value)))); assignExpressions.add(new MutableObject<ILogicalExpression>(metaKeyFunction)); LogicalVariable v = context.newVar(); vars.add(v); if (varRefs != null) { VariableReferenceExpression vRef = new VariableReferenceExpression(v); vRef.setSourceLocation(sourceLoc); varRefs.add(new MutableObject<ILogicalExpression>(vRef)); } }
for (Mutable<ILogicalExpression> argumentRef : func.getArguments()) { if (containsNotMissingFiltering(argumentRef.getValue())) { return true; return false; ILogicalExpression arg = func.getArguments().get(0).getValue(); if (arg.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) { return false;
@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; }
/** * Whether the expression contains a missing filtering * * @param expr * @return true if the expression contains a missing filtering function call; false otherwise. */ private boolean containsMissingFiltering(ILogicalExpression expr) { if (expr.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) { return false; } ScalarFunctionCallExpression func = (ScalarFunctionCallExpression) expr; if (func.getFunctionIdentifier() == AlgebricksBuiltinFunctions.AND) { for (Mutable<ILogicalExpression> argumentRef : func.getArguments()) { if (containsMissingFiltering(argumentRef.getValue())) { return true; } } return false; } if (func.getFunctionIdentifier() != AlgebricksBuiltinFunctions.IS_MISSING) { return false; } 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; } }
notNullFunc.getArguments().add(new MutableObject<ILogicalExpression>(arg));
ARecordType rt = (ARecordType) _emptyTypeEnv.getType(expr.getArguments().get(0).getValue()); String str = ConstantExpressionUtil.getStringConstant(expr.getArguments().get(1).getValue()); int k = rt.getFieldIndex(str); if (k >= 0) {
FunctionUtil.getFunctionInfo(BuiltinFunctions.CAST_TYPE_LAX)); castFunc.setSourceLocation(sourceLoc); castFunc.getArguments().add(new MutableObject<>(probeExpr)); TypeCastUtils.setRequiredAndInputTypes(castFunc, indexedFieldType, probeType); boolean realTypeConvertedToIntegerType =