Search in sources :

Example 26 with TupleBatch

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

the class TestLimitNode method testOffsetAtBatchSize.

@Test
public void testOffsetAtBatchSize() throws Exception {
    LimitNode node = getOffsetNode(50, new FakeRelationalNode(2, getRows(100), 50));
    TupleBatch batch = node.nextBatch();
    assertNotNull(batch);
    assertEquals(50, batch.getRowCount());
    assertEquals(1, batch.getBeginRow());
    assertEquals(50, batch.getEndRow());
    assertEquals(Arrays.asList(new Object[] { new Integer(51) }), batch.getTuple(1));
    assertTrue(batch.getTerminationFlag());
}
Also used : TupleBatch(org.teiid.common.buffer.TupleBatch) Test(org.junit.Test)

Example 27 with TupleBatch

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

the class TestRelationalNodeStatistics method testStatsCollection.

@Test
public void testStatsCollection() throws TeiidComponentException, TeiidProcessingException {
    List[] data = createData(1000);
    FakeRelationalNode fakeNode = createFakeNode(data);
    // read from fake node
    while (true) {
        TupleBatch batch = fakeNode.nextBatch();
        if (batch.getTerminationFlag()) {
            break;
        }
    }
    int actualNodeBlocks = fakeNode.getNodeStatistics().getNodeBlocks();
    int actualNodeNextBatchCalls = fakeNode.getNodeStatistics().getNodeNextBatchCalls();
    long actualNodeOutputRows = fakeNode.getNodeStatistics().getNodeOutputRows();
    // $NON-NLS-1$
    assertEquals("The NodeOutputRows was Inccorrect. Correct: 1000 Actual: " + actualNodeOutputRows, 1000, actualNodeOutputRows);
    // $NON-NLS-1$
    assertEquals("The NodeNextBatchCalls was Inccorrect. Correct: 10 Actual: " + actualNodeNextBatchCalls, 10, actualNodeNextBatchCalls);
    // $NON-NLS-1$
    assertEquals("The NodeBlocks was Inccorrect. Correct: 0 Actual: " + actualNodeBlocks, 0, actualNodeBlocks);
}
Also used : List(java.util.List) ArrayList(java.util.ArrayList) TupleBatch(org.teiid.common.buffer.TupleBatch) Test(org.junit.Test)

Example 28 with TupleBatch

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

the class TestRelationalPlan method testNoRowsFirstBatch.

public void testNoRowsFirstBatch() throws Exception {
    RelationalNode node = new FakeRelationalNode(0, new List[0]);
    RelationalPlan plan = new RelationalPlan(node);
    TupleBatch batch = plan.nextBatch();
    // $NON-NLS-1$
    assertTrue("Did not get terminator batch", batch.getTerminationFlag());
}
Also used : RelationalNode(org.teiid.query.processor.relational.RelationalNode) RelationalPlan(org.teiid.query.processor.relational.RelationalPlan) TupleBatch(org.teiid.common.buffer.TupleBatch)

Example 29 with TupleBatch

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

the class FakeProcessorPlan method nextBatch.

/**
 * @see org.teiid.query.processor.ProcessorPlan#nextBatch()
 */
public TupleBatch nextBatch() throws BlockedException, TeiidComponentException {
    if (this.batches == null || this.batches.size() == 0 || batchIndex >= this.batches.size()) {
        // Return empty terminator batch
        TupleBatch batch = new TupleBatch(nextBatchRow, Collections.EMPTY_LIST);
        batch.setTerminationFlag(true);
        return batch;
    }
    Object nextReturn = this.batches.get(batchIndex);
    batchIndex++;
    if (nextReturn instanceof TupleBatch) {
        TupleBatch batch = (TupleBatch) nextReturn;
        nextBatchRow = nextBatchRow + batch.getRowCount();
        return batch;
    }
    throw (TeiidComponentException) nextReturn;
}
Also used : TeiidComponentException(org.teiid.core.TeiidComponentException) TupleBatch(org.teiid.common.buffer.TupleBatch)

Example 30 with TupleBatch

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

the class TestBatchedUpdatePlan method helpTestNextBatch.

private void helpTestNextBatch(int[] commandsPerPlan) throws Exception {
    List plans = new ArrayList(commandsPerPlan.length);
    int totalCommands = 0;
    for (int i = 0; i < commandsPerPlan.length; i++) {
        totalCommands += commandsPerPlan[i];
        plans.add(new FakeProcessorPlan(commandsPerPlan[i]));
    }
    BatchedUpdatePlan plan = new BatchedUpdatePlan(plans, totalCommands, null, false);
    plan.initialize(new CommandContext(), null, null);
    TupleBatch batch = plan.nextBatch();
    assertEquals(totalCommands, batch.getRowCount());
    for (int i = 1; i <= totalCommands; i++) {
        assertEquals(new Integer(1), batch.getTuple(i).get(0));
    }
}
Also used : CommandContext(org.teiid.query.util.CommandContext) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) TupleBatch(org.teiid.common.buffer.TupleBatch)

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