private UnnestOperator getUnnestOperator(LogicalVariable inputVariable, LogicalVariable unnestVariable) { VariableReferenceExpression inputVre = new VariableReferenceExpression(inputVariable); List<Mutable<ILogicalExpression>> iterateArgs = new ArrayList<Mutable<ILogicalExpression>>(); iterateArgs.add(new MutableObject<ILogicalExpression>(inputVre)); ILogicalExpression unnestExp = new UnnestingFunctionCallExpression(BuiltinOperators.ITERATE, iterateArgs); Mutable<ILogicalExpression> unnestExpRef = new MutableObject<ILogicalExpression>(unnestExp); return new UnnestOperator(unnestVariable, unnestExpRef); }
private UnnestOperator getUnnestOperator(LogicalVariable inputVariable, LogicalVariable unnestVariable) { VariableReferenceExpression inputVre = new VariableReferenceExpression(inputVariable); List<Mutable<ILogicalExpression>> iterateArgs = new ArrayList<Mutable<ILogicalExpression>>(); iterateArgs.add(new MutableObject<ILogicalExpression>(inputVre)); ILogicalExpression unnestExp = new UnnestingFunctionCallExpression(BuiltinOperators.ITERATE, iterateArgs); Mutable<ILogicalExpression> unnestExpRef = new MutableObject<ILogicalExpression>(unnestExp); return new UnnestOperator(unnestVariable, unnestExpRef); }
FunctionUtil.getFunctionInfo(BuiltinFunctions.SCAN_COLLECTION), args); scanCollExpr.setSourceLocation(exprSourceLoc); UnnestOperator unnestOp = new UnnestOperator(unnestVar, new MutableObject<>(scanCollExpr)); unnestOp.getInputs().add(new MutableObject<>(opAndVar.first)); unnestOp.setSourceLocation(exprSourceLoc);
@Override public ILogicalOperator visitUnnestOperator(UnnestOperator op, Void arg) throws AlgebricksException { return new UnnestOperator(op.getVariable(), deepCopyExpressionRef(op.getExpressionRef()), op.getPositionalVariable(), op.getPositionalVariableType(), op.getPositionWriter()); }
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); }
@Override public Pair<ILogicalOperator, LogicalVariable> visit(ForClause fc, Mutable<ILogicalOperator> tupSource) throws CompilationException { LogicalVariable v = context.newVarFromExpression(fc.getVarExpr()); Expression inExpr = fc.getInExpr(); Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = langExprToAlgExpression(inExpr, tupSource); ILogicalOperator returnedOp; if (fc.getPosVarExpr() == null) { returnedOp = new UnnestOperator(v, new MutableObject<ILogicalExpression>(makeUnnestExpression(eo.first))); } else { LogicalVariable pVar = context.newVarFromExpression(fc.getPosVarExpr()); // We set the positional variable type as INT64 type. returnedOp = new UnnestOperator(v, new MutableObject<ILogicalExpression>(makeUnnestExpression(eo.first)), pVar, BuiltinType.AINT64, new PositionWriter()); } returnedOp.getInputs().add(eo.second); return new Pair<>(returnedOp, v); }
@Override public ILogicalOperator visitUnnestOperator(UnnestOperator op, ILogicalOperator arg) throws AlgebricksException { UnnestOperator opCopy = new UnnestOperator(deepCopyVariable(op.getVariable()), exprDeepCopyVisitor.deepCopyExpressionReference(op.getExpressionRef()), deepCopyVariable(op.getPositionalVariable()), op.getPositionalVariableType(), op.getPositionWriter()); deepCopyInputsAnnotationsAndExecutionMode(op, arg, opCopy); return opCopy; }
private ILogicalPlan translateMainModule(MainModuleNode moduleNode) throws SystemException { QueryBodyNode qbn = moduleNode.getQueryBody(); ASTNode queryBody = qbn.getExpression(); TranslationContext tCtx = new TranslationContext(null, new EmptyTupleSourceOperator()); LogicalVariable lVar = translateExpression(queryBody, tCtx); LogicalVariable iLVar = newLogicalVariable(); UnnestOperator unnest = new UnnestOperator(iLVar, mutable(ufce(BuiltinOperators.ITERATE, vre(lVar)))); unnest.getInputs().add(mutable(tCtx.op)); List<Mutable<ILogicalExpression>> exprs = new ArrayList<Mutable<ILogicalExpression>>(); exprs.add(mutable(vre(iLVar))); QueryResultSetDataSink sink = new QueryResultSetDataSink(ccb.getResultSetId(), null); DistributeResultOperator op = new DistributeResultOperator(exprs, sink); op.getInputs().add(mutable(unnest)); ALogicalPlanImpl lp = new ALogicalPlanImpl(mutable(op)); return lp; }
UnnestOperator unnest1 = new UnnestOperator(unnestVar1, new MutableObject<ILogicalExpression>(unnestOpRef.getExpressionRef().getValue().cloneExpression())); LogicalVariable unnestVar2 = context.newVar(); UnnestOperator unnest2 = new UnnestOperator(unnestVar2, new MutableObject<ILogicalExpression>(unnestOpRef.getExpressionRef().getValue().cloneExpression()));
scanCollExpr.setSourceLocation(func.getSourceLocation()); @SuppressWarnings("unchecked") UnnestOperator unnest = new UnnestOperator(var, new MutableObject<ILogicalExpression>(scanCollExpr)); unnest.setSourceLocation(assign.getSourceLocation()); unnest.getInputs().addAll(assign.getInputs());
new UnnestingFunctionCallExpression(functionInfo, func.getArguments()); unnestExpr.setSourceLocation(sourceLoc); UnnestOperator unnestOperator = new UnnestOperator(unnestVar, new MutableObject<>(unnestExpr)); unnestOperator.setSourceLocation(sourceLoc); unnestOperator.getInputs().add(new MutableObject<>(ntsOperator));
LogicalVariable pVar = context.newVarFromExpression(fromTerm.getPositionalVariable()); unnestOp = new UnnestOperator(fromVar, new MutableObject<>(makeUnnestExpression(eo.first)), pVar, BuiltinType.AINT64, new PositionWriter()); } else { unnestOp = new UnnestOperator(fromVar, new MutableObject<>(makeUnnestExpression(eo.first)));
topOp = eo1.second; LogicalVariable uVar = context.newVarFromExpression(qt.getVarExpr()); UnnestOperator u = new UnnestOperator(uVar, new MutableObject<>(makeUnnestExpression(eo1.first))); u.setSourceLocation(expr.getSourceLocation());
private Pair<ILogicalOperator, LogicalVariable> generateUnnestForBinaryCorrelateRightBranch( AbstractBinaryCorrelateClause binaryCorrelate, Mutable<ILogicalOperator> inputOpRef, boolean innerUnnest) throws CompilationException { LogicalVariable rightVar = context.newVarFromExpression(binaryCorrelate.getRightVariable()); Expression rightExpr = binaryCorrelate.getRightExpression(); Pair<ILogicalExpression, Mutable<ILogicalOperator>> eo = langExprToAlgExpression(rightExpr, inputOpRef); AbstractUnnestOperator unnestOp; if (binaryCorrelate.hasPositionalVariable()) { LogicalVariable pVar = context.newVarFromExpression(binaryCorrelate.getPositionalVariable()); // We set the positional variable type as BIGINT type. unnestOp = innerUnnest ? new UnnestOperator(rightVar, new MutableObject<>(makeUnnestExpression(eo.first)), pVar, BuiltinType.AINT64, new PositionWriter()) : new LeftOuterUnnestOperator(rightVar, new MutableObject<>(makeUnnestExpression(eo.first)), pVar, BuiltinType.AINT64, new PositionWriter()); } else { unnestOp = innerUnnest ? new UnnestOperator(rightVar, new MutableObject<>(makeUnnestExpression(eo.first))) : new LeftOuterUnnestOperator(rightVar, new MutableObject<>(makeUnnestExpression(eo.first))); } unnestOp.getInputs().add(eo.second); unnestOp.setSourceLocation(binaryCorrelate.getRightVariable().getSourceLocation()); return new Pair<>(unnestOp, rightVar); }
Collections.singletonList(new MutableObject<>(selectVarRef))); scanCollectionExpr.setSourceLocation(caseExpression.getSourceLocation()); UnnestOperator unnestOp = new UnnestOperator(unnestVar, new MutableObject<>(scanCollectionExpr)); unnestOp.getInputs().add(new MutableObject<>(assignOp)); unnestOp.setSourceLocation(caseExpression.getSourceLocation());
private void iterateOver(ILogicalExpression ctxExpr, TranslationContext tCtx) { LogicalVariable seqLVar = createAssignment(ctxExpr, tCtx); LogicalVariable lastLVar = createAssignment(sfce(BuiltinFunctions.FN_COUNT_1, vre(seqLVar)), tCtx); tCtx.varScope.registerVariable(new XQueryVariable(XMLQueryCompilerConstants.LAST_VAR_NAME, SequenceType.create(BuiltinTypeRegistry.XS_INTEGER, Quantifier.QUANT_ONE), lastLVar)); LogicalVariable forLVar = newLogicalVariable(); LogicalVariable posLVar = newLogicalVariable(); UnnestOperator unnest = new UnnestOperator(forLVar, mutable(ufce(BuiltinOperators.ITERATE, vre(seqLVar))), posLVar, BuiltinTypeRegistry.XS_INTEGER, new VXQueryPositionWriter()); SequenceType forVarType = SequenceType.create(AnyItemType.INSTANCE, Quantifier.QUANT_ONE); XQueryVariable forVar = new XQueryVariable(XMLQueryCompilerConstants.DOT_VAR_NAME, forVarType, forLVar); tCtx.varScope.registerVariable(forVar); SequenceType posVarType = SequenceType.create(BuiltinTypeRegistry.XS_INTEGER, Quantifier.QUANT_ONE); XQueryVariable posVar = new XQueryVariable(XMLQueryCompilerConstants.POS_VAR_NAME, posVarType, posLVar); tCtx.varScope.registerVariable(posVar); unnest.getInputs().add(mutable(tCtx.op)); tCtx.op = unnest; }
tCtx.pushVariableScope(); LogicalVariable forLVar = newLogicalVariable(); UnnestOperator unnest = new UnnestOperator(forLVar, mutable(ufce(BuiltinOperators.ITERATE, seq))); SequenceType forVarType = SequenceType.create(AnyItemType.INSTANCE, Quantifier.QUANT_ONE); if (qvdNode.getType() != null) {
scanExp.setSourceLocation(sourceLoc); LogicalVariable scanVar = context.newVar(); UnnestOperator unn = new UnnestOperator(scanVar, new MutableObject<>(scanExp)); unn.setSourceLocation(sourceLoc); unn.getInputs().add(new MutableObject<>(ets));
LogicalVariable forLVar = newLogicalVariable(); LogicalVariable posLVar = fvdNode.getPosVar() != null ? newLogicalVariable() : null; UnnestOperator unnest = new UnnestOperator(forLVar, mutable(ufce(BuiltinOperators.ITERATE, seq)), posLVar, BuiltinTypeRegistry.XS_INTEGER, new VXQueryPositionWriter());
Collections.singletonList(new MutableObject<>(selectVarRef))); scanCollExpr.setSourceLocation(ifexpr.getSourceLocation()); UnnestOperator unnestOp = new UnnestOperator(unnestVar, new MutableObject<>(scanCollExpr)); unnestOp.getInputs().add(new MutableObject<>(assignOp)); unnestOp.setSourceLocation(ifexpr.getSourceLocation());