Search in sources :

Example 1 with FakeRelationalNode

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());
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) CommandContext(org.teiid.query.util.CommandContext) FakeRelationalNode(org.teiid.query.processor.relational.FakeRelationalNode) Test(org.junit.Test)

Example 2 with FakeRelationalNode

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();
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) List(java.util.List) FakeRelationalNode(org.teiid.query.processor.relational.FakeRelationalNode) BufferManager(org.teiid.common.buffer.BufferManager) Test(org.junit.Test)

Example 3 with FakeRelationalNode

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());
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) TupleBuffer(org.teiid.common.buffer.TupleBuffer) List(java.util.List) FakeRelationalNode(org.teiid.query.processor.relational.FakeRelationalNode) BufferManager(org.teiid.common.buffer.BufferManager) Test(org.junit.Test)

Example 4 with FakeRelationalNode

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));
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) TupleBuffer(org.teiid.common.buffer.TupleBuffer) List(java.util.List) FakeRelationalNode(org.teiid.query.processor.relational.FakeRelationalNode) BufferManager(org.teiid.common.buffer.BufferManager) Test(org.junit.Test)

Example 5 with FakeRelationalNode

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));
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) TupleBuffer(org.teiid.common.buffer.TupleBuffer) List(java.util.List) FakeRelationalNode(org.teiid.query.processor.relational.FakeRelationalNode) BufferManager(org.teiid.common.buffer.BufferManager) Test(org.junit.Test)

Aggregations

FakeRelationalNode (org.teiid.query.processor.relational.FakeRelationalNode)10 Test (org.junit.Test)9 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)9 List (java.util.List)8 BufferManager (org.teiid.common.buffer.BufferManager)8 TupleBuffer (org.teiid.common.buffer.TupleBuffer)6 CommandContext (org.teiid.query.util.CommandContext)2 BlockedException (org.teiid.common.buffer.BlockedException)1 TupleBatch (org.teiid.common.buffer.TupleBatch)1 TeiidComponentException (org.teiid.core.TeiidComponentException)1 TeiidProcessingException (org.teiid.core.TeiidProcessingException)1 BlockingFakeRelationalNode (org.teiid.query.processor.relational.BlockingFakeRelationalNode)1 JoinNode (org.teiid.query.processor.relational.JoinNode)1