Search in sources :

Example 6 with FakeRelationalNode

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());
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) List(java.util.List) FakeRelationalNode(org.teiid.query.processor.relational.FakeRelationalNode) BufferManager(org.teiid.common.buffer.BufferManager) Test(org.junit.Test)

Example 7 with FakeRelationalNode

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());
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) TupleBuffer(org.teiid.common.buffer.TupleBuffer) List(java.util.List) TeiidComponentException(org.teiid.core.TeiidComponentException) FakeRelationalNode(org.teiid.query.processor.relational.FakeRelationalNode) BufferManager(org.teiid.common.buffer.BufferManager) BlockedException(org.teiid.common.buffer.BlockedException) TeiidProcessingException(org.teiid.core.TeiidProcessingException) TupleBatch(org.teiid.common.buffer.TupleBatch) Test(org.junit.Test)

Example 8 with FakeRelationalNode

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());
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) TupleBuffer(org.teiid.common.buffer.TupleBuffer) List(java.util.List) FakeRelationalNode(org.teiid.query.processor.relational.FakeRelationalNode) BufferManager(org.teiid.common.buffer.BufferManager) Test(org.junit.Test)

Example 9 with FakeRelationalNode

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());
}
Also used : ElementSymbol(org.teiid.query.sql.symbol.ElementSymbol) TupleBuffer(org.teiid.common.buffer.TupleBuffer) List(java.util.List) FakeRelationalNode(org.teiid.query.processor.relational.FakeRelationalNode) BufferManager(org.teiid.common.buffer.BufferManager) Test(org.junit.Test)

Example 10 with FakeRelationalNode

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);
}
Also used : CommandContext(org.teiid.query.util.CommandContext) JoinNode(org.teiid.query.processor.relational.JoinNode) BlockingFakeRelationalNode(org.teiid.query.processor.relational.BlockingFakeRelationalNode) FakeRelationalNode(org.teiid.query.processor.relational.FakeRelationalNode)

Aggregations

FakeRelationalNode (org.teiid.query.processor.relational.FakeRelationalNode)10 Test (org.junit.Test)9 ElementSymbol (org.teiid.query.sql.symbol.ElementSymbol)9 List (java.util.List)8 BufferManager (org.teiid.common.buffer.BufferManager)8 TupleBuffer (org.teiid.common.buffer.TupleBuffer)6 CommandContext (org.teiid.query.util.CommandContext)2 BlockedException (org.teiid.common.buffer.BlockedException)1 TupleBatch (org.teiid.common.buffer.TupleBatch)1 TeiidComponentException (org.teiid.core.TeiidComponentException)1 TeiidProcessingException (org.teiid.core.TeiidProcessingException)1 BlockingFakeRelationalNode (org.teiid.query.processor.relational.BlockingFakeRelationalNode)1 JoinNode (org.teiid.query.processor.relational.JoinNode)1