Author: jolee
Date: 2012-07-30 08:59:25 -0400 (Mon, 30 Jul 2012)
New Revision: 4274
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/BatchIterator.java
branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestBatchIterator.java
Log:
TEIID-2120 fix for batchiterator early termination
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/BatchIterator.java
===================================================================
---
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/BatchIterator.java 2012-07-28
01:25:33 UTC (rev 4273)
+++
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/BatchIterator.java 2012-07-30
12:59:25 UTC (rev 4274)
@@ -69,7 +69,7 @@
}
batch = source.nextBatch();
done = batch.getTerminationFlag();
- if (buffer != null && !saveOnMark) {
+ if (buffer != null && (!saveOnMark || mark)) {
buffer.addTupleBatch(batch, true);
}
}
Modified:
branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestBatchIterator.java
===================================================================
---
branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestBatchIterator.java 2012-07-28
01:25:33 UTC (rev 4273)
+++
branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestBatchIterator.java 2012-07-30
12:59:25 UTC (rev 4274)
@@ -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