@Test public void testOffsetWithoutLimit() throws Exception { LimitNode node = new LimitNode(1, null, new Constant(new Integer(10))); node.addChild(new FakeRelationalNode(2, getRows(10), 50)); node.open(); TupleBatch batch = node.nextBatch(); assertNotNull(batch); assertEquals(0, batch.getRowCount()); assertTrue(batch.getTerminationFlag()); }
public void open() throws TeiidComponentException, TeiidProcessingException { limit = -1; if (limitExpr != null) { Integer limitVal = (Integer)new Evaluator(Collections.emptyMap(), getDataManager(), getContext()).evaluate(limitExpr, Collections.emptyList()); ValidationVisitor.LIMIT_CONSTRAINT.validate(limitVal); limit = limitVal.intValue(); } if (limit == 0) { return; } if (offsetExpr != null) { Integer offsetVal = (Integer)new Evaluator(Collections.emptyMap(), getDataManager(), getContext()).evaluate(offsetExpr, Collections.emptyList()); ValidationVisitor.LIMIT_CONSTRAINT.validate(offsetVal); offset = offsetVal.intValue(); } else { offset = 0; } offsetPhase = offset > 0; if (limit > -1 && this.getChildren()[0] instanceof SortNode) { ((SortNode)this.getChildren()[0]).setRowLimit((int) Math.min(Integer.MAX_VALUE, (long)limit + offset)); } super.open(); }
LimitNode extends RelationalNode { public void open() throws TeiidComponentException, TeiidProcessingException { limit = -1; if (limitExpr != null) { Integer limitVal = (Integer)new Evaluator(Collections.emptyMap(), getDataManager(), getContext()).evaluate(limitExpr, Collections.emptyList()); ValidationVisitor.LIMIT_CONSTRAINT.validate(limitVal); limit = limitVal.intValue(); } if (limit == 0) { return; } if (offsetExpr != null) { Integer offsetVal = (Integer)new Evaluator(Collections.emptyMap(), getDataManager(), getContext()).evaluate(offsetExpr, Collections.emptyList()); ValidationVisitor.LIMIT_CONSTRAINT.validate(offsetVal); offset = offsetVal.intValue(); } else { offset = 0; } offsetPhase = offset > 0; if (limit > -1 && this.getChildren()[0] instanceof SortNode) { ((SortNode)this.getChildren()[0]).setRowLimit((int) Math.min(Integer.MAX_VALUE, (long)limit + offset)); } super.open(); } }
LimitNode extends RelationalNode { public void open() throws TeiidComponentException, TeiidProcessingException { limit = -1; if (limitExpr != null) { Integer limitVal = (Integer)new Evaluator(Collections.emptyMap(), getDataManager(), getContext()).evaluate(limitExpr, Collections.emptyList()); ValidationVisitor.LIMIT_CONSTRAINT.validate(limitVal); limit = limitVal.intValue(); } if (limit == 0) { return; } if (offsetExpr != null) { Integer offsetVal = (Integer)new Evaluator(Collections.emptyMap(), getDataManager(), getContext()).evaluate(offsetExpr, Collections.emptyList()); ValidationVisitor.LIMIT_CONSTRAINT.validate(offsetVal); offset = offsetVal.intValue(); } else { offset = 0; } offsetPhase = offset > 0; if (limit > -1 && this.getChildren()[0] instanceof SortNode) { ((SortNode)this.getChildren()[0]).setRowLimit((int) Math.min(Integer.MAX_VALUE, (long)limit + offset)); } super.open(); } LimitNode(int nodeID, Expression limitExpr, Expression offsetExpr); }
LimitNode extends RelationalNode { public void open() throws TeiidComponentException, TeiidProcessingException { limit = -1; if (limitExpr != null) { Integer limitVal = (Integer)new Evaluator(Collections.emptyMap(), getDataManager(), getContext()).evaluate(limitExpr, Collections.emptyList()); ValidationVisitor.LIMIT_CONSTRAINT.validate(limitVal); limit = limitVal.intValue(); } if (limit == 0) { return; } if (offsetExpr != null) { Integer offsetVal = (Integer)new Evaluator(Collections.emptyMap(), getDataManager(), getContext()).evaluate(offsetExpr, Collections.emptyList()); ValidationVisitor.LIMIT_CONSTRAINT.validate(offsetVal); offset = offsetVal.intValue(); } else { offset = 0; } offsetPhase = offset > 0; if (limit > -1 && this.getChildren()[0] instanceof SortNode) { ((SortNode)this.getChildren()[0]).setRowLimit((int) Math.min(Integer.MAX_VALUE, (long)limit + offset)); } super.open(); } LimitNode(int nodeID, Expression limitExpr, Expression offsetExpr); void setImplicit(boolean implicit); boolean isImplicit(); void open(); void reset(); PlanNode getDescriptionProperties(); Object clone(); Expression getLimitExpr(); Expression getOffsetExpr(); int getLimit(); int getOffset(); @Override boolean hasBuffer(); @Override TupleBuffer getBufferDirect(int maxRows); }
LimitNode extends RelationalNode { public void open() throws TeiidComponentException, TeiidProcessingException { limit = -1; if (limitExpr != null) { Integer limitVal = (Integer)new Evaluator(Collections.emptyMap(), getDataManager(), getContext()).evaluate(limitExpr, Collections.emptyList()); ValidationVisitor.LIMIT_CONSTRAINT.validate(limitVal); limit = limitVal.intValue(); } if (limit == 0) { return; } if (offsetExpr != null) { Integer offsetVal = (Integer)new Evaluator(Collections.emptyMap(), getDataManager(), getContext()).evaluate(offsetExpr, Collections.emptyList()); ValidationVisitor.LIMIT_CONSTRAINT.validate(offsetVal); offset = offsetVal.intValue(); } else { offset = 0; } offsetPhase = offset > 0; if (limit > -1 && this.getChildren()[0] instanceof SortNode) { ((SortNode)this.getChildren()[0]).setRowLimit((int) Math.min(Integer.MAX_VALUE, (long)limit + offset)); } super.open(); } LimitNode(int nodeID, Expression limitExpr, Expression offsetExpr); void setImplicit(boolean implicit); boolean isImplicit(); void open(); void reset(); PlanNode getDescriptionProperties(); Object clone(); Expression getLimitExpr(); Expression getOffsetExpr(); int getLimit(); int getOffset(); @Override boolean hasBuffer(); @Override TupleBuffer getBufferDirect(int maxRows);  }