use of org.teiid.common.buffer.TupleBatch in project teiid by teiid.
the class TestBatchedUpdateNode method helpTestNextBatch.
private FakePDM helpTestNextBatch(String[] commands, int[] expectedResults) throws Exception {
int numExecutedCommands = 0;
for (int i = 0; i < expectedResults.length; i++) {
numExecutedCommands += expectedResults[i];
}
FakePDM fakePDM = new FakePDM(numExecutedCommands);
BatchedUpdateNode node = helpOpen(commands, fakePDM);
TupleBatch batch = null;
try {
batch = node.nextBatch();
} catch (BlockedException e) {
batch = node.nextBatch();
}
assertNotNull(batch);
assertTrue(batch.getTerminationFlag());
assertEquals(expectedResults.length, batch.getRowCount());
for (int i = 0; i < expectedResults.length; i++) {
List tuple = batch.getTuple(i + 1);
assertNotNull(tuple);
Object result = tuple.get(0);
assertNotNull(result);
assertEquals(new Integer(expectedResults[i]), result);
}
return fakePDM;
}
use of org.teiid.common.buffer.TupleBatch in project teiid by teiid.
the class TestJoinNode method process.
private void process(List[] expectedResults) throws TeiidComponentException, TeiidProcessingException {
join.open();
int currentRow = 1;
while (true) {
try {
TupleBatch batch = join.nextBatch();
for (; currentRow <= batch.getEndRow(); currentRow++) {
List tuple = batch.getTuple(currentRow);
// $NON-NLS-1$
assertEquals("Rows don't match at " + currentRow, expectedResults[currentRow - 1], tuple);
}
if (batch.getTerminationFlag()) {
break;
}
} catch (BlockedException e) {
// ignore and retry
}
}
assertEquals(expectedResults.length, currentRow - 1);
join.close();
}
use of org.teiid.common.buffer.TupleBatch in project teiid by teiid.
the class TestJoinNode method testMergeJoinPrefetchAlreadySorted.
@Test
public void testMergeJoinPrefetchAlreadySorted() throws Exception {
this.joinType = JoinType.JOIN_INNER;
int rows = 50;
List[] data = new List[rows];
for (int i = 0; i < rows; i++) {
data[i] = new ArrayList();
Integer value = new Integer((i * 17) % 47);
data[i].add(value);
}
this.leftTuples = data;
this.rightTuples = new List[] { Arrays.asList(1), Arrays.asList(2), Arrays.asList(4), Arrays.asList(6), Arrays.asList(7), Arrays.asList(8) };
expected = new List[] { Arrays.asList(new Object[] { 1, 1 }), Arrays.asList(new Object[] { 2, 2 }), Arrays.asList(new Object[] { 4, 4 }), Arrays.asList(new Object[] { 6, 6 }), Arrays.asList(new Object[] { 7, 7 }), Arrays.asList(new Object[] { 8, 8 }) };
helpCreateJoin();
this.joinStrategy = new MergeJoinStrategy(SortOption.SORT, SortOption.ALREADY_SORTED, false);
BlockingFakeRelationalNode newNode = new BlockingFakeRelationalNode(2, rightTuples) {
@Override
public TupleBatch nextBatchDirect() throws BlockedException, TeiidComponentException, TeiidProcessingException {
TupleBatch tb = super.nextBatchDirect();
if (tb.getTerminationFlag()) {
assertFalse(leftNode.isClosed());
}
return tb;
}
};
newNode.setElements(rightNode.getElements());
rightNode = newNode;
this.join.setJoinStrategy(joinStrategy);
helpTestJoinDirect(expected, 5, 1);
}
use of org.teiid.common.buffer.TupleBatch in project teiid by teiid.
the class TestLimitNode method testLimitMultipleOfBatchSize.
@Test
public void testLimitMultipleOfBatchSize() throws Exception {
LimitNode node = getLimitNode(100, new FakeRelationalNode(2, getRows(150), 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();
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 testLimitAtBatchSize.
@Test
public void testLimitAtBatchSize() throws Exception {
LimitNode node = getLimitNode(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());
assertTrue(batch.getTerminationFlag());
}
Aggregations