use of org.teiid.common.buffer.TupleBatch in project teiid by teiid.
the class TestQueryProcessor method testBlockNoResults.
@Test
public void testBlockNoResults() throws Exception {
List elements = new ArrayList();
// $NON-NLS-1$
elements.add(new ElementSymbol("x", null, DataTypeManager.DefaultDataClasses.INTEGER));
List batches = new ArrayList();
batches.add(BlockedException.INSTANCE);
TupleBatch batch = new TupleBatch(1, new List[0]);
batch.setTerminationFlag(true);
batches.add(batch);
FakeProcessorPlan plan = new FakeProcessorPlan(elements, batches);
helpTestProcessor(plan, new List[0]);
}
use of org.teiid.common.buffer.TupleBatch in project teiid by teiid.
the class FakeRelationalNode method nextBatchDirect.
/**
* @throws TeiidProcessingException
* @see com.metamatrix.query.processor.relational.x.RelationalNode#nextBatch()
*/
public TupleBatch nextBatchDirect() throws BlockedException, TeiidComponentException, TeiidProcessingException {
if (data != null) {
if (currentRow < data.length) {
int endRow = Math.min(data.length, currentRow + getBatchSize());
List batchRows = new ArrayList();
for (int i = currentRow; i < endRow; i++) {
batchRows.add(data[i]);
}
TupleBatch batch = new TupleBatch(currentRow + 1, batchRows);
currentRow += batch.getRowCount();
if (currentRow >= data.length) {
batch.setTerminationFlag(true);
}
return batch;
}
TupleBatch batch = new TupleBatch(currentRow + 1, Collections.EMPTY_LIST);
batch.setTerminationFlag(true);
return batch;
}
boolean last = false;
List rows = new ArrayList(batchSize);
for (int i = 0; i < batchSize; i++) {
List tuple = source.nextTuple();
if (tuple == null) {
last = true;
break;
}
rows.add(tuple);
}
TupleBatch batch = new TupleBatch(currentRow + 1, rows);
if (last) {
batch.setTerminationFlag(true);
} else {
currentRow += rows.size();
}
return batch;
}
use of org.teiid.common.buffer.TupleBatch in project teiid by teiid.
the class TestGroupingNode method helpProcess.
private void helpProcess(BufferManager mgr, GroupingNode node, CommandContext context, List[] expected, FakeTupleSource dataSource, ProcessorDataManager dataMgr) throws TeiidComponentException, BlockedException, TeiidProcessingException {
RelationalNode dataNode = new FakeRelationalNode(0, dataSource, mgr.getProcessorBatchSize());
dataNode.setElements(dataSource.getSchema());
node.addChild(dataNode);
node.initialize(context, mgr, dataMgr);
node.open();
int currentRow = 1;
while (true) {
try {
TupleBatch batch = node.nextBatch();
for (int row = currentRow; row <= batch.getEndRow(); row++) {
List tuple = batch.getTuple(row);
// $NON-NLS-1$
assertEquals("Rows don't match at " + row, expected[row - 1], tuple);
}
currentRow += batch.getRowCount();
if (batch.getTerminationFlag()) {
break;
}
} catch (BlockedException e) {
// ignore
}
}
assertEquals(expected.length, currentRow - 1);
}
use of org.teiid.common.buffer.TupleBatch in project teiid by teiid.
the class TestLimitNode method testOffsetInFirstBatch.
@Test
public void testOffsetInFirstBatch() throws Exception {
LimitNode node = getOffsetNode(49, new FakeRelationalNode(2, getRows(100), 50));
// batch 1
TupleBatch batch = node.nextBatch();
assertNotNull(batch);
assertEquals(1, batch.getRowCount());
assertEquals(1, batch.getBeginRow());
assertEquals(1, batch.getEndRow());
assertEquals(Arrays.asList(new Object[] { new Integer(50) }), batch.getTuple(1));
assertFalse(batch.getTerminationFlag());
// batch2
batch = node.nextBatch();
assertNotNull(batch);
assertEquals(50, batch.getRowCount());
assertEquals(2, batch.getBeginRow());
assertEquals(51, batch.getEndRow());
assertEquals(Arrays.asList(new Object[] { new Integer(51) }), batch.getTuple(2));
assertTrue(batch.getTerminationFlag());
}
use of org.teiid.common.buffer.TupleBatch in project teiid by teiid.
the class TestLimitNode method testOffsetNoRows.
@Test
public void testOffsetNoRows() throws Exception {
LimitNode node = getOffsetNode(100, new FakeRelationalNode(2, getRows(0), 50));
TupleBatch batch = node.nextBatch();
assertNotNull(batch);
assertEquals(0, batch.getRowCount());
assertTrue(batch.getTerminationFlag());
}
Aggregations