use of org.teiid.query.processor.relational.FakeRelationalNode in project teiid by teiid.
the class TestBatchCollector method testCollect.
@Test
public void testCollect() throws Exception {
FakeRelationalNode sourceNode = new FakeRelationalNode(1, new List[] { Arrays.asList(1), Arrays.asList(1), Arrays.asList(1) }, 1);
sourceNode.setElements(Arrays.asList(new ElementSymbol("x", null, DataTypeManager.DefaultDataClasses.INTEGER)));
BatchCollector bc = new BatchCollector(sourceNode, BufferManagerFactory.getStandaloneBufferManager(), new CommandContext(), false);
bc.collectTuples(true);
assertEquals(1, bc.getTupleBuffer().getManagedRowCount());
assertEquals(3, bc.collectTuples().getRowCount());
}
use of org.teiid.query.processor.relational.FakeRelationalNode in project teiid by teiid.
the class TestBatchIterator method testReset.
@Test
public void testReset() throws Exception {
BatchIterator bi = new BatchIterator(new FakeRelationalNode(1, new List[] { Arrays.asList(1), Arrays.asList(1), Arrays.asList(1) }, 1));
BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
// $NON-NLS-1$
bi.setBuffer(bm.createTupleBuffer(Arrays.asList(new ElementSymbol("x", null, DataTypeManager.DefaultDataClasses.INTEGER)), "test", TupleSourceType.PROCESSOR), true);
bi.mark();
bi.nextTuple();
bi.nextTuple();
bi.reset();
bi.nextTuple();
}
use of org.teiid.query.processor.relational.FakeRelationalNode in project teiid by teiid.
the class TestBatchIterator method testDisableSave.
@Test
public void testDisableSave() 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);
// $NON-NLS-1$
bi.setBuffer(tb, false);
bi.setPosition(2);
assertTrue(bi.hasNext());
tb.setForwardOnly(true);
bi.setPosition(1);
bi.disableSave();
for (int i = 0; i < 6; i++) {
assertNotNull(bi.nextTuple());
}
assertNull(bi.nextTuple());
assertEquals(0, tb.getManagedRowCount());
}
use of org.teiid.query.processor.relational.FakeRelationalNode in project teiid by teiid.
the class TestBatchIterator method testReset1.
@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);
// $NON-NLS-1$
bi.setBuffer(tb, true);
bi.nextTuple();
bi.mark();
bi.nextTuple();
bi.reset();
assertEquals(2, bi.getCurrentIndex());
assertEquals(2, bi.nextTuple().get(0));
}
use of org.teiid.query.processor.relational.FakeRelationalNode in project teiid by teiid.
the class TestBatchIterator method testReset2.
@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);
// $NON-NLS-1$
bi.setBuffer(tb, true);
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));
}
Aggregations