use of org.teiid.common.buffer.TupleBatch in project teiid by teiid.
the class TestLimitNode method testLimitInFirstBatch.
@Test
public void testLimitInFirstBatch() throws Exception {
LimitNode node = getLimitNode(40, new FakeRelationalNode(2, getRows(100), 50));
TupleBatch batch = node.nextBatch();
assertNotNull(batch);
assertEquals(40, batch.getRowCount());
assertEquals(1, batch.getBeginRow());
assertEquals(40, batch.getEndRow());
assertTrue(batch.getTerminationFlag());
}
use of org.teiid.common.buffer.TupleBatch in project teiid by teiid.
the class TestProjectIntoNode method helpTestNextBatch.
private void helpTestNextBatch(int tupleBatchSize, Mode mode) throws Exception {
ProjectIntoNode node = new ProjectIntoNode(2);
TupleSource tupleSource = new FakeDataTupleSource(NUM_ROWS);
RelationalNode child = new FakeRelationalNode(1, tupleSource, tupleBatchSize);
node.addChild(child);
// $NON-NLS-1$
node.setIntoGroup(new GroupSymbol("myGroup"));
// $NON-NLS-1$
ElementSymbol elementSymbol_1 = new ElementSymbol("myGroup.myElement1");
// $NON-NLS-1$
ElementSymbol elementSymbol_2 = new ElementSymbol("myGroup.myElement2");
elementSymbol_1.setType(Integer.class);
elementSymbol_2.setType(String.class);
List<ElementSymbol> elements = Arrays.asList(elementSymbol_1, elementSymbol_2);
node.setIntoElements(elements);
child.setElements(elements);
node.setMode(mode);
// $NON-NLS-1$
node.setModelName("myModel");
CommandContext context = new CommandContext();
BufferManager bm = BufferManagerFactory.getTestBufferManager(tupleBatchSize, tupleBatchSize);
ProcessorDataManager dataManager = new FakePDM(tupleBatchSize);
child.initialize(context, bm, dataManager);
node.initialize(context, bm, dataManager);
node.open();
TupleBatch batch = null;
// Do the remaining batches
while (true) {
try {
batch = node.nextBatch();
break;
} catch (BlockedException e) {
// Normal
}
}
assertNotNull(batch);
List[] tuples = batch.getAllTuples();
assertEquals(1, tuples.length);
Object[] columns = tuples[0].toArray();
assertNotNull(columns);
assertEquals(1, columns.length);
// Should have inserted all rows
assertEquals(new Integer(NUM_ROWS), columns[0]);
}
use of org.teiid.common.buffer.TupleBatch in project teiid by teiid.
the class TestProjectNode method helpTestProject.
public void helpTestProject(List elements, List[] data, List childElements, List[] expected, ProcessorDataManager dataMgr) throws TeiidComponentException, TeiidProcessingException {
ProjectNode projectNode = helpSetupProject(elements, data, childElements, dataMgr);
projectNode.open();
int currentRow = 1;
while (true) {
try {
TupleBatch batch = projectNode.nextBatch();
for (int row = currentRow; row <= batch.getEndRow(); row++) {
// $NON-NLS-1$
assertEquals("Rows don't match at " + row, expected[row - 1], batch.getTuple(row));
}
if (batch.getTerminationFlag()) {
break;
}
currentRow += batch.getRowCount();
} catch (BlockedException e) {
// ignore and try again
}
}
}
use of org.teiid.common.buffer.TupleBatch in project teiid by teiid.
the class TestProjectNode method helpTestProjectFails.
public void helpTestProjectFails(List elements, List[] data, List childElements, String expectedError) throws TeiidComponentException, TeiidProcessingException {
ProjectNode projectNode = helpSetupProject(elements, data, childElements, null);
try {
projectNode.open();
while (true) {
TupleBatch batch = projectNode.nextBatch();
if (batch.getTerminationFlag()) {
break;
}
}
// $NON-NLS-1$
fail("Expected error but test succeeded");
} catch (ExpressionEvaluationException e) {
// note that this should not be a component exception, which would indicate that something abnormal happened
// $NON-NLS-1$
assertEquals("Got unexpected exception", expectedError.toUpperCase(), e.getMessage().toUpperCase());
}
}
use of org.teiid.common.buffer.TupleBatch in project teiid by teiid.
the class TestRelationalNodeStatistics method testDescriptionProperties.
@Test
public void testDescriptionProperties() throws Exception {
List[] data = createData(1000);
FakeRelationalNode fakeNode = createFakeNode(data);
// read from fake node
while (true) {
TupleBatch batch = fakeNode.nextBatch();
if (batch.getTerminationFlag()) {
break;
}
}
// $NON-NLS-1$
assertEquals("FakeRelationalNode", fakeNode.getDescriptionProperties().getName());
}
Aggregations