@Test public void testReadAhead() throws Exception { BatchIterator bi = new BatchIterator(new FakeRelationalNode(1, new List[] { Arrays.asList(1), Arrays.asList(1), Arrays.asList(1), Arrays.asList(1), Arrays.asList(1), Arrays.asList(1), }, 2)); BufferManager bm = BufferManagerFactory.getStandaloneBufferManager(); TupleBuffer tb = bm.createTupleBuffer(Arrays.asList(new ElementSymbol("x", null, DataTypeManager.DefaultDataClasses.INTEGER)), "test", TupleSourceType.PROCESSOR); bi.setBuffer(tb, false); bi.nextTuple(); assertEquals(1, bi.available()); assertEquals(2, bi.getBuffer().getRowCount()); bi.readAhead(100); assertEquals(4, bi.getBuffer().getRowCount()); bi.readAhead(3); assertEquals(4, bi.getBuffer().getRowCount()); bi.readAhead(5); assertEquals(6, bi.getBuffer().getRowCount()); bi.readAhead(8); for (int i = 0; i < 5; i++) { assertNotNull(bi.nextTuple()); } assertNull(bi.nextTuple()); }
public void readAhead(long limit) throws TeiidComponentException, TeiidProcessingException { if (buffer == null || done) { return; } if (this.buffer.getManagedRowCount() >= limit) { return; } if (this.batch != null && this.buffer.getRowCount() < this.batch.getEndRow() && !this.buffer.isForwardOnly()) { this.buffer.addTupleBatch(this.batch, true); } TupleBatch tb = source.nextBatch(); done = tb.getTerminationFlag(); this.buffer.addTupleBatch(tb, true); if (done) { this.buffer.close(); } }
BatchIterator extends AbstractTupleSource { public void readAhead(long limit) throws TeiidComponentException, TeiidProcessingException { if (buffer == null || done) { return; } if (this.buffer.getManagedRowCount() >= limit) { return; } if (this.batch != null && this.buffer.getRowCount() < this.batch.getEndRow() && !this.buffer.isForwardOnly()) { this.buffer.addTupleBatch(this.batch, true); } TupleBatch tb = source.nextBatch(); done = tb.getTerminationFlag(); this.buffer.addTupleBatch(tb, true); if (done) { this.buffer.close(); } } }
BatchIterator extends AbstractTupleSource { public void readAhead(long limit) throws TeiidComponentException, TeiidProcessingException { if (buffer == null || done) { return; } if (this.buffer.getManagedRowCount() >= limit) { return; } if (this.batch != null && this.buffer.getRowCount() < this.batch.getEndRow() && !this.buffer.isForwardOnly()) { this.buffer.addTupleBatch(this.batch, true); } TupleBatch tb = source.nextBatch(); done = tb.getTerminationFlag(); this.buffer.addTupleBatch(tb, true); if (done) { this.buffer.close(); } } BatchIterator(BatchProducer source); }
BatchIterator extends AbstractTupleSource { public void readAhead(long limit) throws TeiidComponentException, TeiidProcessingException { if (buffer == null || done) { return; } if (this.buffer.getManagedRowCount() >= limit) { return; } if (this.batch != null && this.buffer.getRowCount() < this.batch.getEndRow() && !this.buffer.isForwardOnly()) { this.buffer.addTupleBatch(this.batch, true); } TupleBatch tb = source.nextBatch(); done = tb.getTerminationFlag(); this.buffer.addTupleBatch(tb, true); if (done) { this.buffer.close(); } } BatchIterator(BatchProducer source); long available(); void setBuffer(TupleBuffer buffer, boolean saveOnMark); @Override void closeSource(); @Override void reset(); @Override void mark(); @Override void setPosition(long position); boolean ensureSave(); void disableSave(); void readAhead(long limit); TupleBuffer getBuffer(); }
BatchIterator extends AbstractTupleSource { public void readAhead(long limit) throws TeiidComponentException, TeiidProcessingException { if (buffer == null || done) { return; } if (this.buffer.getManagedRowCount() >= limit) { return; } if (this.batch != null && this.buffer.getRowCount() < this.batch.getEndRow() && !this.buffer.isForwardOnly()) { this.buffer.addTupleBatch(this.batch, true); } TupleBatch tb = source.nextBatch(); done = tb.getTerminationFlag(); this.buffer.addTupleBatch(tb, true); if (done) { this.buffer.close(); } } BatchIterator(BatchProducer source); long available(); void setBuffer(TupleBuffer buffer, boolean saveOnMark); @Override void closeSource(); @Override void reset(); @Override void mark(); @Override void setPosition(long position); boolean ensureSave(); void disableSave(); void readAhead(long limit); TupleBuffer getBuffer();  }