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());
}
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);
}
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());
}
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;
}
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));
}
}
Aggregations