@Override public boolean equals(Object object) { if (this == object) { return true; } if (!(object instanceof LimitClause)) { return false; } LimitClause target = (LimitClause) object; return limitExpr.equals(target.getLimitExpr()) && Objects.equals(offset, target.getOffset()); } }
@Override public Void visit(LimitClause limitClause, Collection<VariableExpr> freeVars) throws CompilationException { limitClause.getLimitExpr().accept(this, freeVars); return null; }
@Override public Void visit(LimitClause lc, Integer step) throws CompilationException { out.print(skip(step) + "limit "); lc.getLimitExpr().accept(this, step + 1); if (lc.getOffset() != null) { out.print(" offset "); lc.getOffset().accept(this, step + 1); } out.println(); return null; }
@Override public Boolean visit(LimitClause lc, ILangExpression arg) throws CompilationException { return visit(lc.getLimitExpr(), arg) || visit(lc.getOffset(), arg); }
@Override public Void visit(LimitClause lc, Integer step) throws CompilationException { out.println(skip(step) + "Limit"); lc.getLimitExpr().accept(this, step + 1); if (lc.getOffset() != null) { out.println(skip(step + 1) + "Offset"); lc.getOffset().accept(this, step + 2); } return null; }
@Override public Void visit(LimitClause lc, Void arg) throws CompilationException { lc.getLimitExpr().accept(this, arg); if (lc.getOffset() != null) { lc.getOffset().accept(this, arg); } return null; }
@Override public Expression visit(LimitClause limitClause, ILangExpression arg) throws CompilationException { limitClause.setLimitExpr(visit(limitClause.getLimitExpr(), limitClause)); if (limitClause.hasOffset()) { limitClause.setOffset(visit(limitClause.getOffset(), limitClause)); } return null; }
@Override public Expression visit(LimitClause limitClause, ILangExpression arg) throws CompilationException { limitClause.setLimitExpr(visit(limitClause.getLimitExpr(), limitClause)); if (limitClause.hasOffset()) { limitClause.setOffset(visit(limitClause.getOffset(), limitClause)); } return null; }
@Override public Boolean visit(LimitClause lc, List<FunctionDecl> arg) throws CompilationException { Pair<Boolean, Expression> p1 = inlineUdfsInExpr(lc.getLimitExpr(), arg); lc.setLimitExpr(p1.second); boolean changed = p1.first; if (lc.getOffset() != null) { Pair<Boolean, Expression> p2 = inlineUdfsInExpr(lc.getOffset(), arg); lc.setOffset(p2.second); changed = changed || p2.first; } return changed; }
@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<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 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 Expression visit(LimitClause limitClause, ILangExpression arg) throws CompilationException { scopeChecker.pushForbiddenScope(scopeChecker.getCurrentScope()); limitClause.setLimitExpr(visit(limitClause.getLimitExpr(), limitClause)); if (limitClause.hasOffset()) { limitClause.setOffset(visit(limitClause.getOffset(), limitClause)); } scopeChecker.popForbiddenScope(); return null; }