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