Author: shawkins
Date: 2012-07-27 21:25:33 -0400 (Fri, 27 Jul 2012)
New Revision: 4273
Modified:
trunk/engine/src/main/java/org/teiid/query/processor/BatchIterator.java
trunk/engine/src/test/java/org/teiid/query/processor/TestBatchIterator.java
Log:
TEIID-2120 fix for batchiterator early termination
Modified: trunk/engine/src/main/java/org/teiid/query/processor/BatchIterator.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/BatchIterator.java 2012-07-26
17:21:06 UTC (rev 4272)
+++ trunk/engine/src/main/java/org/teiid/query/processor/BatchIterator.java 2012-07-28
01:25:33 UTC (rev 4273)
@@ -69,7 +69,7 @@
}
batch = source.nextBatch();
done = batch.getTerminationFlag();
- if (buffer != null && !saveOnMark) {
+ if (buffer != null && (!saveOnMark || mark)) {
buffer.addTupleBatch(batch, true);
}
}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestBatchIterator.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestBatchIterator.java 2012-07-26
17:21:06 UTC (rev 4272)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestBatchIterator.java 2012-07-28
01:25:33 UTC (rev 4273)
@@ -32,7 +32,6 @@
import org.teiid.common.buffer.BufferManagerFactory;
import org.teiid.common.buffer.TupleBuffer;
import org.teiid.common.buffer.BufferManager.TupleSourceType;
-import org.teiid.query.processor.BatchIterator;
import org.teiid.query.processor.relational.FakeRelationalNode;
import org.teiid.query.sql.symbol.ElementSymbol;
@@ -91,4 +90,21 @@
assertEquals(1, bi.nextTuple().get(0));
}
+ @Test public void testBatchReadDuringMark() throws Exception {
+ BatchIterator bi = new BatchIterator(new FakeRelationalNode(1, new List[] {
+ Arrays.asList(1),
+ Arrays.asList(1),
+ }, 1));
+ BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
+ bi.setBuffer(bm.createTupleBuffer(Arrays.asList(new ElementSymbol("x")),
"test", TupleSourceType.PROCESSOR), true); //$NON-NLS-1$
+ bi.mark();
+ assertNotNull(bi.nextTuple());
+ assertNotNull(bi.nextTuple());
+ assertNull(bi.nextTuple());
+ bi.reset();
+ assertNotNull(bi.nextTuple());
+ assertNotNull(bi.nextTuple());
+ assertNull(bi.nextTuple());
+ }
+
}
Show replies by date