protected ILogicalExpression makeUnnestExpression(ILogicalExpression expr) { SourceLocation sourceLoc = expr.getSourceLocation(); List<Mutable<ILogicalExpression>> argRefs = new ArrayList<>(); argRefs.add(new MutableObject<>(expr)); switch (expr.getExpressionTag()) { case CONSTANT: case VARIABLE: UnnestingFunctionCallExpression scanCollExpr1 = new UnnestingFunctionCallExpression( FunctionUtil.getFunctionInfo(BuiltinFunctions.SCAN_COLLECTION), argRefs); scanCollExpr1.setSourceLocation(sourceLoc); return scanCollExpr1; case FUNCTION_CALL: AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expr; if (fce.getKind() == FunctionKind.UNNEST) { return expr; } else { UnnestingFunctionCallExpression scanCollExpr2 = new UnnestingFunctionCallExpression( FunctionUtil.getFunctionInfo(BuiltinFunctions.SCAN_COLLECTION), argRefs); scanCollExpr2.setSourceLocation(sourceLoc); return scanCollExpr2; } default: return expr; } }
UnnestingFunctionCallExpression scanCollExpr = new UnnestingFunctionCallExpression( FunctionUtil.getFunctionInfo(BuiltinFunctions.SCAN_COLLECTION), args); scanCollExpr.setSourceLocation(exprSourceLoc); UnnestOperator unnestOp = new UnnestOperator(unnestVar, new MutableObject<>(scanCollExpr)); unnestOp.getInputs().add(new MutableObject<>(opAndVar.first));
@Override public UnnestingFunctionCallExpression cloneExpression() { cloneAnnotations(); List<Mutable<ILogicalExpression>> clonedArgs = cloneArguments(); UnnestingFunctionCallExpression ufce = new UnnestingFunctionCallExpression(finfo, clonedArgs); ufce.setReturnsUniqueValues(returnsUniqueValues); ufce.setOpaqueParameters(this.getOpaqueParameters()); ufce.setSourceLocation(sourceLoc); return ufce; }
private Pair<ILogicalOperator, LogicalVariable> createUnnestForAggregatedList(LogicalVariable aggVar, SourceLocation sourceLoc) { LogicalVariable unnestVar = context.newVar(); // Creates an unnest function expression. VariableReferenceExpression aggVarRef = new VariableReferenceExpression(aggVar); aggVarRef.setSourceLocation(sourceLoc); Mutable<ILogicalExpression> unnestArg = new MutableObject<>(aggVarRef); List<Mutable<ILogicalExpression>> unnestArgList = new ArrayList<>(); unnestArgList.add(unnestArg); UnnestingFunctionCallExpression unnestExpr = new UnnestingFunctionCallExpression( FunctionUtil.getFunctionInfo(BuiltinFunctions.SCAN_COLLECTION), unnestArgList); unnestExpr.setSourceLocation(sourceLoc); UnnestOperator unnestOp = new UnnestOperator(unnestVar, new MutableObject<>(unnestExpr)); unnestOp.setSourceLocation(sourceLoc); return new Pair<>(unnestOp, unnestVar); }
new UnnestingFunctionCallExpression(FunctionUtil.getFunctionInfo(BuiltinFunctions.SCAN_COLLECTION), new MutableObject<ILogicalExpression>(argExpr)); scanCollExpr.setSourceLocation(func.getSourceLocation()); @SuppressWarnings("unchecked") UnnestOperator unnest = new UnnestOperator(var, new MutableObject<ILogicalExpression>(scanCollExpr));
UnnestingFunctionCallExpression unnestExpr = new UnnestingFunctionCallExpression(functionInfo, func.getArguments()); unnestExpr.setSourceLocation(sourceLoc); UnnestOperator unnestOperator = new UnnestOperator(unnestVar, new MutableObject<>(unnestExpr)); unnestOperator.setSourceLocation(sourceLoc);
UnnestingFunctionCallExpression secondaryIndexSearchFunc = new UnnestingFunctionCallExpression(secondaryIndexSearch, secondaryIndexFuncArgs); secondaryIndexSearchFunc.setSourceLocation(sourceLoc); secondaryIndexSearchFunc.setReturnsUniqueValues(true);
new UnnestingFunctionCallExpression(FunctionUtil.getFunctionInfo(BuiltinFunctions.SCAN_COLLECTION), Collections.singletonList(new MutableObject<>(selectVarRef))); scanCollectionExpr.setSourceLocation(caseExpression.getSourceLocation()); UnnestOperator unnestOp = new UnnestOperator(unnestVar, new MutableObject<>(scanCollectionExpr)); unnestOp.getInputs().add(new MutableObject<>(assignOp));
UnnestingFunctionCallExpression primaryIndexSearchFunc = new UnnestingFunctionCallExpression(primaryIndexSearch, primaryIndexFuncArgs); primaryIndexSearchFunc.setSourceLocation(dataSourceOp.getSourceLocation()); primaryIndexSearchFunc.setReturnsUniqueValues(true); AbstractUnnestMapOperator unnestMapOp;
@Override public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue(); if (context.checkIfInDontApplySet(this, op)) { return false; } if (op.getOperatorTag() != LogicalOperatorTag.UNNEST) { context.addToDontApplySet(this, op); return false; } UnnestOperator unnest = (UnnestOperator) op; ILogicalExpression unnestExpr = unnest.getExpressionRef().getValue(); if (needsScanCollection(unnestExpr, op)) { UnnestingFunctionCallExpression newExpr = new UnnestingFunctionCallExpression(FunctionUtil.getFunctionInfo(BuiltinFunctions.SCAN_COLLECTION), new MutableObject<ILogicalExpression>(unnestExpr)); newExpr.setSourceLocation(unnestExpr.getSourceLocation()); unnest.getExpressionRef().setValue(newExpr); context.addToDontApplySet(this, op); return true; } context.addToDontApplySet(this, op); return false; }
IFunctionInfo scanFctInfo = BuiltinFunctions.getAsterixFunctionInfo(BuiltinFunctions.SCAN_COLLECTION); UnnestingFunctionCallExpression scanExp = new UnnestingFunctionCallExpression(scanFctInfo, mutCExp); scanExp.setSourceLocation(sourceLoc); LogicalVariable scanVar = context.newVar(); UnnestOperator unn = new UnnestOperator(scanVar, new MutableObject<>(scanExp));
new UnnestingFunctionCallExpression(FunctionUtil.getFunctionInfo(BuiltinFunctions.SCAN_COLLECTION), Collections.singletonList(new MutableObject<>(selectVarRef))); scanCollExpr.setSourceLocation(ifexpr.getSourceLocation()); UnnestOperator unnestOp = new UnnestOperator(unnestVar, new MutableObject<>(scanCollExpr)); unnestOp.getInputs().add(new MutableObject<>(assignOp));