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(); }
public static AccessNode getAccessNode(ProcessorPlan plan) { if(!(plan instanceof RelationalPlan)) { return null; } RelationalPlan rplan = (RelationalPlan) plan; // Check that the plan is just an access node RelationalNode accessNode = rplan.getRootNode(); if (accessNode instanceof LimitNode) { LimitNode ln = (LimitNode)accessNode; if (!ln.isImplicit()) { return null; } accessNode = ln.getChildren()[0]; } if (! (accessNode instanceof AccessNode)) { return null; } return (AccessNode)accessNode; }
this.terminateBatches(); return pullBatch(); batch = getChildren()[0].nextBatch(); // Can throw BlockedException rowCounter += batch.getRowCount(); if (batch.getTerminationFlag()) { rowCounter = 0; } else { batch = getChildren()[0].nextBatch(); // Can throw BlockedException
Expression rowLimit = (Expression)node.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT); Expression offset = (Expression)node.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT); LimitNode ln = new LimitNode(getID(), rowLimit, offset); ln.setImplicit(node.hasBooleanProperty(Info.IS_IMPLICIT_LIMIT)); processNode = ln; break;
@Test public void testClone() { LimitNode node = new LimitNode(1, new Constant(new Integer(-1)), null); LimitNode clone = (LimitNode)node.clone(); assertEquals(node.getLimitExpr(), clone.getLimitExpr()); assertNull(clone.getOffsetExpr()); node = new LimitNode(1, null, new Constant(new Integer(-1))); clone = (LimitNode)node.clone(); assertNull(clone.getLimitExpr()); } }
@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()); }
@Override public TupleBuffer getBufferDirect(int maxRows) throws BlockedException, TeiidComponentException, TeiidProcessingException { if (maxRows >= 0) { if (limit >= 0) { maxRows = Math.min(maxRows, limit); } } else { maxRows = limit; } return this.getChildren()[0].getBuffer(maxRows); }
if (parent instanceof LimitNode) { LimitNode ln = (LimitNode)parent; if (ln.getLimit() != -1) { hasLimit = true;
this.terminateBatches(); return pullBatch(); batch = getChildren()[0].nextBatch(); // Can throw BlockedException rowCounter += batch.getRowCount(); if (batch.getTerminationFlag()) { rowCounter = 0; } else { batch = getChildren()[0].nextBatch(); // Can throw BlockedException
Expression rowLimit = (Expression)node.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT); Expression offset = (Expression)node.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT); LimitNode ln = new LimitNode(getID(), rowLimit, offset); ln.setImplicit(node.hasBooleanProperty(Info.IS_IMPLICIT_LIMIT)); processNode = ln; break;
public static AccessNode getAccessNode(ProcessorPlan plan) { if(!(plan instanceof RelationalPlan)) { return null; } RelationalPlan rplan = (RelationalPlan) plan; // Check that the plan is just an access node RelationalNode accessNode = rplan.getRootNode(); if (accessNode instanceof LimitNode) { LimitNode ln = (LimitNode)accessNode; if (!ln.isImplicit()) { return null; } accessNode = ln.getChildren()[0]; } if (! (accessNode instanceof AccessNode)) { return null; } return (AccessNode)accessNode; }
@Override public boolean hasBuffer() { //TODO: support offset return offsetExpr == null && this.getChildren()[0].hasBuffer(); }
if (parent instanceof LimitNode) { LimitNode ln = (LimitNode)parent; if (ln.getLimit() != -1) { hasLimit = true;
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(); }