public long available() { if (batch != null && batch.containsRow(getCurrentIndex())) { return batch.getEndRow() - getCurrentIndex() + 1; } return 0; }
public long available() { if (batch != null && batch.containsRow(getCurrentIndex())) { return batch.getEndRow() - getCurrentIndex() + 1; } return 0; }
public long available() { if (batch != null && batch.containsRow(getCurrentIndex())) { return batch.getEndRow() - getCurrentIndex() + 1; } return 0; }
private void saveTuple(List<?> tuple) throws TeiidComponentException { if (tuple != null && mark && saveOnMark && this.getCurrentIndex() > this.buffer.getRowCount()) { this.buffer.setRowCount(this.getCurrentIndex() - 1); this.buffer.addTuple(tuple); } }
@Override public void setPosition(long position) { if (this.buffer == null && position < getCurrentIndex() && position < (this.batch != null ? batch.getBeginRow() : Long.MAX_VALUE)) { throw new UnsupportedOperationException("Backwards positioning is not allowed"); //$NON-NLS-1$ } super.setPosition(position); }
private void saveTuple(List<?> tuple) throws TeiidComponentException { if (tuple != null && mark && saveOnMark && this.getCurrentIndex() > this.buffer.getRowCount()) { this.buffer.setRowCount(this.getCurrentIndex() - 1); this.buffer.addTuple(tuple); } }
@Override public void setPosition(long position) { if (this.buffer == null && position < getCurrentIndex() && position < (this.batch != null ? batch.getBeginRow() : Long.MAX_VALUE)) { throw new UnsupportedOperationException("Backwards positioning is not allowed"); //$NON-NLS-1$ } super.setPosition(position); }
private void saveTuple(List<?> tuple) throws TeiidComponentException { if (tuple != null && mark && saveOnMark && this.getCurrentIndex() > this.buffer.getRowCount()) { this.buffer.setRowCount(this.getCurrentIndex() - 1); this.buffer.addTuple(tuple); } }
@Override public void setPosition(long position) { if (this.buffer == null && position < getCurrentIndex() && position < (this.batch != null ? batch.getBeginRow() : Long.MAX_VALUE)) { throw new UnsupportedOperationException("Backwards positioning is not allowed"); //$NON-NLS-1$ } super.setPosition(position); }
@Override public void mark() throws TeiidComponentException { super.mark(); if (this.buffer != null && saveOnMark && this.getCurrentIndex() > this.buffer.getRowCount()) { this.buffer.purge(); } mark = true; saveTuple(this.currentTuple); }
@Override public void mark() throws TeiidComponentException { super.mark(); if (this.buffer != null && saveOnMark && this.getCurrentIndex() > this.buffer.getRowCount()) { this.buffer.purge(); } mark = true; saveTuple(this.currentTuple); }
@Override public void mark() throws TeiidComponentException { super.mark(); if (this.buffer != null && saveOnMark && this.getCurrentIndex() > this.buffer.getRowCount()) { this.buffer.purge(); } mark = true; saveTuple(this.currentTuple); }
@Override protected List<?> finalRow() throws TeiidComponentException, TeiidProcessingException { if (this.buffer != null && this.getCurrentIndex() <= this.buffer.getRowCount()) { batch = this.buffer.getBatch(this.getCurrentIndex()); } while (available() < 1) { if (done) { return null; } batch = source.nextBatch(); done = batch.getTerminationFlag(); if (buffer != null && (!saveOnMark || mark) && !buffer.isForwardOnly()) { buffer.addTupleBatch(batch, true); } if (done && buffer != null) { this.buffer.close(); } } return getCurrentTuple(); }
@Override protected List<?> finalRow() throws TeiidComponentException, TeiidProcessingException { if (this.buffer != null && this.getCurrentIndex() <= this.buffer.getRowCount()) { batch = this.buffer.getBatch(this.getCurrentIndex()); } while (available() < 1) { if (done) { return null; } batch = source.nextBatch(); done = batch.getTerminationFlag(); if (buffer != null && (!saveOnMark || mark) && !buffer.isForwardOnly()) { buffer.addTupleBatch(batch, true); } if (done && buffer != null) { this.buffer.close(); } } return getCurrentTuple(); }
@Override protected List<?> finalRow() throws TeiidComponentException, TeiidProcessingException { if (this.buffer != null && this.getCurrentIndex() <= this.buffer.getRowCount()) { batch = this.buffer.getBatch(this.getCurrentIndex()); } while (available() < 1) { if (done) { return null; } batch = source.nextBatch(); done = batch.getTerminationFlag(); if (buffer != null && (!saveOnMark || mark) && !buffer.isForwardOnly()) { buffer.addTupleBatch(batch, true); } if (done && buffer != null) { this.buffer.close(); } } return getCurrentTuple(); }
@Test public void testReset1() throws Exception { BatchIterator bi = new BatchIterator(new FakeRelationalNode(1, new List[] { Arrays.asList(1), Arrays.asList(2), Arrays.asList(3) }, 2)); BufferManager bm = BufferManagerFactory.getStandaloneBufferManager(); TupleBuffer tb = bm.createTupleBuffer(Arrays.asList(new ElementSymbol("x", null, DataTypeManager.DefaultDataClasses.INTEGER)), "test", TupleSourceType.PROCESSOR); bi.setBuffer(tb, true); //$NON-NLS-1$ bi.nextTuple(); bi.mark(); bi.nextTuple(); bi.reset(); assertEquals(2, bi.getCurrentIndex()); assertEquals(2, bi.nextTuple().get(0)); }
@Test public void testReset2() throws Exception { BatchIterator bi = new BatchIterator(new FakeRelationalNode(1, new List[] { Arrays.asList(1), Arrays.asList(2), }, 2)); BufferManager bm = BufferManagerFactory.getStandaloneBufferManager(); TupleBuffer tb = bm.createTupleBuffer(Arrays.asList(new ElementSymbol("x", null, DataTypeManager.DefaultDataClasses.INTEGER)), "test", TupleSourceType.PROCESSOR); bi.setBuffer(tb, true); //$NON-NLS-1$ bi.hasNext(); bi.mark(); bi.nextTuple(); bi.nextTuple(); assertNull(bi.nextTuple()); bi.reset(); bi.hasNext(); assertEquals(1, bi.getCurrentIndex()); assertEquals(1, bi.nextTuple().get(0)); }