@Override public LimitClause visit(LimitClause limitClause, Void arg) throws CompilationException { Expression limitExpr = (Expression) limitClause.getLimitExpr().accept(this, arg); Expression offsetExpr = limitClause.hasOffset() ? (Expression) limitClause.getOffset().accept(this, arg) : null; LimitClause copy = new LimitClause(limitExpr, offsetExpr); copy.setSourceLocation(limitClause.getSourceLocation()); return copy; }
@Override public Pair<ILangExpression, VariableSubstitutionEnvironment> visit(LimitClause lc, VariableSubstitutionEnvironment env) throws CompilationException { Pair<ILangExpression, VariableSubstitutionEnvironment> p1 = lc.getLimitExpr().accept(this, env); Pair<ILangExpression, VariableSubstitutionEnvironment> p2; Expression lcOffsetExpr = lc.getOffset(); if (lcOffsetExpr != null) { p2 = lcOffsetExpr.accept(this, env); } else { p2 = new Pair<>(null, null); } LimitClause c = new LimitClause((Expression) p1.first, (Expression) p2.first); c.setSourceLocation(lc.getSourceLocation()); return new Pair<>(c, env); }
@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); }