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); }
private boolean replaceWithFunctionCallArg(Mutable<ILogicalExpression> expRef, FunctionIdentifier normFuncIdent, AsterixConstantValue constVal, AbstractFunctionCallExpression funcExpr) throws AlgebricksException { // Analyze func expr to see if it is an optimizable similarity function. ScalarFunctionCallExpression simCheckFuncExpr = getSimilarityCheckExpr(normFuncIdent, constVal, funcExpr); // Replace the expr in the select condition. if (simCheckFuncExpr != null) { // Get item 0 from var. List<Mutable<ILogicalExpression>> getItemArgs = new ArrayList<Mutable<ILogicalExpression>>(); // First arg is the similarity-check function call. getItemArgs.add(new MutableObject<ILogicalExpression>(simCheckFuncExpr)); // Second arg is the item index to be accessed. getItemArgs.add(new MutableObject<ILogicalExpression>( new ConstantExpression(new AsterixConstantValue(new AInt32(0))))); ScalarFunctionCallExpression getItemExpr = new ScalarFunctionCallExpression( FunctionUtil.getFunctionInfo(BuiltinFunctions.GET_ITEM), getItemArgs); getItemExpr.setSourceLocation(simCheckFuncExpr.getSourceLocation()); // Replace the old similarity function call with the new getItemExpr. expRef.setValue(getItemExpr); return true; } return false; }
SourceLocation sourceLoc = simCheckFuncExpr.getSourceLocation();