@Override public Long visitLimitOperator(LimitOperator op, Void arg) throws AlgebricksException { return adjustCardinalityForTupleReductionOperator(op.getInputs().get(0).getValue().accept(this, arg)); }
VariableUtilities.getSubplanLocalLiveVariables(op.getInputs().get(0).getValue(), inputLiveVars); ILogicalOperator assignOp = assignOpAndRecordVar.first; LogicalVariable recordVar = assignOpAndRecordVar.second; ILogicalOperator inputOp = op.getInputs().get(0).getValue(); assignOp.getInputs().add(new MutableObject<>(inputOp));
@Override public Pair<ILogicalOperator, LogicalVariable> visit(LimitClause lc, Mutable<ILogicalOperator> tupSource) throws CompilationException { SourceLocation sourceLoc = lc.getSourceLocation(); LimitOperator opLim; Pair<ILogicalExpression, Mutable<ILogicalOperator>> p1 = langExprToAlgExpression(lc.getLimitExpr(), tupSource); ILogicalExpression maxObjectsExpr = createLimitOffsetValueExpression(p1.first, lc.getLimitExpr().getSourceLocation()); Expression offset = lc.getOffset(); if (offset != null) { Pair<ILogicalExpression, Mutable<ILogicalOperator>> p2 = langExprToAlgExpression(offset, p1.second); ILogicalExpression offsetExpr = createLimitOffsetValueExpression(p2.first, lc.getOffset().getSourceLocation()); opLim = new LimitOperator(maxObjectsExpr, offsetExpr); opLim.getInputs().add(p2.second); opLim.setSourceLocation(sourceLoc); } else { opLim = new LimitOperator(maxObjectsExpr); opLim.getInputs().add(p1.second); opLim.setSourceLocation(sourceLoc); } return new Pair<>(opLim, null); }
@Override public void contributeRuntimeOperator(IHyracksJobBuilder builder, JobGenContext context, ILogicalOperator op, IOperatorSchema propagatedSchema, IOperatorSchema[] inputSchemas, IOperatorSchema outerPlanSchema) throws AlgebricksException { LimitOperator limit = (LimitOperator) op; IExpressionRuntimeProvider expressionRuntimeProvider = context.getExpressionRuntimeProvider(); IVariableTypeEnvironment env = context.getTypeEnvironment(op); IScalarEvaluatorFactory maxObjectsFact = expressionRuntimeProvider .createEvaluatorFactory(limit.getMaxObjects().getValue(), env, inputSchemas, context); ILogicalExpression offsetExpr = limit.getOffset().getValue(); IScalarEvaluatorFactory offsetFact = (offsetExpr == null) ? null : expressionRuntimeProvider.createEvaluatorFactory(offsetExpr, env, inputSchemas, context); RecordDescriptor recDesc = JobGenHelper.mkRecordDescriptor(context.getTypeEnvironment(op), propagatedSchema, context); StreamLimitRuntimeFactory runtime = new StreamLimitRuntimeFactory(maxObjectsFact, offsetFact, null, context.getBinaryIntegerInspectorFactory()); runtime.setSourceLocation(limit.getSourceLocation()); builder.contributeMicroOperator(limit, runtime, recDesc); // and contribute one edge from its child ILogicalOperator src = limit.getInputs().get(0).getValue(); builder.contributeGraphEdge(src, 0, limit, 0); }