use of org.teiid.query.processor.relational.FakeRelationalNode in project teiid by teiid.
the class TestBatchIterator method testBatchReadDuringMark.
@Test
public void testBatchReadDuringMark() throws Exception {
BatchIterator bi = new BatchIterator(new FakeRelationalNode(1, new List[] { Arrays.asList(1), Arrays.asList(1), Arrays.asList(1), Arrays.asList(1) }, 2));
BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
// $NON-NLS-1$
bi.setBuffer(bm.createTupleBuffer(Arrays.asList(new ElementSymbol("x", null, DataTypeManager.DefaultDataClasses.INTEGER)), "test", TupleSourceType.PROCESSOR), true);
bi.mark();
assertNotNull(bi.nextTuple());
assertNotNull(bi.nextTuple());
assertNotNull(bi.nextTuple());
bi.reset();
assertNotNull(bi.nextTuple());
assertNotNull(bi.nextTuple());
assertNotNull(bi.nextTuple());
assertNotNull(bi.nextTuple());
assertNull(bi.nextTuple());
}
use of org.teiid.query.processor.relational.FakeRelationalNode in project teiid by teiid.
the class TestBatchIterator method testNoSaveForwardOnly.
@Test
public void testNoSaveForwardOnly() throws Exception {
BatchIterator bi = new BatchIterator(new FakeRelationalNode(1, new List[] { Arrays.asList(1), Arrays.asList(1), Arrays.asList(1), Arrays.asList(1) }, 2) {
@Override
public TupleBatch nextBatchDirect() throws BlockedException, TeiidComponentException, TeiidProcessingException {
TupleBatch tb = super.nextBatchDirect();
tb.setRowOffset(tb.getBeginRow() + 3);
return tb;
}
});
BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
TupleBuffer tb = bm.createTupleBuffer(Arrays.asList(new ElementSymbol("x", null, DataTypeManager.DefaultDataClasses.INTEGER)), "test", TupleSourceType.PROCESSOR);
tb.setForwardOnly(true);
// $NON-NLS-1$
bi.setBuffer(tb, false);
tb.addTuple(Arrays.asList(2));
tb.addTuple(Arrays.asList(2));
tb.addTuple(Arrays.asList(2));
assertEquals(3, bi.getBuffer().getManagedRowCount());
bi.nextTuple();
// pull the first batch
assertEquals(2, bi.available());
assertEquals(0, bi.getBuffer().getManagedRowCount());
for (int i = 0; i < 2; i++) {
assertNotNull(bi.nextTuple());
assertEquals(0, bi.getBuffer().getManagedRowCount());
}
bi.readAhead(3);
assertEquals(2, bi.getBuffer().getManagedRowCount());
for (int i = 0; i < 4; i++) {
assertNotNull(bi.nextTuple());
assertEquals(0, bi.getBuffer().getManagedRowCount());
}
assertNull(bi.nextTuple());
assertEquals(0, bi.getBuffer().getManagedRowCount());
}
use of org.teiid.query.processor.relational.FakeRelationalNode in project teiid by teiid.
the class TestBatchIterator method testReadAheadMark.
@Test
public void testReadAheadMark() throws Exception {
BatchIterator bi = new BatchIterator(new FakeRelationalNode(1, new List[] { Arrays.asList(1), Arrays.asList(1), Arrays.asList(1), Arrays.asList(1), Arrays.asList(1), Arrays.asList(1), Arrays.asList(1) }, 2));
BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
TupleBuffer tb = bm.createTupleBuffer(Arrays.asList(new ElementSymbol("x", null, DataTypeManager.DefaultDataClasses.INTEGER)), "test", TupleSourceType.PROCESSOR);
// $NON-NLS-1$
bi.setBuffer(tb, true);
bi.nextTuple();
assertEquals(1, bi.available());
assertEquals(0, bi.getBuffer().getRowCount());
bi.readAhead(100);
assertEquals(4, bi.getBuffer().getRowCount());
// shouldn't keep reading
bi.readAhead(2);
assertEquals(4, bi.getBuffer().getRowCount());
bi.readAhead(5);
assertEquals(6, bi.getBuffer().getRowCount());
// does nothing
bi.readAhead(8);
for (int i = 0; i < 6; i++) {
assertNotNull(bi.nextTuple());
}
assertNull(bi.nextTuple());
}
use of org.teiid.query.processor.relational.FakeRelationalNode in project teiid by teiid.
the class TestBatchIterator method testReadAhead.
@Test
public void testReadAhead() throws Exception {
BatchIterator bi = new BatchIterator(new FakeRelationalNode(1, new List[] { Arrays.asList(1), Arrays.asList(1), Arrays.asList(1), Arrays.asList(1), Arrays.asList(1), Arrays.asList(1) }, 2));
BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
TupleBuffer tb = bm.createTupleBuffer(Arrays.asList(new ElementSymbol("x", null, DataTypeManager.DefaultDataClasses.INTEGER)), "test", TupleSourceType.PROCESSOR);
// $NON-NLS-1$
bi.setBuffer(tb, false);
bi.nextTuple();
assertEquals(1, bi.available());
assertEquals(2, bi.getBuffer().getRowCount());
bi.readAhead(100);
assertEquals(4, bi.getBuffer().getRowCount());
// shouldn't keep reading
bi.readAhead(3);
assertEquals(4, bi.getBuffer().getRowCount());
bi.readAhead(5);
assertEquals(6, bi.getBuffer().getRowCount());
// does nothing
bi.readAhead(8);
for (int i = 0; i < 5; i++) {
assertNotNull(bi.nextTuple());
}
assertNull(bi.nextTuple());
}
use of org.teiid.query.processor.relational.FakeRelationalNode in project teiid by teiid.
the class TestEnginePerformance method helpTestEquiJoin.
public void helpTestEquiJoin(int expectedRowCount, List<?>[] leftData, List<?>[] rightData, List<? extends Expression> elems, BufferManager bufferManager, JoinStrategy joinStrategy, JoinType joinType) throws TeiidComponentException, TeiidProcessingException {
// $NON-NLS-1$ //$NON-NLS-2$
CommandContext context = new CommandContext("pid", "test", null, null, 1);
FakeRelationalNode dataNode1 = new FakeRelationalNode(1, leftData);
dataNode1.setElements(elems);
dataNode1.initialize(context, bufferManager, null);
FakeRelationalNode dataNode2 = new FakeRelationalNode(2, rightData);
dataNode2.setElements(elems);
dataNode2.initialize(context, bufferManager, null);
JoinNode join = new JoinNode(3);
join.addChild(dataNode1);
join.addChild(dataNode2);
join.setJoinStrategy(joinStrategy.clone());
join.setElements(elems);
join.setJoinType(joinType);
join.setJoinExpressions(elems.subList(0, 1), elems.subList(0, 1));
join.initialize(context, bufferManager, null);
process(join, expectedRowCount);
}
Aggregations