Search in sources :

Example 21 with TupleBatch

use of org.teiid.common.buffer.TupleBatch in project teiid by teiid.

the class TestLimitNode method testZeroLimit.

@Test
public void testZeroLimit() throws Exception {
    LimitNode node = getLimitNode(0, new FakeRelationalNode(2, getRows(100), 50));
    TupleBatch batch = node.nextBatch();
    batch = node.nextBatch();
    assertNotNull(batch);
    assertEquals(0, batch.getRowCount());
    assertEquals(1, batch.getBeginRow());
    assertEquals(0, batch.getEndRow());
    assertTrue(batch.getTerminationFlag());
}
Also used : TupleBatch(org.teiid.common.buffer.TupleBatch) Test(org.junit.Test)

Example 22 with TupleBatch

use of org.teiid.common.buffer.TupleBatch in project teiid by teiid.

the class TestLimitNode method testZeroOffset.

@Test
public void testZeroOffset() throws Exception {
    LimitNode node = getOffsetNode(0, new FakeRelationalNode(2, getRows(100), 50));
    TupleBatch batch = node.nextBatch();
    assertNotNull(batch);
    assertEquals(50, batch.getRowCount());
    assertEquals(1, batch.getBeginRow());
    assertEquals(50, batch.getEndRow());
    assertFalse(batch.getTerminationFlag());
    batch = node.nextBatch();
    assertNotNull(batch);
    assertEquals(50, batch.getRowCount());
    assertEquals(51, batch.getBeginRow());
    assertEquals(100, batch.getEndRow());
    assertTrue(batch.getTerminationFlag());
}
Also used : TupleBatch(org.teiid.common.buffer.TupleBatch) Test(org.junit.Test)

Example 23 with TupleBatch

use of org.teiid.common.buffer.TupleBatch in project teiid by teiid.

the class TestLimitNode method testOffsetGreaterThanRowCount.

@Test
public void testOffsetGreaterThanRowCount() throws Exception {
    LimitNode node = getOffsetNode(100, new FakeRelationalNode(2, getRows(10), 50));
    TupleBatch batch = node.nextBatch();
    assertNotNull(batch);
    assertEquals(0, batch.getRowCount());
    assertTrue(batch.getTerminationFlag());
}
Also used : TupleBatch(org.teiid.common.buffer.TupleBatch) Test(org.junit.Test)

Example 24 with TupleBatch

use of org.teiid.common.buffer.TupleBatch in project teiid by teiid.

the class TestQueryProcessor method testProcessWithOccasionalBlocks.

@Test
public void testProcessWithOccasionalBlocks() throws Exception {
    List elements = new ArrayList();
    // $NON-NLS-1$
    elements.add(new ElementSymbol("x", null, DataTypeManager.DefaultDataClasses.INTEGER));
    HashSet blocked = new HashSet(Arrays.asList(new Integer[] { new Integer(0), new Integer(2), new Integer(7) }));
    int numBatches = 10;
    int batchRow = 1;
    int rowsPerBatch = 50;
    List[] expectedResults = new List[rowsPerBatch * (numBatches - blocked.size())];
    List batches = new ArrayList();
    for (int b = 0; b < numBatches; b++) {
        if (blocked.contains(new Integer(b))) {
            batches.add(BlockedException.INSTANCE);
        } else {
            List[] rows = new List[rowsPerBatch];
            for (int i = 0; i < rowsPerBatch; i++) {
                rows[i] = new ArrayList();
                rows[i].add(new Integer(batchRow));
                expectedResults[batchRow - 1] = rows[i];
                batchRow++;
            }
            TupleBatch batch = new TupleBatch(batchRow - rows.length, rows);
            if (b == numBatches - 1) {
                batch.setTerminationFlag(true);
            }
            batches.add(batch);
        }
    }
    FakeProcessorPlan plan = new FakeProcessorPlan(elements, batches);
    helpTestProcessor(plan, expectedResults);
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) HashSet(java.util.HashSet) TupleBatch(org.teiid.common.buffer.TupleBatch) Test(org.junit.Test)

Example 25 with TupleBatch

use of org.teiid.common.buffer.TupleBatch in project teiid by teiid.

the class TestLimitNode method testLimitGetsNoRows.

@Test
public void testLimitGetsNoRows() throws Exception {
    LimitNode node = getLimitNode(100, new FakeRelationalNode(2, getRows(0), 50));
    TupleBatch batch = node.nextBatch();
    assertNotNull(batch);
    assertEquals(0, batch.getRowCount());
    assertTrue(batch.getTerminationFlag());
}
Also used : TupleBatch(org.teiid.common.buffer.TupleBatch) Test(org.junit.Test)

Aggregations

TupleBatch (org.teiid.common.buffer.TupleBatch)61 Test (org.junit.Test)26 List (java.util.List)23 ArrayList (java.util.ArrayList)22 BlockedException (org.teiid.common.buffer.BlockedException)17 CommandContext (org.teiid.query.util.CommandContext)10 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)9 TeiidProcessingException (org.teiid.core.TeiidProcessingException)8 TeiidComponentException (org.teiid.core.TeiidComponentException)6 BufferManager (org.teiid.common.buffer.BufferManager)4 TupleBuffer (org.teiid.common.buffer.TupleBuffer)4 TeiidRuntimeException (org.teiid.core.TeiidRuntimeException)3 TransactionContext (org.teiid.dqp.service.TransactionContext)3 TransactionService (org.teiid.dqp.service.TransactionService)3 ExpressionEvaluationException (org.teiid.api.exception.query.ExpressionEvaluationException)2 BufferManagerImpl (org.teiid.common.buffer.impl.BufferManagerImpl)2 TeiidException (org.teiid.core.TeiidException)2 QueryProcessor (org.teiid.query.processor.QueryProcessor)2 FakeRelationalNode (org.teiid.query.processor.relational.FakeRelationalNode)2 CacheHint (org.teiid.query.sql.lang.CacheHint)2