@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);
}